docs: upgrade to Storybook 10 & add accessibility testing#3295
docs: upgrade to Storybook 10 & add accessibility testing#3295
Conversation
skip-automated-commits either explicitly exits with 0 or exits without any code, which is a 0 exit, so it never actually skips anything
|
View your CI Pipeline Execution ↗ for commit 6e746e7 ☁️ Nx Cloud last updated this comment at |
|
in storybook 10, the default undefined option is responsive so we don't need this
these were added during this branch's explorations and I'm just now removing them
|
📬 Published Alpha Packages: |
| - 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 }} |
There was a problem hiding this comment.
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
|
🚀 Styleguide deploy preview ready! Preview URL: https://69bdc09e28081ed92ba4ddf1--gamut-preview.netlify.app |
| . "$(dirname -- "$0")/_/husky.sh" | ||
|
|
||
| npx lint-staged --relative | ||
| npx lint-staged |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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.
| "eslint-plugin-gamut": "^2.0.0", | ||
| "eslint-plugin-gamut": "workspace:*", |
There was a problem hiding this comment.
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\"" |
There was a problem hiding this comment.
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=styleguideI 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", |
There was a problem hiding this comment.
Added automatically by husky init.
| presets: [ | ||
| [require.resolve('@babel/preset-typescript'), { allowDeclareFields: true }], | ||
| [require.resolve('@babel/preset-react'), { runtime: 'automatic' }], | ||
| ], |
There was a problem hiding this comment.
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?
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
Testing Instructions
yarn && yarn build && yarn build-storybookyarn playwright install chromiumthenyarn test:storybookyarn start:storybook) and then spot-check docs, toolbars, and the new a11y panel