Skip to content
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

[Chromatic] Disable snapshots globally, only keep regression stories #1911

Closed
wants to merge 1 commit into from

Conversation

nishasy
Copy link
Contributor

@nishasy nishasy commented Nov 25, 2024

Summary:

Right now, Chromatic snapshots are only supposed to run on files
that end with .regression.stories.tsx, but they seem to be running
on other stories as well in the github checks.

Instead of using the .yml to specify this, I'm disabling chromatic
using the disableSnapshot chromatic parameter globally, and
manually enabling it in the one regression stories file we have.

Issue: https://khanacademy.atlassian.net/browse/LEMS-2579

Test plan:

Check the chromatic info in the github checks below.

Right now, Chromatic snapshots are only supposed to run on files
that end with `.regression.stories.tsx`, but they seem to be running
on other stories as well in the github checks.

Instead of using the .yml to specify this, I'm disabling chromatic
using the `disableSnapshot` chormatic parameter globablly, and
manually enabling it in the one regression stories file we have.

Issue: https://khanacademy.atlassian.net/browse/LEMS-2579

Test plan:
Check the chromatic info in the github checks below.
@nishasy nishasy self-assigned this Nov 25, 2024
Copy link
Contributor

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (08ee321) and published it to npm. You
can install it using the tag PR1911.

Example:

yarn add @khanacademy/perseus@PR1911

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR1911

Copy link
Contributor

Size Change: 0 B

Total Size: 1.29 MB

ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 4.27 kB
packages/math-input/dist/es/index.js 77.9 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 1.48 kB
packages/perseus-editor/dist/es/index.js 697 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus/dist/es/index.js 421 kB
packages/perseus/dist/es/strings.js 3.57 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@nishasy nishasy marked this pull request as ready for review November 25, 2024 20:55
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/wise-dragons-prove.md, .storybook/preview.tsx, .github/workflows/storybook.yml, packages/perseus/src/widgets/interactive-graphs/interactive-graph-regression.stories.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@nishasy
Copy link
Contributor Author

nishasy commented Nov 25, 2024

The new "test" number on the dashboard matches the expected snapshot number in the checks! I think this means it's working.

image image

*/}
<div className="framework-perseus">
<Story />
</div>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NOTE: This is causing some trivial snapshot updates within the UI tests for the regression stories.

@@ -43,4 +43,3 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_APP_CODE }}
autoAcceptChanges: "main"
onlyStoryFiles: "**/*regression.stories.tsx"
Copy link
Member

Choose a reason for hiding this comment

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

So I think the issue is that onlyStoryFiles is an option inside the chromatic.config.json file, the option is here: https://www.chromatic.com/docs/configure/#options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that's good to know!

I think we're gonna enable a few key stories other than the regression stories soon, so I think it would still be worth removing this from the .yml file.

Copy link
Collaborator

@jeremywiebe jeremywiebe Nov 25, 2024

Choose a reason for hiding this comment

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

It seems like this is working as designed. This setting is documented as being supported in the GitHub Action:

image

On an example PR I checked, it seems like it is obeying the setting:

19:50:09.030 Starting partial build
19:50:09.030     → Snapshots will be limited to story files matching '**/*regression.stories.tsx'

...

19:50:58.649 Build 5134 passed!
                 → Tested 412 stories across 130 components; captured 27 snapshots in 39 seconds

It captured only 27 snapshots.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeremywiebe It does say "captured 27 snapshots" on all the PRs. I checked a bunch of older unrelated Perseus PRs to check this, and it's true that that messaging is consistent. However, the PRs would also show other snapshots that aren't part of these 27 in the "UI test" check. It also says there are 130 tests on the chromatic dashboard for other PRs when there should only be 27:

image

I'd like to move away from using the onlyStoryFiles: "**/*regression.stories.tsx" because I think there's a disconnect somewhere that isn't super obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to retract my last comment. Just for a confidence check, I put up another PR that would have had a ton of UI test updates if my assertion was correct. It only reported changes in the regression stories, so I think my statements before this were all false, and I just don't know what "tests" means on the chromatic dashboard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeremywiebe we can still continue with this PR if we want to enable other stories to have snapshots later, rather than just limiting to regression stories.

@nishasy
Copy link
Contributor Author

nishasy commented Nov 26, 2024

It turns out that the onlyStoryFiles: "**/*regression.stories.tsx" line in the .yml file is working as expected, and I was just misunderstanding the reports in the chromatic dashboard. We don't need to enable snapshots on any other stories at this time, so I'm closing this PR.

@nishasy nishasy closed this Nov 26, 2024
@nishasy nishasy deleted the disable-chromatic-globally-regression branch November 26, 2024 22:05
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.

4 participants