Skip to content

feat: docs composites cycle 1 — testing + ThemeProvider, Breadcrumbs, PageFooterNav#1

Merged
Sam Gammon (sgammon) merged 9 commits into
mainfrom
feat/docs-composites
Jul 6, 2026
Merged

feat: docs composites cycle 1 — testing + ThemeProvider, Breadcrumbs, PageFooterNav#1
Sam Gammon (sgammon) merged 9 commits into
mainfrom
feat/docs-composites

Conversation

@sgammon

Copy link
Copy Markdown
Member

Summary

Stands up component testing and ships the first docs-shell composites. Cycle 1 of the Tier-2 composites (Sidebar / AppNav / SectionTabs / TableOfContents follow in later PRs).

Testing (new)

  • Storybook 10 + Vitest addon — every story runs as a test in real Chromium (Vitest 4 browser mode via Playwright); interaction assertions live in each story's play function. Complements Chromatic (visual) without duplicating it.
  • apps/storybook/vitest.config.ts, @storybook/addon-vitest registered, a test task (Turbo + root).
  • New reusable check.test.yml (installs Chromium, runs the suite) wired into on.pr.yml / on.push.yml.
  • 25 story tests pass across 17 files.

Composites (themed from @elide/tokens, each with a play test + visual diff vs the mockup)

  • ThemeProvider / useTheme — sets .dark + data-theme on <html> (so Base UI portals inherit it), persists to localStorage, initializes from stored value or prefers-color-scheme.
  • Breadcrumbssegments[], chevron separators, final segment aria-current="page".
  • PageFooterNav — prev/next cards; either side optional, lone next stays right-aligned.

Verification

  • bun run build, bun run lint, bun run test all green from a cold cache; actionlint clean.
  • Breadcrumbs and PageFooterNav visually match their mockup regions.

Notes

  • The chromatic CI job needs the CHROMATIC_PROJECT_TOKEN secret (unrelated to these Vitest tests, which need no secret).
  • Follow-ups: Sidebar, AppNav, SectionTabs, TableOfContents.

🤖 Generated with Claude Code

Sam Gammon (sgammon) and others added 7 commits July 6, 2026 10:08
…r/Breadcrumbs/PageFooterNav)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Stories run as tests in real Chromium via @storybook/addon-vitest (Vitest 4 browser mode, Playwright). Adds vitest.config.ts, a test task (turbo + root), and a reusable check.test.yml wired into on.pr.yml/on.push.yml. 21 story tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Context that sets .dark + data-theme on <html> (so Base UI portals inherit it), persists to localStorage, and initializes from stored value or prefers-color-scheme. useTheme() → { theme, setTheme, toggle }. Story with a play test asserting the toggle flips the documentElement class. Adds storybook + @storybook/addon-vitest to @elide/ui devDeps so colocated stories' runtime test imports resolve.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Docs breadcrumb trail: nav > ol, chevron separators, links for segments with href, final segment aria-current=page. Story + play test asserting aria-current and link href.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Prev/next docs pagination cards; either side optional, lone next stays right-aligned. Stories (Both, NextOnly) with play tests asserting hrefs and the absent-prev case.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… testing

Registers the addon (serves the MCP endpoint at :6006/mcp when Storybook dev runs) and adds the storybook HTTP MCP server to .mcp.json. Enables run-story-tests to fetch/diagnose failing stories.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ThemeProvider Toggle play test was coupled to the Storybook theme decorator's initial <html> class, which diverged from the provider's own state — failing nondeterministically in Chromatic (light+dark modes). Rewrites it to assert against the provider's reported theme with waitFor. Also fixes a11y violations surfaced via the Storybook MCP run-story-tests: CopyButton empty aria-label (fallback to 'Copy' + regression play test), Popover dialog accessible name, and Switch accessible name.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces Storybook-driven interaction testing (Vitest browser mode via Playwright) and ships the first “docs-shell composite” UI components for the docs experience: ThemeProvider/useTheme, Breadcrumbs, and PageFooterNav.

Changes:

  • Added a test Turbo pipeline + root test script and a reusable GitHub Actions workflow to run story play functions as browser tests.
  • Implemented and exported ThemeProvider/useTheme, Breadcrumbs, and PageFooterNav, each with Storybook stories that include interaction assertions.
  • Tightened accessibility guardrails in stories/components (e.g., aria-label defaults and story args).

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
turbo.json Adds a test Turbo task to run the new story-based test suite.
package.json Adds root test script (turbo run test).
apps/storybook/package.json Adds Vitest/Playwright deps and vitest run test script for story execution.
apps/storybook/vitest.config.ts Configures Vitest browser mode + Storybook Vitest plugin to run stories as tests.
apps/storybook/.storybook/main.ts Registers @storybook/addon-vitest (and MCP addon) in Storybook config.
.github/workflows/check.test.yml New reusable workflow to install Chromium + run bun run test.
.github/workflows/on.pr.yml Wires the reusable test workflow into PR CI.
.github/workflows/on.push.yml Wires the reusable test workflow into push CI.
packages/ui/src/components/theme-provider.tsx Introduces theme context/provider that reflects theme onto <html> and persists it.
packages/ui/src/stories/Theme.stories.tsx Adds ThemeProvider story with play interaction test verifying toggle behavior.
packages/ui/src/components/breadcrumbs.tsx Adds Breadcrumbs composite with aria-current="page" on final segment.
packages/ui/src/stories/Breadcrumbs.stories.tsx Adds Breadcrumbs story + play assertions (links + current segment).
packages/ui/src/components/page-footer-nav.tsx Adds PageFooterNav composite for prev/next navigation cards.
packages/ui/src/stories/PageFooterNav.stories.tsx Adds PageFooterNav stories + play assertions for both/next-only cases.
packages/ui/src/components/code-block.tsx Ensures CopyButton has a non-empty accessible name fallback.
packages/ui/src/stories/CodeBlock.stories.tsx Adds a regression play test for CopyButton accessible name.
packages/ui/src/stories/Switch.stories.tsx Sets a default aria-label arg for Switch stories.
packages/ui/src/stories/Popover.stories.tsx Adds aria-label to PopoverContent in the story for accessibility.
packages/ui/src/index.ts Exports the new composites (ThemeProvider, Breadcrumbs, PageFooterNav).
packages/ui/package.json Adds Storybook-related devDependencies for the UI package.
COMPONENTS.md Marks ThemeProvider/Breadcrumbs/PageFooterNav as done.
docs/superpowers/specs/2026-07-06-docs-composites-design.md Adds the design spec documenting goals, APIs, and DoD for cycle 1.
docs/superpowers/plans/2026-07-06-docs-composites.md Adds an implementation plan detailing the test infra + component work.
.mcp.json Adds a local Storybook MCP endpoint configuration.
bun.lock Locks new Storybook/Vitest/Playwright dependency additions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/ui/src/components/theme-provider.tsx Outdated
Comment thread packages/ui/package.json
Sam Gammon (sgammon) and others added 2 commits July 6, 2026 10:50
The previous fix addressed the assertion but not the root cause: ThemeProvider resolved its theme in a mount useEffect, which in Chromatic's timing ran AFTER the play function's click and reverted the toggle (button stayed 'Theme: dark'). Move resolution into a lazy useState initializer (SSR-guarded) and drop the init effect, so the theme is set synchronously and nothing re-initializes over an early interaction. Test now asserts the exact toggled value.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…sed devDep

1) resolveInitialTheme now honors the OS preference in both directions (light stays light), falling back to defaultTheme only when matchMedia is unavailable — the previous code left an OS-light user on the dark default, contradicting the docstring.

2) Remove @storybook/addon-vitest from @elide/ui devDependencies. The suite still passes: the storybookTest plugin's injected @storybook/addon-vitest/internal/test-utils import resolves from apps/storybook (the Vitest root), not packages/ui. (storybook stays — the source `storybook/test` import resolves from packages/ui.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sgammon Sam Gammon (sgammon) merged commit 6ed75ee into main Jul 6, 2026
5 checks passed
@sgammon Sam Gammon (sgammon) deleted the feat/docs-composites branch July 6, 2026 18:19
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