-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Include individual settings snapshots #33809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2c9951c
to
56baa47
Compare
We consistently regenerate our settings snapshots and they're very hard to compare, let's instead create individual snapshots for each of our sections. There's a fair amount of boilerplate, but I've added an `_ALL_SECTIONS_CHECKER` constant to guarantee we're always including new sections. It's unfortunately very hard to make this work dynamically. I tried a couple approaches already but they all failed: `storiesOf`, `Indexer` API, etc. When upgrading to Storybook v8 we should check whether there's an easier way to do this
This used to be covered by snapshot tests which isnt ideal, let's instead test it for real using tests
56baa47
to
36a66ac
Compare
Size Change: 0 B Total Size: 2.57 MB ℹ️ View Unchanged
|
They'd be useful, but I dont know enough about kea, kea tests and this logic to get them to pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Refactors Storybook settings snapshots to use individual section stories instead of a monolithic snapshot, improving maintainability and diff readability.
- Added new
frontend/src/scenes/settings/SettingsScene.stories.tsx
with granular stories for each settings section and type-safe_ALL_SECTIONS_CHECKER
constant - Added comprehensive test suite in
frontend/src/lib/components/TimeSensitiveAuthentication/timeSensitiveAuthenticationLogic.test.ts
- Cleaned up
frontend/src/scenes/settings/types.ts
by removing deprecated sections like 'environment-role-based-access-control' - Extended mock handlers in
frontend/src/mocks/handlers.ts
to support error tracking settings snapshots
4 files reviewed, 3 comments
Edit PR Review Bot Settings | Greptile
...tend/src/lib/components/TimeSensitiveAuthentication/timeSensitiveAuthenticationLogic.test.ts
Show resolved
Hide resolved
'api/environments/:team_id/error_tracking/assignment_rules': EMPTY_PAGINATED_RESPONSE, | ||
'api/environments/:team_id/error_tracking/grouping_rules': EMPTY_PAGINATED_RESPONSE, | ||
'api/environments/:team_id/error_tracking/suppression_rules': EMPTY_PAGINATED_RESPONSE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, this is what was causing the tests to fail, but it was impossible to learn that was the case without the changes I did here ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QQ about ignoring the TypeScript error
SettingsUserDangerZone.args = { sectionId: 'user-danger-zone' } | ||
|
||
// NOTE: This is used to guarantee we're testing all sections | ||
const _ALL_SECTIONS_CHECKER: Record<SettingSectionId, Story> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great
// NOTE: This is here to avoid TS complaining | ||
// about us not using the variable used above to check all sections | ||
;(() => _ALL_SECTIONS_CHECKER)() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use a // @ts-expect-error
comment instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I wanna check with Typescript that we have a snapshot for every possible setting. If I disable Typescript to avoid the "umused variable" warning, it also defeats the purpose of using Typescript to check for full coverage.
I would love a way to disable a single TS rule rather than all or nothing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval to generally unblock, though TypeScript error question pending
We consistently regenerate our settings snapshots and they're very hard to compare, let's instead create individual snapshots for each of our sections.
There's a fair amount of boilerplate, but I've added an
_ALL_SECTIONS_CHECKER
constant to guarantee we're always including new sections.It's unfortunately very hard to make this work dynamically. I tried a couple approaches already but they all failed:
storiesOf
,Indexer
API, etc. When upgrading to Storybook v8 we should check whether there's an easier way to do this