Skip to content

docs: upgrade to Storybook 10 & add accessibility testing#3295

Open
sh0ji wants to merge 23 commits intomainfrom
evan-storybook-10
Open

docs: upgrade to Storybook 10 & add accessibility testing#3295
sh0ji wants to merge 23 commits intomainfrom
evan-storybook-10

Conversation

@sh0ji
Copy link
Member

@sh0ji sh0ji commented Mar 19, 2026

While reviewing Datepicker for accessibility issues, I was wishing we had some basic accessibility tests, so I worked with Cursor to upgrade to Storybook 10 and add their built-in accessibility testing, which runs off Playwright. While working on this, I also upgraded husky & lint-staged because my IDE wasn't using them to lint/format files.

The overall diff is pretty big because it includes a bunch of little changes to stories like changing the import names of the new packages, but individual commit diffs should be pretty legible if you want a more chunked view of the changes.

Changelog description

Upgrades the Styleguide to Storybook 10 (preview, addon-docs, and MDX).
Adds Storybook’s built-in accessibility testing, with a dedicated CI job and Nx target so a11y checks run in the pipeline.

PR Checklist

  • Related to JIRA ticket: GMT-1465 GMT-153
  • I have run this code to verify it works
  • This PR includes testing instructions tests for the code change

Testing Instructions

  • update deps and build storybook: yarn && yarn build && yarn build-storybook
  • run the new tests: yarn playwright install chromium then yarn test:storybook
  • run storybook in dev mode (yarn start:storybook) and then spot-check docs, toolbars, and the new a11y panel

@nx-cloud
Copy link

nx-cloud bot commented Mar 19, 2026

View your CI Pipeline Execution ↗ for commit 6e746e7


☁️ Nx Cloud last updated this comment at 2026-03-20 21:45:08 UTC

@codecov
Copy link

codecov bot commented Mar 19, 2026

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@sh0ji sh0ji changed the title WIP: Storybook 10 & accessibility testing docs: upgrade to Storybook 10 & add accessibility testing Mar 20, 2026
@sh0ji sh0ji marked this pull request as ready for review March 20, 2026 21:42
@sh0ji sh0ji requested a review from a team as a code owner March 20, 2026 21:42
@sh0ji sh0ji requested review from LinKCoding and aresnik11 March 20, 2026 21:42
@codecademydev
Copy link
Collaborator

📬 Published Alpha Packages:

@codecademy/styleguide@79.2.4-alpha.ee1acd.0

Comment on lines -36 to -40
- name: Skip build from automated commit
uses: ./.github/actions/skip-automated-commits
if: github.event_name == 'pull_request'
with:
ignore-commit-message: ${{ env.IGNORE_COMMIT_MESSAGE }}
Copy link
Member Author

Choose a reason for hiding this comment

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

dc8dadd describes my rationale for removing this:

skip-automated-commits either explicitly exits with 0 or exits without any code, which is a 0 exit, so it never actually skips anything

@github-actions
Copy link
Contributor

. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged --relative
npx lint-staged
Copy link
Member Author

Choose a reason for hiding this comment

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

Lint-staged wasn't running on pre-commit for me, so I updated the tooling and I verified that it's working for my environment now. The latest Husky simplified this a bit.

const preview: Preview = {
parameters: {
a11y: {
test: 'todo',
Copy link
Member Author

Choose a reason for hiding this comment

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

There are quite a few a11y errors in our stories, but it was outside of the scope of this PR to fix them so I'm leaving this as todo for now. I'm going to open a separate ticket to fix them, after which we should switch this to error so that CI fails if we have a11y issues in a story.

Comment on lines -69 to +64
"eslint-plugin-gamut": "^2.0.0",
"eslint-plugin-gamut": "workspace:*",
Copy link
Member Author

Choose a reason for hiding this comment

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

Small tweak because my eslint wasn't recognizing this package. This tells yarn to resolve it to the latest workspace directory, which I think is a better approach for local dependencies.

"options": {
"cwd": "{workspaceRoot}",
"forwardAllArgs": false,
"command": "start-server-and-test \"http-server dist/storybook/styleguide -p 6007 --silent\" http://127.0.0.1:6007 \"test-storybook --url http://127.0.0.1:6007 --config-dir packages/styleguide/.storybook\""
Copy link
Member Author

@sh0ji sh0ji Mar 20, 2026

Choose a reason for hiding this comment

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

This was one of the things I spent the most time on because it's such an annoyingly complex command: it serves the Storybook build and runs the Storybook test runner against it, and the start-server-and-test wrapper ensures that the server closes when tests are complete.

Storybook's recommended way to handle this is with Vitest, which would use the waaay simpler

vitest --project=styleguide

I looked into what that would take a bit and concluded it should be a follow-up, not part of this PR, so consider this gnarly command to be a stop-gap. That follow-up will require us to switch to the Vite React builder (from our current webpack5 one), which feels worthwhile for other reasons and we may want to just switch the entire Gamut build process to Vite at the same time.

"format:verify": "yarn prettier --check",
"lint": "eslint --ignore-path .eslintignore \"./**/*.{mdx,js,ts,tsx,json}\" --max-warnings 0",
"lint:fix": "yarn lint --fix",
"prepare": "husky",
Copy link
Member Author

Choose a reason for hiding this comment

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

Added automatically by husky init.

Comment on lines +3 to +6
presets: [
[require.resolve('@babel/preset-typescript'), { allowDeclareFields: true }],
[require.resolve('@babel/preset-react'), { runtime: 'automatic' }],
],
Copy link
Member Author

Choose a reason for hiding this comment

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

This was done by Storybook's automatic migration process. I'm realizing now that I don't 100% know why...I'll look into it but maybe one of you intrepid reviewers knows?

@sh0ji sh0ji requested a review from dreamwasp March 20, 2026 22:04
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