Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Add unified UI Testing Module #29241

Merged
merged 240 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
240 commits
Select commit Hold shift + click to select a range
40ca30b
Add experimental_TEST_PROVIDER addon type
ghengeveld Sep 12, 2024
b423331
Test for experimental_TEST_PROVIDER addon type
ghengeveld Sep 13, 2024
cea8021
Register Test addon as TEST_PROVIDER addon type
ghengeveld Sep 13, 2024
cb619ae
Addon-Test: Implement Addon Test TestProvider Backend
valentinpalkovic Sep 20, 2024
123c6d2
Lazy boot for Vitest runner
ghengeveld Sep 23, 2024
72bd862
Replace Node's process.fork with Execa and refactor/cleanup a bunch o…
ghengeveld Sep 24, 2024
840fa04
make test run succeed
yannbf Sep 24, 2024
76c1c4e
Add unit tests and fix timeout logic
ghengeveld Sep 24, 2024
b71e2f2
Merge branch 'unified-ui-testing' into valentin/implement-addon-test-…
yannbf Sep 24, 2024
998b8e1
fix remaining tests
yannbf Sep 24, 2024
1d45366
Fix unit test on Windows and avoid default export
ghengeveld Sep 25, 2024
b307cd9
add test module crash report event
yannbf Sep 25, 2024
1966455
fix exports
yannbf Sep 25, 2024
04d892b
Fix timeout after ready and debouple test manager from process context
ghengeveld Sep 25, 2024
8573831
Fix progress reporting
ghengeveld Sep 25, 2024
0d00235
Add missing deps
ghengeveld Sep 25, 2024
54dc6e3
Linting
ghengeveld Sep 25, 2024
b332fac
bring back vitest patch
yannbf Sep 25, 2024
b0a68af
fix user event interactions on firefox
yannbf Sep 25, 2024
0123f8f
fix vitest patch again
yannbf Sep 25, 2024
23329d9
exclude story files from coverage
yannbf Sep 25, 2024
5b11aa2
Add tests for TestManager and VitestManager
ghengeveld Sep 25, 2024
b7c33b5
Comment out log messages for now
ghengeveld Sep 25, 2024
f8095ba
Increase wait time
ghengeveld Sep 25, 2024
3544db5
Merge pull request #29171 from storybookjs/valentin/implement-addon-t…
ghengeveld Sep 26, 2024
a5a036a
Merge branch 'next' into unified-ui-testing
yannbf Sep 26, 2024
d755734
Register addon test on sandboxes and introduce E2E tests
yannbf Sep 26, 2024
81c3dcd
add timeout
yannbf Sep 26, 2024
23b5ca3
add workaround for vitest version
yannbf Sep 26, 2024
71093f6
skip e2e on non-chromium browsers
yannbf Sep 26, 2024
db40f3c
fixes
yannbf Sep 26, 2024
959f975
change testing strategies
yannbf Sep 27, 2024
90cc559
Merge branch 'next' into unified-ui-testing
yannbf Sep 27, 2024
a43f27e
Testing Module UI
ghengeveld Sep 27, 2024
ade4ffc
fix
yannbf Sep 27, 2024
ff5ee95
Addon Test: Add interactions functionality
yannbf Sep 27, 2024
42d0ef4
apply addon-test to all sandboxes
yannbf Sep 30, 2024
190f6eb
Merge branch 'next' into unified-ui-testing
yannbf Sep 30, 2024
39f6569
fix test run
yannbf Sep 30, 2024
8703d63
Merge branch 'unified-ui-testing' into yann/introduce-test-panel
yannbf Sep 30, 2024
64cce47
Merge branch 'unified-ui-testing' into yann/addon-test-e2e
yannbf Sep 30, 2024
8af1122
Add Knip with initial custom config
webpro Sep 12, 2024
b05237c
Move script/config
webpro Sep 12, 2024
9e28a8b
Add knip job to circle ci
webpro Sep 22, 2024
0ae48df
Fix TS issues (use matcher pkg that we have types for)
webpro Sep 22, 2024
26f9219
remove handlebars
ndelangen Sep 25, 2024
8058192
fixes
ndelangen Sep 26, 2024
4381f77
Discard changes to .vscode/settings.json
ndelangen Sep 26, 2024
13fd6aa
ignore eslint warning of template file
ndelangen Sep 26, 2024
9aaf4a7
fix
ndelangen Sep 27, 2024
1e64fb3
make prettier a core optional peer dependency
JReinhold Sep 26, 2024
0cc7bb8
keep prettier/standalone
JReinhold Sep 26, 2024
c75dc6a
propagate prettier peer dependency to storybook package
JReinhold Sep 27, 2024
41093ec
update lock-file
JReinhold Sep 27, 2024
c2b75ba
Update CHANGELOG.md for v8.3.4 [skip ci]
storybook-bot Sep 28, 2024
5c82c12
Write changelog for 8.4.0-alpha.2 [skip ci]
storybook-bot Sep 28, 2024
491f595
Bump version from "8.4.0-alpha.1" to "8.4.0-alpha.2" [skip ci]
storybook-bot Sep 28, 2024
fc01f69
fix test run
yannbf Sep 30, 2024
11042e8
Testing Module functionality and stories
ghengeveld Sep 30, 2024
9ca737d
fix issues in webpack projects
yannbf Sep 30, 2024
511892a
update test snapshots
yannbf Sep 30, 2024
628e730
Upgrade es-toolkit to fix throttle
ghengeveld Sep 30, 2024
dc75e9a
Proper floating Testing Module style and behavior
ghengeveld Sep 30, 2024
641799c
Proper floating Testing Module style and behavior
ghengeveld Sep 30, 2024
3bae439
add strict: false to addon test tsconfig (hopefully temporarily)
yannbf Sep 30, 2024
504026e
skip ts issues
yannbf Sep 30, 2024
12a7fdb
experiment with v8 coverage
yannbf Sep 30, 2024
31608b4
Also show collapse toggle on focus
ghengeveld Sep 30, 2024
fba1359
bring back istanbul coverage
yannbf Sep 30, 2024
8dd3585
Handle stopPropagation internally
ghengeveld Sep 30, 2024
13fa858
Show notifications in sidebar
ghengeveld Sep 30, 2024
c133e5a
Dark mode fixes
ghengeveld Sep 30, 2024
b19c824
Tweaks
ghengeveld Sep 30, 2024
ef23e3b
Merge branch 'unified-ui-testing' into testing-module-ui
ghengeveld Sep 30, 2024
c3bb1b2
Use actual registered test providers
ghengeveld Sep 30, 2024
21d01be
Handle empty list of test providers and fix story data
ghengeveld Sep 30, 2024
1815e21
Fix mocks
ghengeveld Oct 1, 2024
001abc4
update lockfile
yannbf Oct 1, 2024
e6d2872
Disable console.log
ghengeveld Oct 1, 2024
d64d8ce
Description is non-nullable
ghengeveld Oct 1, 2024
6986da3
Fix runAllTests action
ghengeveld Oct 1, 2024
ea4f8ef
Fix filter button colors
ghengeveld Oct 1, 2024
d9099d2
Hide Testing Module on mobile
ghengeveld Oct 1, 2024
0a96f01
Fix notification shadow on mobile
ghengeveld Oct 1, 2024
5702fb0
Extract to constant
ghengeveld Oct 1, 2024
3c49ac3
Update addon test preset to use experimental addon
yannbf Oct 1, 2024
43a5c82
Merge pull request #29232 from storybookjs/yann/introduce-test-panel
yannbf Oct 1, 2024
dd965b8
Avoid shadow on top of scrollbar
ghengeveld Oct 1, 2024
543e0bb
Fix active state for filter toggles
ghengeveld Oct 1, 2024
0a6fc46
Avoid excessive shadow on stacked notifications
ghengeveld Oct 1, 2024
0c11df3
Merge branch 'unified-ui-testing' into testing-module-ui
ghengeveld Oct 1, 2024
d24cab3
Merge pull request #29236 from storybookjs/testing-module-ui
ghengeveld Oct 1, 2024
a10e7ee
Merge branch 'unified-ui-testing' into yann/addon-test-e2e
yannbf Oct 1, 2024
6ff1a8b
Fix vitest execution
yannbf Oct 1, 2024
48dc887
Merge branch 'unified-ui-testing' into yann/addon-test-e2e
yannbf Oct 1, 2024
c11a589
Refactor component testing spec and configuration files
yannbf Oct 1, 2024
8b909b8
update and add more tests
yannbf Oct 2, 2024
b55897b
Refactor artifact storage paths in CircleCI configuration
yannbf Oct 2, 2024
4640ed8
experiment to debug CI issue
yannbf Oct 2, 2024
ae4c8ff
update tests
yannbf Oct 2, 2024
03da278
debug coverage issue
yannbf Oct 2, 2024
e632a51
fix unit test
yannbf Oct 2, 2024
9e0d43b
extend timeout
yannbf Oct 2, 2024
1fc074e
fix
yannbf Oct 2, 2024
7d53c27
debug specific workflows
yannbf Oct 2, 2024
9570872
fix
yannbf Oct 2, 2024
59b0cb9
Merge pull request #29219 from storybookjs/yann/addon-test-e2e
yannbf Oct 2, 2024
8c6e3f8
Merge branch 'next' into unified-ui-testing
yannbf Oct 4, 2024
0618742
Add basic implementation of discrepancy detection
yannbf Oct 4, 2024
d7bd573
fix file cache in direct story testing
yannbf Oct 7, 2024
9861641
add UI component
yannbf Oct 8, 2024
576fe0e
Update code/addons/test/src/node/vitest-manager.ts
yannbf Oct 8, 2024
c5e20e2
add test discrepancy component, add tests
yannbf Oct 9, 2024
44b3b31
fix cache for run all scenario
yannbf Oct 9, 2024
219a93c
fix stories
yannbf Oct 9, 2024
c9a32e4
speed up test storybook
yannbf Oct 9, 2024
72e453d
fix ts issues
yannbf Oct 9, 2024
46047ba
cleanup
yannbf Oct 9, 2024
c4d3ed0
Progress reporting for Testing Module
ghengeveld Oct 9, 2024
8c03675
improvements based on review
yannbf Oct 9, 2024
a67057e
Merge pull request #29294 from storybookjs/yann/addon-test-discrepanc…
yannbf Oct 9, 2024
b24b3a2
Merge pull request #29290 from storybookjs/yann/fix-test-cache
yannbf Oct 9, 2024
9fc034c
Modal: Change styling
valentinpalkovic Oct 9, 2024
c8cdccd
Addon-Test: Implement GlobalErrorModal
valentinpalkovic Oct 9, 2024
6670087
Fix documentation link and provide dynamic troubleshooting link
valentinpalkovic Oct 9, 2024
6c3e57a
Remove border radius on ModalStackTrace
valentinpalkovic Oct 10, 2024
e6063d8
Remove unnecessary story config entry in Storybook's main.js
valentinpalkovic Oct 10, 2024
06836a0
Fix tests
valentinpalkovic Oct 10, 2024
1354966
Merge pull request #29309 from storybookjs/valentin/add-global-error-…
valentinpalkovic Oct 10, 2024
d8f4a43
Merge remote-tracking branch 'origin/next' into unified-ui-testing
valentinpalkovic Oct 10, 2024
e224aa9
Merge branch 'unified-ui-testing' into ui-testing-progress
valentinpalkovic Oct 10, 2024
03f205c
Refactor test runner error handling and logging
valentinpalkovic Oct 10, 2024
4dc91e6
Merge pull request #29311 from storybookjs/ui-testing-progress
valentinpalkovic Oct 10, 2024
037f7ce
Integrate GlobalErrorModal into testing UI module
yannbf Oct 10, 2024
2356f45
Refactor test runner error handling and logging
yannbf Oct 10, 2024
11a0891
fix test
yannbf Oct 10, 2024
2eb23c8
remove test
yannbf Oct 10, 2024
8c9be57
Merge pull request #29318 from storybookjs/valentin/integrate-global-…
yannbf Oct 10, 2024
1ad5dc0
fix stories
yannbf Oct 10, 2024
26bfe92
fix e2e
yannbf Oct 10, 2024
49df30f
Ensure #sidebar-bottom-wrapper is a correctly sized and positioned el…
ghengeveld Oct 11, 2024
6b6537b
remove coverage in unit tests
yannbf Oct 11, 2024
cf7ba11
add telemetry on discrepancy results
yannbf Oct 11, 2024
8db0daa
add testRunId to telemetry
yannbf Oct 11, 2024
16077e6
Addon-Test: Refactor bootTestRunner to handle fatal errors and improv…
valentinpalkovic Oct 11, 2024
27aa84b
Support globals and viewports global config in portable stories
yannbf Oct 14, 2024
2ca29f8
Merge pull request #29319 from storybookjs/yann/support-viewport-glob…
yannbf Oct 14, 2024
1c671de
Merge pull request #29329 from storybookjs/yann/discrepancy-detection…
yannbf Oct 14, 2024
0e572bc
Throw error upon detecting addon interactions alongside addon test
yannbf Oct 11, 2024
64644ef
Fix tests
valentinpalkovic Oct 14, 2024
1a44d1a
Merge remote-tracking branch 'origin/unified-ui-testing' into valenti…
valentinpalkovic Oct 14, 2024
20d5f9d
Merge pull request #29336 from storybookjs/valentin/fix-error-reporti…
valentinpalkovic Oct 14, 2024
d29f0c6
Refactor component test status message handling
valentinpalkovic Oct 14, 2024
d0ebd38
Merge branch 'unified-ui-testing' into vta-compat
ghengeveld Oct 14, 2024
d83bd0a
Drop React state in favor of direct height manipulation to avoid rere…
ghengeveld Oct 14, 2024
14f978d
Update documentation links
valentinpalkovic Oct 14, 2024
2ee831c
Merge pull request #29330 from storybookjs/vta-compat
ghengeveld Oct 14, 2024
374a112
Detect Nextjs webpack when using addon test and propose next vite
yannbf Oct 15, 2024
d184988
refactor log, rephrase message
yannbf Oct 15, 2024
19d024f
Add prompt to remove addon interactions as part of addon test postins…
yannbf Oct 14, 2024
60d07a6
add --yes option to sb add
yannbf Oct 15, 2024
53c91b3
make vitest dependencies optional
yannbf Oct 15, 2024
886a28e
Refactor JsPackageManager to include a new abstract method getRemoteR…
yannbf Oct 15, 2024
e9cc430
Add config dir to sb remove command
yannbf Oct 15, 2024
99a36a5
remove interactions addon internally before testing addon test
yannbf Oct 15, 2024
f8cd069
fix lockfile
yannbf Oct 15, 2024
2ebaa34
Fix tests
yannbf Oct 15, 2024
5719970
Testing Module: Add telemetry to testingmodule events
valentinpalkovic Oct 15, 2024
38b017a
improve prompt message
yannbf Oct 15, 2024
e269caf
Merge pull request #29353 from storybookjs/yann/addon-interactions-re…
yannbf Oct 15, 2024
c563e31
Refactor log message in test addon preset
yannbf Oct 15, 2024
cebf305
Merge pull request #29355 from storybookjs/yann/promote-nextjs-vite
yannbf Oct 15, 2024
786ddd7
Rename tab
ghengeveld Oct 15, 2024
9570499
Merge pull request #29359 from storybookjs/valentin/unified-testing-t…
valentinpalkovic Oct 16, 2024
024cd2a
fix tests
yannbf Oct 16, 2024
6282669
Upgrade vitest
valentinpalkovic Oct 16, 2024
e22e544
Remove Play buttons in the sidebar
ghengeveld Oct 16, 2024
d8a24fa
Don't show a checkmark on stories with success status
ghengeveld Oct 16, 2024
c875a27
Show number of tests when showing last run time, and prioritize this …
ghengeveld Oct 16, 2024
c56107f
Wait for current run to finish before restarting Vitest when toggling…
ghengeveld Oct 16, 2024
5045d57
Addon-Test: Fix watch mode
valentinpalkovic Oct 16, 2024
81c9b87
Merge remote-tracking branch 'origin/unified-ui-testing' into valenti…
valentinpalkovic Oct 16, 2024
71a4b08
Improve aria labels using test provider name property
ghengeveld Oct 16, 2024
371c7f6
fix e2e tests
yannbf Oct 16, 2024
5e28792
Merge branch 'unified-ui-testing' into valentin/fix-watch-mode-in-tes…
valentinpalkovic Oct 17, 2024
f5c3959
Merge pull request #29373 from storybookjs/valentin/fix-watch-mode-in…
valentinpalkovic Oct 17, 2024
448cc6a
Merge remote-tracking branch 'origin/next' into unified-ui-testing
valentinpalkovic Oct 17, 2024
e9523db
Only start tests for test providers that are ready to run
ghengeveld Oct 17, 2024
2ecb957
Merge pull request #29375 from storybookjs/test-provider-name
valentinpalkovic Oct 17, 2024
0c9a253
Refactor vite-plugin-storybook-test configuration handling
valentinpalkovic Oct 17, 2024
1e1fe9e
Merge pull request #29389 from storybookjs/valentin/fix-vue-warning
valentinpalkovic Oct 21, 2024
b68f953
Addon-Test: Report component file tests to the frontend
valentinpalkovic Oct 17, 2024
79ec6c6
Merge branch 'unified-ui-testing' into yann/addon-interactions-conflict
valentinpalkovic Oct 21, 2024
3039a87
Merge remote-tracking branch 'origin/next' into unified-ui-testing
valentinpalkovic Oct 21, 2024
becbd84
Merge branch 'unified-ui-testing' into valentin/report-component-test…
valentinpalkovic Oct 21, 2024
b6f9267
Merge remote-tracking branch 'origin/next' into unified-ui-testing
valentinpalkovic Oct 21, 2024
bf0f7fa
Fix e2e tests
valentinpalkovic Oct 21, 2024
85ab53c
Update playwright
valentinpalkovic Oct 21, 2024
8549ddb
Merge pull request #29388 from storybookjs/valentin/report-component-…
valentinpalkovic Oct 21, 2024
4da1ec1
Fix type issues
valentinpalkovic Oct 21, 2024
71d32f5
Hardcode outline colors to prevent theme overrides from affecting them
ghengeveld Oct 18, 2024
f728e29
Docs: Replace Vitest plugin with Test addon
kylegach Oct 9, 2024
7960bdd
Update required Vitest version
kylegach Oct 10, 2024
4fc0b7c
Add Vitest attribution in experimental callout
kylegach Oct 15, 2024
524cec4
Correct status indicator guidance
kylegach Oct 15, 2024
1220592
Clarify Next.js requirements
kylegach Oct 16, 2024
20879cb
Add assets
kylegach Oct 18, 2024
e40db8b
Add Vitest error screenshot
kylegach Oct 21, 2024
bcecdb9
Address feedback
kylegach Oct 22, 2024
15c9433
Improve videos
kylegach Oct 23, 2024
f3b479a
Merge pull request #29315 from storybookjs/addon-test-docs
kylegach Oct 23, 2024
75cc1b1
Make sure Next 14 is used for sandboxes
kasperpeulen Oct 23, 2024
a035e39
Generate sandboxes
kasperpeulen Oct 23, 2024
9bcab72
Fix
kasperpeulen Oct 23, 2024
28db96d
upgrade svelte dependencies to v5
JReinhold Oct 23, 2024
86f2d25
Merge branch 'unified-ui-testing' into yann/addon-interactions-conflict
valentinpalkovic Oct 23, 2024
88fb437
Cleanup
valentinpalkovic Oct 23, 2024
3b442d9
dont upgrade vite to v5 anyway
JReinhold Oct 23, 2024
b468f9a
dont force v3 of vite-plugin-svelte
JReinhold Oct 23, 2024
bc1ac58
Merge branch 'jeppe/svelte-5-peer-deps' of github.com:storybookjs/sto…
JReinhold Oct 23, 2024
8a7e063
Remove addon interaction from internal Storybook
valentinpalkovic Oct 23, 2024
0959d02
Merge pull request #29338 from storybookjs/yann/addon-interactions-co…
valentinpalkovic Oct 23, 2024
d9972f7
Disable angular stories as Angular RC fails
kasperpeulen Oct 23, 2024
7460021
Merge remote-tracking branch 'origin/next' into unified-ui-testing
valentinpalkovic Oct 23, 2024
f30996d
Merge remote-tracking branch 'origin/kasper/fix-sandboxes-next' into …
valentinpalkovic Oct 23, 2024
3cfcd71
Hooks don't work in vitest yet
kasperpeulen Oct 23, 2024
4df7be6
Merge remote-tracking branch 'origin/kasper/fix-sandboxes-next' into …
valentinpalkovic Oct 23, 2024
12dd5b2
Fix linting
valentinpalkovic Oct 23, 2024
ce8dd08
Revert "Addon Test: Error when addon interactions exists"
valentinpalkovic Oct 23, 2024
011c6fc
Merge pull request #29433 from storybookjs/revert-29338-yann/addon-in…
valentinpalkovic Oct 23, 2024
37d466b
Pin next^14 the right way
kasperpeulen Oct 23, 2024
eecd7b6
Revert workflow changes
kasperpeulen Oct 23, 2024
4a7c51e
Revert "Revert workflow changes"
kasperpeulen Oct 23, 2024
641c978
Use next 14 for next-vite as well
kasperpeulen Oct 23, 2024
7ea466b
Fix empty next projects
kasperpeulen Oct 23, 2024
f1d92c5
Merge remote-tracking branch 'origin/kasper/fix-sandboxes-next' into …
valentinpalkovic Oct 24, 2024
fa42817
Refactor CircleCI config to enable parallel unit testing with 2 shards
valentinpalkovic Oct 24, 2024
0f9606d
Fix tests
valentinpalkovic Oct 24, 2024
0739b0e
Merge shardened unit test reports
valentinpalkovic Oct 24, 2024
b4ae855
Save junit xml file
valentinpalkovic Oct 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions code/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ const config: StorybookConfig = {
directory: '../addons/interactions/src',
titlePrefix: 'addons/interactions',
},
// {
// directory: '../addons/interactions/template/stories',
// titlePrefix: 'addons/interactions',
// },
{
directory: '../addons/interactions/template/stories',
titlePrefix: 'addons/interactions/tests',
},
],
addons: [
'@storybook/addon-themes',
Expand Down
6 changes: 5 additions & 1 deletion code/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export const loaders = [
* The DocsContext will then be added via the decorator below.
*/
async ({ parameters: { relativeCsfPaths, attached = true } }) => {
if (!relativeCsfPaths) {
// TODO bring a better way to skip tests when running as part of the vitest plugin instead of __STORYBOOK_URL__
// eslint-disable-next-line no-underscore-dangle
if (!relativeCsfPaths || (import.meta as any).env?.__STORYBOOK_URL__) {
return {};
}
const csfFiles = await Promise.all(
Expand Down Expand Up @@ -358,3 +360,5 @@ export const parameters = {
},
},
};

export const tags = ['test', 'vitest'];
16 changes: 13 additions & 3 deletions code/.storybook/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,39 @@ if (process.env.INSPECT === 'true') {

export default mergeConfig(
vitestCommonConfig,
// @ts-expect-error added this because of testNamePattern below
defineProject({
plugins: [
import('@storybook/experimental-addon-test/vitest-plugin').then(({ storybookTest }) =>
storybookTest({
configDir: process.cwd(),
tags: {
include: ['vitest'],
},
})
),
...extraPlugins,
],
test: {
name: 'storybook-ui',
include: [
// TODO: test all core and addon stories later
// './core/**/components/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../addons/**/src/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../addons/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../core/template/stories/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../core/src/manager/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../core/src/preview-api/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../core/src/components/{brand,components}/**/*.{story,stories}.?(c|m)[jt]s?(x)',
],
exclude: [
...defaultExclude,
'../node_modules/**',
'**/__mockdata__/**',
'../**/__mockdata__/**',
// expected to fail in Vitest because of fetching /iframe.html to cause ECONNREFUSED
'**/Zoom.stories.tsx',
],
// TODO: bring this back once portable stories support @storybook/core/preview-api hooks
// @ts-expect-error this type does not exist but the property does!
testNamePattern: /^(?!.*(UseState)).*$/,
browser: {
enabled: true,
name: 'chromium',
Expand Down
13 changes: 10 additions & 3 deletions code/addons/interactions/template/stories/basics.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,17 @@ const UserEventSetup = {
{ keys: '[TouchA>]', target: canvas.getByRole('textbox') },
{ keys: '[/TouchA]' },
]);
await user.tab();
await user.keyboard('{enter}');
const submitButton = await canvas.findByRole('button');
await expect(submitButton).toHaveFocus();

if (navigator.userAgent.toLowerCase().includes('firefox')) {
// user event has a few issues on firefox, therefore we do it differently
await fireEvent.click(submitButton);
valentinpalkovic marked this conversation as resolved.
Show resolved Hide resolved
} else {
await user.tab();
await user.keyboard('{enter}');
await expect(submitButton).toHaveFocus();
}

await expect(args.onSuccess).toHaveBeenCalled();
});
},
Expand Down
19 changes: 14 additions & 5 deletions code/addons/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,28 @@
"prep": "jiti ../../../scripts/prepare/addon-bundle.ts"
},
"dependencies": {
"@storybook/csf": "^0.1.11"
"@storybook/csf": "^0.1.11",
"@storybook/icons": "^1.2.10",
"chalk": "^5.3.0"
},
"devDependencies": {
"@types/semver": "^7",
"@vitest/browser": "^2.0.0",
"@vitest/browser": "^2.1.1",
"@vitest/runner": "^2.1.1",
"boxen": "^8.0.1",
"execa": "^8.0.1",
"find-up": "^7.0.0",
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"semver": "^7.6.3",
"tinyrainbow": "^1.2.0",
"ts-dedent": "^2.2.0",
"vitest": "^2.0.0"
"vitest": "^2.1.1"
},
"peerDependencies": {
"@vitest/browser": "^2.0.0",
"@vitest/browser": "^2.1.1",
"@vitest/runner": "^2.1.1",
"storybook": "workspace:^",
"vitest": "^2.0.0"
},
Expand All @@ -103,7 +111,8 @@
"./src/preset.ts",
"./src/vitest-plugin/index.ts",
"./src/vitest-plugin/global-setup.ts",
"./src/postinstall.ts"
"./src/postinstall.ts",
"./src/node/vitest.ts"
]
}
}
3 changes: 2 additions & 1 deletion code/addons/test/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const ADDON_ID = 'storybook/vitest';
export const ADDON_ID = 'storybook/test';
export const TEST_PROVIDER_ID = `${ADDON_ID}/test-provider`;
7 changes: 7 additions & 0 deletions code/addons/test/src/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import chalk from 'chalk';

import { ADDON_ID } from './constants';

export const log = (message: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using a more specific type than 'any' for the message parameter

console.log(`${chalk.magenta(ADDON_ID)}: ${message.toString().trim()}`);
};
18 changes: 15 additions & 3 deletions code/addons/test/src/manager.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { type API, addons } from 'storybook/internal/manager-api';
import React from 'react';

import { ADDON_ID } from './constants';
import { addons } from 'storybook/internal/manager-api';
import { Addon_TypesEnum } from 'storybook/internal/types';

addons.register(ADDON_ID, () => {});
import { PointerHandIcon } from '@storybook/icons';

import { ADDON_ID, TEST_PROVIDER_ID } from './constants';

addons.register(ADDON_ID, () => {
addons.add(TEST_PROVIDER_ID, {
type: Addon_TypesEnum.experimental_TEST_PROVIDER,
icon: <PointerHandIcon />,
title: 'Component tests',
description: () => 'Not yet run',
});
});
145 changes: 145 additions & 0 deletions code/addons/test/src/node/boot-test-runner.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { Channel, type ChannelTransport } from '@storybook/core/channels';

import {
TESTING_MODULE_CANCEL_TEST_RUN_REQUEST,
TESTING_MODULE_RUN_ALL_REQUEST,
TESTING_MODULE_RUN_PROGRESS_RESPONSE,
TESTING_MODULE_RUN_REQUEST,
TESTING_MODULE_WATCH_MODE_REQUEST,
} from '@storybook/core/core-events';

import { execaNode } from 'execa';

import { log } from '../logger';
import { bootTestRunner } from './boot-test-runner';

let stdout: (chunk: any) => void;
let stderr: (chunk: any) => void;
let message: (event: any) => void;
valentinpalkovic marked this conversation as resolved.
Show resolved Hide resolved

const child = vi.hoisted(() => ({
stdout: {
on: vi.fn((event, callback) => {
stdout = callback;
}),
},
stderr: {
on: vi.fn((event, callback) => {
stderr = callback;
}),
},
on: vi.fn((event, callback) => {
message = callback;
}),
send: vi.fn(),
kill: vi.fn(),
}));

vi.mock('execa', () => ({
execaNode: vi.fn().mockReturnValue(child),
}));

vi.mock('../logger', () => ({
log: vi.fn(),
}));

beforeEach(() => {
vi.useFakeTimers();
});

afterEach(() => {
vi.useRealTimers();
});

const transport = { setHandler: vi.fn(), send: vi.fn() } satisfies ChannelTransport;
const mockChannel = new Channel({ transport });

describe('bootTestRunner', () => {
it('should execute vitest.js', async () => {
bootTestRunner(mockChannel);
expect(execaNode).toHaveBeenCalledWith(expect.stringMatching(/vitest\.js$/));
});

it('should log stdout and stderr', async () => {
bootTestRunner(mockChannel);
stdout('foo');
stderr('bar');
expect(log).toHaveBeenCalledWith('foo');
expect(log).toHaveBeenCalledWith('bar');
});

it('should wait for vitest to be ready', async () => {
let ready;
const promise = bootTestRunner(mockChannel).then(() => {
ready = true;
});
expect(ready).toBeUndefined();
message({ type: 'ready' });
await expect(promise).resolves.toBeUndefined();
expect(ready).toBe(true);
});

it('should abort if vitest doesn’t become ready in time', async () => {
const promise = bootTestRunner(mockChannel);
vi.advanceTimersByTime(10000);
await expect(promise).rejects.toThrow();
});

it('should abort if vitest fails to start repeatedly', async () => {
const promise = bootTestRunner(mockChannel);
message({ type: 'error' });
vi.advanceTimersByTime(1000);
message({ type: 'error' });
vi.advanceTimersByTime(1000);
message({ type: 'error' });
await expect(promise).rejects.toThrow();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider extracting the repeated error simulation into a helper function for better readability


it('should forward channel events', async () => {
bootTestRunner(mockChannel);
message({ type: 'ready' });

message({ type: TESTING_MODULE_RUN_PROGRESS_RESPONSE, args: ['foo'] });
expect(mockChannel.last(TESTING_MODULE_RUN_PROGRESS_RESPONSE)).toEqual(['foo']);

mockChannel.emit(TESTING_MODULE_RUN_REQUEST, 'foo');
expect(child.send).toHaveBeenCalledWith({
args: ['foo'],
from: 'server',
type: TESTING_MODULE_RUN_REQUEST,
});

mockChannel.emit(TESTING_MODULE_RUN_ALL_REQUEST, 'bar');
expect(child.send).toHaveBeenCalledWith({
args: ['bar'],
from: 'server',
type: TESTING_MODULE_RUN_ALL_REQUEST,
});

mockChannel.emit(TESTING_MODULE_WATCH_MODE_REQUEST, 'baz');
expect(child.send).toHaveBeenCalledWith({
args: ['baz'],
from: 'server',
type: TESTING_MODULE_WATCH_MODE_REQUEST,
});

mockChannel.emit(TESTING_MODULE_CANCEL_TEST_RUN_REQUEST, 'qux');
expect(child.send).toHaveBeenCalledWith({
args: ['qux'],
from: 'server',
type: TESTING_MODULE_CANCEL_TEST_RUN_REQUEST,
});
});

it('should resend init event', async () => {
bootTestRunner(mockChannel, 'init', ['foo']);
message({ type: 'ready' });
expect(child.send).toHaveBeenCalledWith({
args: ['foo'],
from: 'server',
type: 'init',
});
});
});
Loading
Loading