Skip to content

test(core): move the unit tests into the stories' play functions - #571

Merged
ggdaltoso merged 45 commits into
masterfrom
chore/tests-in-stories
Oct 8, 2026
Merged

ggdaltoso merged 45 commits into
masterfrom
chore/tests-in-stories

Conversation

@ggdaltoso

@ggdaltoso ggdaltoso commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Moves @react95/core's unit tests into the stories, as play functions. Each component's behavior is now tested in a real browser, shows up step by step in the Interactions panel, and runs in CI with test-storybook. Writing those tests turned up several bugs, fixed here too.

Tests in the stories

  • Every component story tests what the component does, read from its args: Tooltip shows its text only after delay, Tabs swaps the content, the TaskBar keeps its buttons in the order the windows opened, and so on. Snapshots are gone; each one became explicit checks.
  • Every rule was checked by breaking it in the component on purpose and seeing a story fail.
  • .storybook/pointer.ts gives play functions a real hover in Vitest (List's submenus open on CSS :hover, which a simulated hover doesn't trigger). .storybook/theme-color.ts resolves theme tokens, so the active/inactive TitleBar and Modal checks work with any theme.
  • The Hooks/useModal stories get their Interactions panel back, with tests for registration, minimize/restore, toggle, focus and the events.
  • The only unit test left is the event emitter's (components/shared/events.test.ts), which now runs in Node. The core test setup it no longer needs (happy-dom, mocks, snapshot resolver) is removed.

Fixes

  • RadioButton: a className no longer replaces the input's own class (the native radio showed up on top of the Win95 one).
  • Alert: the icon is named after the alert type, so screen readers announce it. A sound the browser blocks no longer throws.
  • Modal: the active modal has aria-current. It registers with the TaskBar once, so a re-render of its parent no longer steals the focus or moves its TaskBar button.
  • TaskBar: the clock updates every second (it ran every ~4 ms) and shows the time right away. Closing the active window focuses the next one outside of a state update, which React warned about. A modal's new title updates its button in place.
  • Video: blocked playback no longer throws, and the play/pause button follows the video instead of flipping on click.

Refactors and cleanup

  • modalController is removed: it wasn't exported or used.
  • The TaskBar's window logic moved to an internal useModalWindows hook, which also subscribes to the events once.
  • Stories load from a glob (new files show up without restarting Storybook), and metas use satisfies where TypeScript can handle it. packages/core/tsconfig.json no longer asks for declarations, which it never emits and which made newer TypeScript versions warn about satisfies.
  • Cursor has a docs page on how to use it, and clicking a cursor copies its className.

Screenshots

Interactions panel

image

Tests

$yarn test:storybook               
> nx run @react95/core:test-storybook

> yarn test-storybook

$ vitest run --config=vitest.config.mjs
(node:2585839) [DEP0205] DeprecationWarning: `module.register()` is deprecated. Use `module.registerHooks()` instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

assetFileNames isn't equal for every build.rollupOptions.output. A single pattern across all outputs is supported by Vite.


 RUN  v3.2.7 /home/ggdaltoso/projects/React95/packages/core


assetFileNames isn't equal for every build.rollupOptions.output. A single pattern across all outputs is supported by Vite.

 ✓  storybook (chromium)  stories/button.stories.tsx (1 test) 1252ms
   ✓ Simple  1251ms
 ✓  storybook (chromium)  stories/frame.stories.tsx (7 tests) 1622ms
   ✓ Simple  1424ms
 ✓  storybook (chromium)  stories/dropdown.stories.tsx (1 test) 188ms
 ✓  storybook (chromium)  stories/input.stories.tsx (1 test) 662ms
   ✓ Simple  661ms
 ✓  storybook (chromium)  stories/textarea.stories.tsx (1 test) 667ms
   ✓ Simple  666ms
stdout | stories/modal.stories.tsx > Simple
Ok
stdout | stories/modal.stories.tsx > Simple
Cancel
 ✓  storybook (chromium)  stories/range.stories.tsx (1 test) 643ms
   ✓ Simple  641ms
 ↓  storybook (chromium)  stories/contract.stories.tsx (0 test)
stdout | stories/modal.stories.tsx > Simple
Help
 ✓  storybook (chromium)  stories/progressbar.stories.tsx (1 test) 612ms
   ✓ Simple  610ms
stderr | stories/video.stories.tsx > From File
[React95] Video: the browser blocked playback. Browsers only play videos with sound after the user has interacted with the page.
 ✓  storybook (chromium)  stories/titlebar.stories.tsx (3 tests) 740ms
   ✓ Simple  640ms
 ✓  storybook (chromium)  stories/list.stories.tsx (2 tests) 877ms
   ✓ With Icons  829ms
 ✓  storybook (chromium)  stories/tree.stories.tsx (1 test) 575ms
   ✓ Simple  573ms
stderr | stories/alert.stories.tsx > With Sound
[React95] Alert: the browser blocked the alert's sound. Browsers only play sound after the user has interacted with the page.
 ✓  storybook (chromium)  stories/alert.stories.tsx (5 tests) 745ms
   ✓ Simple  479ms
stdout | stories/modal.stories.tsx > Minimize
I'm in control
 ✓  storybook (chromium)  stories/video.stories.tsx (3 tests) 1372ms
   ✓ From URL  651ms
   ✓ Playback  639ms
 ✓  storybook (chromium)  stories/modal.stories.tsx (3 tests) 964ms
   ✓ Simple  609ms
 ✓  storybook (chromium)  stories/useModal.stories.tsx (4 tests) 1060ms
   ✓ Basic Usage  513ms
 ✓  storybook (chromium)  stories/tooltip.stories.tsx (1 test) 2825ms
   ✓ Simple  2823ms
 ✓  storybook (chromium)  stories/taskbar.stories.tsx (2 tests) 2498ms
   ✓ Simple  1460ms
   ✓ Clock  1036ms
 ↓  storybook (chromium)  stories/icons.stories.tsx (0 test)
 ↓  storybook (chromium)  stories/all.stories.tsx (0 test)
 ↓  storybook (chromium)  stories/globalstyle.stories.tsx (0 test)
 ✓  storybook (chromium)  stories/fieldset.stories.tsx (1 test) 209ms
 ✓  storybook (chromium)  stories/tabs.stories.tsx (1 test) 239ms
 ✓  storybook (chromium)  stories/cursor.stories.tsx (1 test) 255ms
 ✓  storybook (chromium)  stories/avatar.stories.tsx (3 tests) 275ms
 ✓  storybook (chromium)  stories/radiobutton.stories.tsx (2 tests) 283ms
 ✓  storybook (chromium)  stories/checkbox.stories.tsx (5 tests) 333ms

 Test Files  22 passed | 4 skipped (26)
      Tests  50 passed (50)
   Start at  15:13:47
   Duration  16.72s (transform 0ms, setup 75.93s, collect 198.90s, tests 18.89s, environment 0ms, prepare 59.94s)

———————————————————————————

 NX   Successfully ran target test-storybook for project @react95/core (19s)

Merging this publishes @react95/core 9.8.5 (patch), and the CRA templates 0.2.5 along with it, as on every core release (confirmed with nx release --dry-run).

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@nx-cloud

nx-cloud Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 4486f78

Command Status Duration Result
nx affected -t lint,test,build,test-storybook,b... ✅ Succeeded 1m 12s View ↗
nx-cloud record -- yarn nx format:check ✅ Succeeded 2s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-10-06 18:10:05 UTC

@ggdaltoso
ggdaltoso marked this pull request as ready for review October 6, 2026 18:17
@ggdaltoso
ggdaltoso merged commit 5102f5e into master Oct 8, 2026
9 checks passed
@ggdaltoso
ggdaltoso deleted the chore/tests-in-stories branch October 8, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant