8000 feat: Include individual settings snapshots by rafaeelaudibert · Pull Request #33809 · PostHog/posthog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 7 commits into from
Jun 18, 2025

Conversation

rafaeelaudibert
Copy link
Member
@rafaeelaudibert rafaeelaudibert commented Jun 17, 2025

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

@rafaeelaudibert rafaeelaudibert requested review from Twixes and a team June 17, 2025 15:56
@rafaeelaudibert rafaeelaudibert force-pushed the refactor-settings-snapshots branch 2 times, most recently from 2c9951c to 56baa47 Compare June 17, 2025 17:29
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
@rafaeelaudibert rafaeelaudibert force-pushed the refactor-settings-snapshots branch from 56baa47 to 36a66ac Compare June 17, 2025 18:07
Copy link
Contributor
github-actions bot commented Jun 17, 2025

Size Change: 0 B

Total Size: 2.57 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 2.57 MB

compressed-size-action

They'd be useful, but I dont know enough about kea, kea tests and this logic to get them to pass
@rafaeelaudibert rafaeelaudibert marked this pull request as ready for review June 17, 2025 22:28
Copy link
Contributor
@greptile-apps greptile-apps bot left a 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

Comment on lines +208 to +210
'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,
Copy link
Member Author

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 ✨

Copy link
Member
@Twixes Twixes left a 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> = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great

Comment on lines +213 to +215
// NOTE: This is here to avoid TS complaining
// about us not using the variable used above to check all sections
;(() => _ALL_SECTIONS_CHECKER)()
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member
@Twixes Twixes left a 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

@rafaeelaudibert rafaeelaudibert merged commit 4816d45 into master Jun 18, 2025
104 checks passed
@rafaeelaudibert rafaeelaudibert deleted the refactor-settings-snapshots branch June 18, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0