- Write this complete plan to
/STORYBOOK-PLAN.mdat the repository root. - Add plan 13 to
plans/plan-00-tracker.md, linking to../STORYBOOK-PLAN.md. - Keep implementation status only in
plans/plan-00-tracker.md, as required by the repository. - Do not create a duplicate
plans/plan-13-storybook.md. - Before implementation, read:
AGENTS.mdcommit-patterns.mddev_readme-code-patterns.mddev_readme-eslint.mdgood-bad-examples.md- Relevant feature documentation for every touched component.
Every subtask produces exactly one commit.
Workflow for each subtask:
- Implement only that subtask.
- Run its focused tests and mandatory lint/type checks.
- Review every changed line against
dev_readme-code-patterns.md. - Show the uncommitted diff to Nikita.
- Wait for the exact approval phrase:
approved - continue. - Create the subtask’s single planned commit.
- Push it to the Storybook branch so CodeRabbit can review it.
- Resolve CodeRabbit findings before beginning the next subtask.
- If review feedback changes the completed subtask:
- Amend the existing subtask commit with
git commit --amend --no-edit. - Do not add a separate fixup commit.
- Push the amended branch using
git push --force-with-lease.
- Amend the existing subtask commit with
- Start the next subtask only after the amended commit passes its checks and review.
All subjects must follow commit-patterns.md:
- One line.
type: lowercase message.- No scope.
- No body.
- No trailing period.
- Only
fix,upd,style,docs,feat, orchore.
| Order | Subtask | Exact commit |
|---|---|---|
| 1 | Root plan and tracker entry | docs: storybook plan |
| 2 | CodeRabbit configuration | chore: coderabbit review |
| 3 | Mechanical commit and PR-title validator | chore: validate commit names |
| 4 | Storybook packages and base configuration | chore: storybook setup |
| 5 | Providers, typed fixtures, stores, and service mocks | chore: storybook fixtures and providers |
| 6 | Design foundations | feat: storybook foundations |
| 7 | Inputs and controls | feat: storybook inputs and controls |
| 8 | Overlays, feedback, and pending states | feat: storybook overlays and feedback |
| 9 | Product and cart compositions | feat: storybook product and cart |
| 10 | Navigation and authentication | feat: storybook navigation and auth |
| 11 | Support components and interactions | feat: storybook support |
| 12 | Product creation and optimistic rollback | feat: storybook product creation |
| 13 | Product updates and optimistic rollback | feat: storybook product updates |
| 14 | Product deletion and recovery | feat: storybook product deletion |
| 15 | Storybook tests and CI gate | chore: storybook ci |
| 16 | Chromatic publishing and visual-review gate | chore: chromatic publishing |
| 17 | Final documentation and completed tracker status | docs: storybook |
The commit list is fixed. A subject may change only if commit-patterns.md requires it, and that change must be approved before committing.
- Confirm
feat/cypress-e2e-testsis clean and all existing work is committed. - Create
feat/storybookfrom its current HEAD. - Add this plan as
/STORYBOOK-PLAN.md. - Add plan 13 to the tracker as
in progress. - Do not send Storybook changes back to the Cypress branch.
- Open a draft PR into
developmentafter the CodeRabbit configuration is committed and pushed.
Commit: docs: storybook plan
Nikita must grant the CodeRabbit GitHub App access to nicitaacom/23_store:
- GitHub Settings → Applications → Installed GitHub Apps.
- Configure or install CodeRabbit for
nicitaacom. - Add
23_storeunder selected repositories. - Save any requested permission changes.
- Refresh the CodeRabbit workspace after permissions propagate.
Add .coderabbit.yaml with:
- Assertive review profile.
- English output.
- Draft PR reviews enabled.
- Incremental review after each push.
- Review branches
development,production, andproduction-vite. - Request-changes workflow enabled.
- Failed-review commit status enabled.
- GitHub Checks integration enabled.
- Direct autofix disabled so CodeRabbit does not bypass the one-subtask/one-commit review process.
Configure these existing files as CodeRabbit guidelines:
commit-patterns.mddev_readme-code-patterns.mddev_readme-eslint.mdgood-bad-examples.md
AGENTS.md and CLAUDE.md are detected automatically. CodeRabbit will use the files as the source of truth instead of duplicating their contents. CodeRabbit code guidelines
Add blocking AI checks for:
- Changed code compliance with the project code patterns.
- Commit subjects against
commit-patterns.md. - Meaningful test assertions.
- No weakening of tests to accommodate production changes.
- Story isolation from live services.
- Authentication and authorization-sensitive changes.
- Supabase request-bound client and RLS rules.
- No credentials in code, stories, CI, logs, or documentation.
AI checks inspect only the PR’s changes and introduced commits. Pre-existing unrelated code must not fail the PR. CodeRabbit custom checks
Commit: chore: coderabbit review
Add a Node-based CI validator and focused tests.
The validator checks:
- Every non-merge commit introduced by the PR.
- The PR title used for squash merging.
- Allowed commit types.
- Required
type: messageshape. - No scopes.
- No multiline body.
- No trailing period.
- Lowercase message according to
commit-patterns.md.
It must not fail on historical commits outside the PR range.
Add pnpm test:commit-naming and run it in the CI quality job. CodeRabbit provides the AI interpretation; the script provides deterministic enforcement.
Commit: chore: validate commit names
Install with pnpm:
- Storybook 10.5.
@storybook/nextjs-vite.- Docs, themes, accessibility, and Vitest addons.
- Compatible Vitest browser and Playwright dependencies.
- MSW and
msw-storybook-addon. - Chromatic.
Configure:
pnpm storybookon port 6006.pnpm build-storybook.pnpm test:storybook.pnpm chromaticwithout a token argument.- TypeScript CSF stories.
- Autodocs.
@/*aliases.- Next App Router mode.
publicstatic assets.app/globals.css.- No generated tutorial stories.
- Ordered navigation:
- Foundations
- UI
- Commerce
- Navigation
- Authentication
- Support
- Admin
- Viewports at 320, 414, 768, 1024, 1440, and 1920 pixels.
- Theme and locale toolbars.
The Vite framework is Storybook’s recommended Next.js integration and supports the project’s Next 16 and React 19 versions. Storybook Next.js/Vite
Commit: chore: storybook setup
Create typed reusable Storybook support for:
I18nProviderClientwithen,fi,ru, andse.- Light and dark themes using production CSS variables.
- Zustand state reset before every story.
- Users, products, variants, carts, categories, tickets, and messages.
- Fixed dates, IDs, currencies, and image URLs.
- Next pathname, search-parameter, and navigation mocks.
- Deferred promises for optimistic interaction tests.
- SDK/module mocks for Supabase, email, payment, AI, uploads, and Pusher.
- MSW with unexpected application API requests treated as test errors.
- Console and unhandled-promise failure reporting.
Do not add Storybook-specific runtime branches to production components. Introduce presentational props or service injection only when required to isolate an existing component.
Commit: chore: storybook fixtures and providers
Create comparison stories and documentation for:
- Light/dark color tokens.
- Brand and semantic status colors.
- Typography.
- Spacing.
- Radius scale.
- Borders.
- Shadows.
- Focus appearance.
- Disabled appearance.
- Responsive breakpoints.
Use stable matrix stories suitable for Chromatic comparison.
Commit: feat: storybook foundations
Cover:
- Every meaningful Button variant and size.
- Pending, disabled, icon, link, and full-width buttons.
- Base input and validated input.
- Search input.
- Message input.
- Markdown editor and rendered markdown.
- Checkbox.
- Radio button.
- Slider.
- Progress bar.
- Product quantity control.
- Add-to-cart control.
- Dropdown container and item.
Play tests must cover keyboard activation, focus, validation, disabled behavior, quantity boundaries, and callback arguments.
Commit: feat: storybook inputs and controls
Cover:
- Toast variants and dismissal.
- Image success and fallback.
- Skeleton states.
- Empty states.
- Modal containers.
- Confirmation dialogs.
- Search modal.
- Avatar update modal.
- Pending and failure feedback.
Test focus placement, focus return, Escape handling, outside click, destructive confirmation, dismissal, and pending-button protection.
Commit: feat: storybook overlays and feedback
Product stories:
- Normal product.
- Long localized content.
- Missing image.
- Multiple variants.
- Selected variant.
- Sold-out variant.
- Fully out-of-stock product.
- Cart-locked variant.
- Owner controls.
- Anonymous controls.
Cart stories:
- Empty cart.
- One line.
- Multiple lines.
- Variant lines.
- Long product names.
- Quantity changes.
- Removal.
- Correct recalculated totals.
- Anonymous and authenticated price requests.
- Pending, success, and failed price requests.
Tests assert observable product selection, cart state, totals, request arguments, and feedback.
Commit: feat: storybook product and cart
Navigation:
- Anonymous and authenticated navbar.
- Cart counts.
- Owner/admin links.
- Mobile hamburger menu.
- Desktop navigation.
- Language dropdown.
- All locales.
- Light and dark themes.
Authentication:
- Sign-in.
- Registration.
- Password reset.
- Verification timer.
- OAuth choices.
- Validation failures.
- Pending request.
- Backend rejection.
- Authenticated redirect.
- Anonymous protected-action prompt.
No story creates a real authentication cookie or session.
Commit: feat: storybook navigation and auth
Cover:
- Closed and open support button.
- Unread count.
- Empty conversation.
- Multi-day messages.
- Own and foreign messages.
- Attachment preview.
- Image fallback.
- Pending send.
- Failed send.
- Completed ticket.
- Rating.
- Mobile and desktop layouts.
- Anonymous support access.
Play tests assert message entry, submission arguments, failure feedback, modal/dropdown behavior, and state cleanup.
Commit: feat: storybook support
Cover product creation states:
- Empty form.
- Validation errors.
- Valid form.
- Inserting state.
- Optimistic product visible while the mocked request remains unresolved.
- Confirmed server response replacing the temporary product.
- Failed request removing the temporary product.
- Error toast.
- Duplicate-submission prevention.
The play test must explicitly prove that the optimistic row appears before the request resolves.
Commit: feat: storybook product creation
Cover optimistic updates for:
- Title.
- Description.
- Price.
- Category.
- Stock.
- Images.
- Variants.
For every update family:
- Keep the request unresolved.
- Assert the new value appears immediately.
- Resolve and store the confirmed response.
- Repeat with a failure.
- Assert rollback uses the last confirmed response.
- Assert the error toast and SDK arguments.
Commit: feat: storybook product updates
Cover:
- Delete confirmation.
- Cancel.
- Pending deletion.
- Optimistic removal where the production UI uses it.
- Successful deletion.
- Failed deletion recovery.
- Unauthorized controls hidden or disabled.
- Duplicate deletion prevention.
RLS and backend authorization remain Cypress/API responsibilities; Storybook verifies the component behavior and submitted identifiers.
Commit: feat: storybook product deletion
Add a Storybook CI job that runs:
- Static Storybook build.
- Story render tests.
- Play-function interaction tests.
- Accessibility tests.
Configure stable stories with accessibility failures treated as CI errors. Fix valid violations instead of globally disabling rules.
Upload Storybook output and failure evidence when the job fails. Add the job to CI required.
Let CodeRabbit read the completed GitHub Checks and comment on relevant CI failures. CodeRabbit GitHub Checks
Commit: chore: storybook ci
- Use the supplied token only through an environment variable.
- Store the active token as
CHROMATIC_PROJECT_TOKENin GitHub Actions. - Never put it in tracked code, scripts, docs, or workflow YAML.
- Publish from branch pushes with full Git history.
- Do not enable TurboSnap initially.
- Require Chromatic UI Test and UI Review checks.
- Block merging until visual changes are approved.
- Keep asynchronous visual approval separate from
CI required. - Auto-accept an already-reviewed baseline after squash merge into
development. - Update the branch-rules documentation with the final check names.
- Rotate the token pasted into chat and replace the GitHub secret.
Commit: chore: chromatic publishing
Add dev_readme-storybook.md and link it from CLAUDE.md.
Document:
- Commands.
- Story organization.
- Fixture and Zustand reset rules.
- Network and module mocking.
- How to write a meaningful story.
- Interaction-test requirements.
- Accessibility policy.
- Theme, locale, and viewport support.
- Chromatic review process.
- CodeRabbit workflow.
- One-subtask/one-commit and amend rules.
- Storybook versus Cypress/API responsibilities.
- Secret handling.
Run final verification:
pnpm test:commit-namingpnpm test:eslint-rulespnpm lintpnpm exec next typegenpnpm type-checkpnpm build-storybookpnpm test:storybook- Existing Cypress smoke suite
- CodeRabbit full review and pre-merge checks
- Chromatic visual approval
- Clean working tree
Change plan 13 from in progress to done only when every required check passes and all CodeRabbit discussions are resolved.
Commit: docs: storybook
- The complete plan exists at
/STORYBOOK-PLAN.md. - Exactly one commit exists for every listed subtask.
- Review corrections are amended into the relevant subtask commit.
- All commits and the PR title follow
commit-patterns.md. - Every changed line follows
dev_readme-code-patterns.md. - CodeRabbit uses the repository documents as review criteria.
- Storybook contains meaningful states and interactions, not generated examples.
- Stories do not contact live application services.
- Product create, update, and delete stories verify success and failure behavior.
- Optimistic tests prove both immediate UI updates and rollback.
- Accessibility and Storybook tests pass in CI.
- Chromatic blocks unapproved visual changes.
- CodeRabbit blocks unresolved review findings.
- Existing Cypress, authorization, lint, type, and branch-protection checks continue to pass.