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

Release: Prerelease alpha 7.6.0-alpha.3 #24556

Merged
merged 145 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
28422c5
fix: added code to update store.settings.lastTrackedStoryId in api.se…
rashidshamloo Sep 8, 2023
07b4d3a
Merge branch 'next' into bugfix-23723-canvas-link-shows-default-story…
rashidshamloo Sep 9, 2023
8a204ba
Merge branch 'next' into bugfix-23723-canvas-link-shows-default-story…
rashidshamloo Sep 11, 2023
29420ae
Merge branch 'next' into bugfix-23723-canvas-link-shows-default-story…
ndelangen Sep 19, 2023
3f97e04
Merge branch 'next' into bugfix-23723-canvas-link-shows-default-story…
rashidshamloo Sep 19, 2023
29f8596
Create @storybook/test package
kasperpeulen Aug 17, 2023
f0d68a1
Replace expect (from jest) with @vitest/expect
kasperpeulen Aug 25, 2023
97350aa
Fix build
kasperpeulen Aug 25, 2023
daeffb5
Move testing library to test package + some improvements
kasperpeulen Sep 19, 2023
1f02904
Add testing library assertion on expect
kasperpeulen Sep 19, 2023
b406b6d
Make sure synchronous methods are always promises, even in the first run
kasperpeulen Sep 20, 2023
76c109a
Revert mistake
kasperpeulen Sep 20, 2023
d034a44
Clear spies and instrument spies by event handler name
kasperpeulen Sep 20, 2023
e6b0f0a
Show deprecation message
kasperpeulen Sep 20, 2023
9d88027
Revert making get* method's promises and make sure we instrument `not`
kasperpeulen Sep 21, 2023
ea2c3c3
fix yarn lock
yannbf Sep 21, 2023
33cbcae
Fix eslint
kasperpeulen Sep 21, 2023
6d19861
Comment out deprecation for now
kasperpeulen Sep 22, 2023
0b76716
Fix types
kasperpeulen Sep 22, 2023
da91e3d
Make getters lazy and fix workspace
kasperpeulen Sep 22, 2023
17b3a33
Fix yarn.lock
kasperpeulen Sep 22, 2023
fae8299
Fix type fest range
kasperpeulen Sep 22, 2023
2085dd4
Patch vitest to make it compatible with the jest runner
kasperpeulen Sep 22, 2023
39ed28d
Add jest types to lock
kasperpeulen Sep 22, 2023
ddd8bf1
Better patch
kasperpeulen Sep 22, 2023
27ded25
Fix lock
kasperpeulen Sep 22, 2023
d44e0bd
Fix lazy getters
kasperpeulen Sep 23, 2023
8657c59
Fix gitignore
kasperpeulen Sep 23, 2023
db9bb66
Merge branch 'next' into kasper/test-package
kasperpeulen Oct 3, 2023
a5cdd31
Fix getter
kasperpeulen Oct 3, 2023
d62d5b2
Merge remote-tracking branch 'origin/next' into kasper/test-package
kasperpeulen Oct 3, 2023
de86f5d
Always externalize @vitest deps in tsup, as they are ESM-only. But st…
kasperpeulen Oct 4, 2023
6ee27f2
Always install extra deps
kasperpeulen Oct 3, 2023
47586d9
Fix getters that use `this`
kasperpeulen Oct 4, 2023
4ae6a77
Fix deps issue
kasperpeulen Oct 4, 2023
5497868
Merge remote-tracking branch 'origin/next' into kasper/bladiebla
kasperpeulen Oct 5, 2023
6de0d49
Fix lock files
kasperpeulen Oct 5, 2023
2b9981a
Fix check script
kasperpeulen Oct 5, 2023
fb84613
Calculate the diff for chai errors
kasperpeulen Oct 10, 2023
6801e04
Add moduleNameMapper for ESM only modules with package json exports
kasperpeulen Oct 10, 2023
ef847b9
Downcast function types that are mocks in meta args
kasperpeulen Oct 10, 2023
d843514
Merge branch 'next' into kapser/test-package2
ndelangen Oct 11, 2023
4b3d638
Make sure that actions get attached spies across stories when defined…
kasperpeulen Oct 12, 2023
8d51ad7
Merge branch 'next' into kasper/fix-attach-spy
yannbf Oct 13, 2023
c80c4a2
Avoid CSP issue in A11y
Marklb Oct 15, 2023
4c48b53
Docs: Fix links and conditional rendering sections
jonniebigodes Oct 18, 2023
cca1bad
Docs: Vite builder updates
jonniebigodes Oct 19, 2023
728fc89
Fix:Typo in multiple files of docs and code folder
thapasusheel Oct 21, 2023
3c0d6c8
allow yarn 4 in link command
yannbf Oct 23, 2023
4ee42ac
Merge pull request #24551 from storybookjs/yann/fix-link-command
JReinhold Oct 23, 2023
81e7288
Core-Server: Ingore all node_module folders for watchpack
valentinpalkovic Oct 23, 2023
387da6d
upgrade to yarn 4
JReinhold Oct 23, 2023
d5c5226
fix publishing with yarn v4
JReinhold Oct 23, 2023
e7330c2
bust prettydocs yarn cache
JReinhold Oct 23, 2023
11cc507
use other command for installing in prettydocs
JReinhold Oct 23, 2023
f02e9c6
Merge branch 'next' into docs_vite_builder_updates
jonniebigodes Oct 23, 2023
46c45c6
Merge branch 'next' into docs_minor_fixes
jonniebigodes Oct 23, 2023
58b6b0a
Merge pull request #24553 from storybookjs/valentin/ignore-all-node_m…
valentinpalkovic Oct 23, 2023
1dec9cb
Merge branch 'next' into patch
jonniebigodes Oct 23, 2023
30669e7
Merge branch 'next' into docs_minor_fixes
jonniebigodes Oct 23, 2023
2bbcab4
Docs: MDX updates
jonniebigodes Oct 23, 2023
a7a4cdf
Docs: Addon-docs minor changes
jonniebigodes Oct 23, 2023
ef80cf5
increase prettydocs image size
JReinhold Oct 24, 2023
2d556c1
Merge branch 'next' into upgrade-yarn-4
JReinhold Oct 24, 2023
20213b8
Implement test build bench
kasperpeulen Oct 24, 2023
25eb141
Change the big query schema
kasperpeulen Oct 24, 2023
d6963a2
Add the jobs
kasperpeulen Oct 24, 2023
b6acefa
Merge branch 'next' into bugfix-23723-canvas-link-shows-default-story…
JReinhold Oct 24, 2023
f2733d0
Try to fix bench
kasperpeulen Oct 24, 2023
fd539a7
Merge pull request #24115 from rashidshamloo/bugfix-23723-canvas-link…
JReinhold Oct 24, 2023
9bbf3c5
Fix antoher dep
kasperpeulen Oct 24, 2023
7f2b880
Don't use the same file names
kasperpeulen Oct 24, 2023
c64fada
New run
kasperpeulen Oct 24, 2023
08be048
Merge branch 'next' into docs_minor_fixes
jonniebigodes Oct 24, 2023
41ecb47
Merge branch 'next' into patch
jonniebigodes Oct 24, 2023
5a68ab9
Merge pull request #24566 from storybookjs/kasper/test-build-bench
kasperpeulen Oct 24, 2023
d8d16f4
Revert "Build: Implement test build bench"
kasperpeulen Oct 24, 2023
b2d66c6
Merge pull request #24569 from storybookjs/revert-24566-kasper/test-b…
kasperpeulen Oct 24, 2023
7128bbb
Merge branch 'next' into docs_minor_fixes
jonniebigodes Oct 24, 2023
3e098fd
Merge pull request #24508 from storybookjs/docs_minor_fixes
jonniebigodes Oct 24, 2023
8725910
Revert "Revert: "Build: Implement test build bench""
kasperpeulen Oct 25, 2023
25417d2
Fix parallelism
kasperpeulen Oct 25, 2023
2509a69
Fix pnp support when cache dir is outside working dir
valentinpalkovic Oct 25, 2023
14ce071
Merge pull request #24571 from storybookjs/revert-24569-revert-24566-…
kasperpeulen Oct 25, 2023
4a12d4a
Merge pull request #24565 from storybookjs/upgrade-yarn-4
JReinhold Oct 25, 2023
622585c
Revert "Build: Implement test build bench"
kasperpeulen Oct 25, 2023
9efca7a
Merge pull request #24573 from storybookjs/revert-24571-revert-24569-…
kasperpeulen Oct 25, 2023
5182fcc
Revert "Revert "Build: Implement test build bench""
kasperpeulen Oct 25, 2023
2a0cd91
Merge pull request #24574 from storybookjs/revert-24573-revert-24571-…
kasperpeulen Oct 25, 2023
f42e9ef
Pre bundle most deps of the test package
kasperpeulen Oct 25, 2023
43ee7d5
Merge remote-tracking branch 'origin/next' into kapser/test-package2
kasperpeulen Oct 25, 2023
7b2167a
Updated wording
thapasusheel Oct 26, 2023
deb14a6
Update test-runner.md prepare function typo
kota-kamikawa Oct 26, 2023
1e75e89
Add new sandboxes for test build benchmarks
kasperpeulen Oct 26, 2023
c2ac545
Fix sandbox names
kasperpeulen Oct 26, 2023
ece2d24
Merge pull request #24582 from storybookjs/kasper/bench-sandboxes
kasperpeulen Oct 26, 2023
0761358
Remove inDevelopment
kasperpeulen Oct 26, 2023
9a2a515
Merge branch 'next' into docs_remove_transclude_option
JReinhold Oct 26, 2023
65ea5c5
Merge pull request #24561 from storybookjs/docs_remove_transclude_option
JReinhold Oct 26, 2023
047a9a6
Merge pull request #24572 from storybookjs/valentin/fix-pnp-support-f…
valentinpalkovic Oct 26, 2023
f505c63
Merge pull request #24586 from storybookjs/kasper/bench-sandboxes-rem…
kasperpeulen Oct 26, 2023
c6ffb6c
Merge pull request #24451 from storybookjs/kasper/fix-attach-spy
kasperpeulen Oct 26, 2023
153c1f8
Merge branch 'next' into docs_writing_docs_updates
jonniebigodes Oct 26, 2023
a8edebd
Merge branch 'next' into kapser/test-package2
kasperpeulen Oct 26, 2023
20508e7
Merge pull request #24559 from storybookjs/docs_writing_docs_updates
jonniebigodes Oct 26, 2023
958ad98
Merge branch 'next' into patch-1
jonniebigodes Oct 26, 2023
1452ab6
Merge pull request #24583 from kota-kamikawa/patch-1
jonniebigodes Oct 26, 2023
3a1f2cb
Fix broken link to Builder API declaration in docs
speelbarrow Oct 26, 2023
cf6b415
Merge pull request #24588 from speelbarrow/patch-1
jonniebigodes Oct 26, 2023
ab7b7b1
Docs: Fix Globals and Toolbars examples
jonniebigodes Oct 26, 2023
4086d5b
Merge branch 'next' into docs_vite_builder_updates
jonniebigodes Oct 26, 2023
4446a24
Merge branch 'next' into docs_update_toolbar_docs_snippets
jonniebigodes Oct 26, 2023
a8cda8d
Merge pull request #24590 from storybookjs/docs_update_toolbar_docs_s…
jonniebigodes Oct 26, 2023
b03f402
fix wording in multiple files
thapasusheel Oct 27, 2023
3fa771c
feat: Support next@14.0.0
nikospapcom Oct 27, 2023
83f4ef0
chore: Remove package-lock file
nikospapcom Oct 27, 2023
a27e789
chore: Revert node engine to 16
nikospapcom Oct 27, 2023
bcf87ea
Fix eslint
kasperpeulen Oct 27, 2023
031534f
export globals const instead of default
JReinhold Oct 27, 2023
19f2409
Merge branch 'next' into kapser/test-package2
kasperpeulen Oct 27, 2023
bf06b67
add codeowners for addon-themes
JReinhold Oct 27, 2023
7626e39
Merge branch 'next' into patch
jonniebigodes Oct 27, 2023
1919343
Merge pull request #24541 from thapasusheel/patch
jonniebigodes Oct 27, 2023
8102813
Merge branch 'next' into 24351-bug-error-when-switching-themes-addon-…
Oct 27, 2023
eacb4a7
Feedback addressed
jonniebigodes Oct 27, 2023
d888f60
Fix next version
kasperpeulen Oct 27, 2023
715381c
Fix next/legacy/image imports for Next.js v14
valentinpalkovic Oct 27, 2023
c91523f
Merge branch 'next' into support-next-14
valentinpalkovic Oct 27, 2023
4f08e77
Merge remote-tracking branch 'origin/kapser/test-package2' into kapse…
kasperpeulen Oct 27, 2023
7726afc
Merge pull request #24593 from nikospapcom/support-next-14
valentinpalkovic Oct 27, 2023
4e993be
Merge remote-tracking branch 'origin/next' into kapser/test-package2
kasperpeulen Oct 27, 2023
6e0c0da
Merge branch 'next' into docs_vite_builder_updates
jonniebigodes Oct 27, 2023
98dfee4
Merge pull request #24522 from storybookjs/docs_vite_builder_updates
jonniebigodes Oct 27, 2023
6359db3
Docs: Builder Vite - Remove outdated Svelte reference
jonniebigodes Oct 27, 2023
e1bcbfe
Merge pull request #24392 from storybookjs/kapser/test-package2
kasperpeulen Oct 27, 2023
1a13287
Docs: Fix conditional rendering for Unit testing
jonniebigodes Oct 27, 2023
1b0ca54
Merge pull request #24600 from storybookjs/docs_updates_unit_tests
jonniebigodes Oct 27, 2023
55eccb3
Merge branch 'next' into marklb/fix-csp-error-in-a11y-addon
valentinpalkovic Oct 27, 2023
2066866
Merge branch 'next' into docs_vite_builder_svelte_update
jonniebigodes Oct 27, 2023
9925d3b
Merge pull request #24477 from Marklb/marklb/fix-csp-error-in-a11y-addon
valentinpalkovic Oct 27, 2023
1423941
Merge branch 'next' into docs_vite_builder_svelte_update
jonniebigodes Oct 27, 2023
38d7bca
Merge pull request #24599 from storybookjs/docs_vite_builder_svelte_u…
jonniebigodes Oct 27, 2023
2245d79
Merge branch 'next' into 24351-bug-error-when-switching-themes-addon-…
JReinhold Oct 27, 2023
010fc13
Merge pull request #24596 from storybookjs/24351-bug-error-when-switc…
JReinhold Oct 27, 2023
3d872a0
Write changelog for 7.6.0-alpha.3 [skip ci]
storybook-bot Oct 30, 2023
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
23 changes: 12 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ commands:
jobs:
pretty-docs:
executor:
class: small
class: medium
name: sb_node_16_classic
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
- restore_cache:
name: Restore Yarn cache
keys:
- prettydocs-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
- prettydocs-yarn-2-cache-v7--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
- run:
name: Install
command: |
cd scripts
yarn install
- save_cache:
name: Save Yarn cache
key: prettydocs-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
key: prettydocs-yarn-2-cache-v7--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
paths:
- ~/.yarn/berry/cache
- run:
Expand Down Expand Up @@ -499,11 +499,11 @@ workflows:
requires:
- unit-tests
- create-sandboxes:
parallelism: 12
parallelism: 14
requires:
- build
- build-sandboxes:
parallelism: 12
parallelism: 14
requires:
- create-sandboxes
- chromatic-sandboxes:
Expand All @@ -523,7 +523,7 @@ workflows:
requires:
- build-sandboxes
- bench:
parallelism: 3
parallelism: 5
requires:
- build-sandboxes
# TODO: reenable once we find out the source of flakyness
Expand Down Expand Up @@ -555,11 +555,11 @@ workflows:
requires:
- unit-tests
- create-sandboxes:
parallelism: 21
parallelism: 23
requires:
- build
- build-sandboxes:
parallelism: 21
parallelism: 23
requires:
- create-sandboxes
- chromatic-sandboxes:
Expand All @@ -579,7 +579,7 @@ workflows:
requires:
- build-sandboxes
- bench:
parallelism: 3
parallelism: 5
requires:
- build-sandboxes
# TODO: reenable once we find out the source of flakyness
Expand Down Expand Up @@ -609,14 +609,14 @@ workflows:
requires:
- build
- create-sandboxes:
parallelism: 36
parallelism: 38
requires:
- build
# - smoke-test-sandboxes: # disabled for now
# requires:
# - create-sandboxes
- build-sandboxes:
parallelism: 36
parallelism: 38
requires:
- create-sandboxes
- chromatic-sandboxes:
Expand All @@ -640,3 +640,4 @@ workflows:
# parallelism: 4
# requires:
# - create-sandboxes

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ test-results
!/**/.yarn/plugins
!/**/.yarn/sdks
!/**/.yarn/versions
!/**/.yarn/patches
/**/.pnp.*
!/node_modules

Expand Down
28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.5.1.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.0.cjs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
compressionLevel: mixed

enableGlobalCache: false

installStatePath: ./.yarn/root-install-state.gz

nodeLinker: node-modules

npmPublishAccess: public

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.5.1.cjs
yarnPath: .yarn/releases/yarn-4.0.0.cjs
12 changes: 12 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 7.6.0-alpha.3

- Action: Attach spies on actions across stories when defined in meta - [#24451](https://github.com/storybookjs/storybook/pull/24451), thanks [@kasperpeulen](https://github.com/kasperpeulen)!
- Addon A11y: Avoid CSP issue - [#24477](https://github.com/storybookjs/storybook/pull/24477), thanks [@Marklb](https://github.com/Marklb)!
- Addon-themes: Fix globals not being set when using absolute path - [#24596](https://github.com/storybookjs/storybook/pull/24596), thanks [@JReinhold](https://github.com/JReinhold)!
- CLI: Allow Yarn v4 in `link` command - [#24551](https://github.com/storybookjs/storybook/pull/24551), thanks [@yannbf](https://github.com/yannbf)!
- Core-Server: Ignore all node_module folders for watchpack - [#24553](https://github.com/storybookjs/storybook/pull/24553), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!
- Core: Fix pnp support when cache dir is outside working dir - [#24572](https://github.com/storybookjs/storybook/pull/24572), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!
- Manager: Update `store.settings.lastTrackedStoryId` - [#24115](https://github.com/storybookjs/storybook/pull/24115), thanks [@rashidshamloo](https://github.com/rashidshamloo)!
- Next.js: Support v14.0.0 - [#24593](https://github.com/storybookjs/storybook/pull/24593), thanks [@nikospapcom](https://github.com/nikospapcom)!
- Test: Create @storybook/test package based on vitest - [#24392](https://github.com/storybookjs/storybook/pull/24392), thanks [@kasperpeulen](https://github.com/kasperpeulen)!

## 7.6.0-alpha.2

- Actions: Fix missing crypto module crashing React Native - [#24546](https://github.com/storybookjs/storybook/pull/24546), thanks [@dannyhw](https://github.com/dannyhw)!
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/code/addons/storyshots-core/ @ndelangen
/code/addons/storyshots-puppeteer/ @ndelangen
/code/addons/storysource/ @ndelangen
/code/addons/themes/ @JReinhold @Integrayshaun
/code/addons/toolbars/ @ndelangen @JReinhold
/code/addons/viewport/ @yannbf @ndelangen

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ No process is defined for this.

### Merges to `main` without versioning

As described in more details in [the Patch Releases section](#patch-releases), there are scenarios where you want to patch [unreleasable](#which-changes-are-considered-releasable-and-what-does-it-mean) content back to `main` without bumping versions or publishing a new release. This happens automatically as long as all the unpicked patch pull requests have unreleasable labels. In that case the prepared patch pull request will change form slighty, to just cherry-picking the patches without bumping the versions.
As described in more details in [the Patch Releases section](#patch-releases), there are scenarios where you want to patch [unreleasable](#which-changes-are-considered-releasable-and-what-does-it-mean) content back to `main` without bumping versions or publishing a new release. This happens automatically as long as all the unpicked patch pull requests have unreleasable labels. In that case the prepared patch pull request will change form slightly, to just cherry-picking the patches without bumping the versions.

## FAQ

Expand Down
37 changes: 37 additions & 0 deletions code/.yarn/patches/@vitest-expect-npm-0.34.5-8031508efe.patch

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion code/.yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ plugins:
unsafeHttpWhitelist:
- localhost

yarnPath: ../.yarn/releases/yarn-3.5.1.cjs
yarnPath: ../.yarn/releases/yarn-4.0.0.cjs
installStatePath: '../.yarn/code-install-state.gz'
8 changes: 7 additions & 1 deletion code/addons/a11y/src/a11yRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ const run = async (storyId: string) => {
}

const result = await axe.run(htmlElement, options);

// Axe result contains class instances, which telejson deserializes in a
// way that violates:
// Content Security Policy directive: "script-src 'self' 'unsafe-inline'".
const resultJson = JSON.parse(JSON.stringify(result));

// It's possible that we requested a new run on a different story.
// Unfortunately, axe doesn't support a cancel method to abort current run.
// We check if the story we run against is still the current one,
// if not, trigger a new run using the current story
if (activeStoryId === storyId) {
channel.emit(EVENTS.RESULT, result);
channel.emit(EVENTS.RESULT, resultJson);
} else {
active = false;
run(activeStoryId);
Expand Down
7 changes: 6 additions & 1 deletion code/addons/actions/src/addArgs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type { ArgsEnhancer } from '@storybook/types';
import { addActionsFromArgTypes, inferActionsFromArgTypesRegex } from './addArgsHelpers';
import {
addActionsFromArgTypes,
attachActionsToFunctionMocks,
inferActionsFromArgTypesRegex,
} from './addArgsHelpers';

export const argsEnhancers: ArgsEnhancer[] = [
addActionsFromArgTypes,
inferActionsFromArgTypesRegex,
attachActionsToFunctionMocks,
];
33 changes: 32 additions & 1 deletion code/addons/actions/src/addArgsHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-underscore-dangle,no-param-reassign */
import type { Args, Renderer, ArgsEnhancer } from '@storybook/types';
import { action } from './runtime/action';

Expand Down Expand Up @@ -31,7 +32,7 @@ export const inferActionsFromArgTypesRegex: ArgsEnhancer<Renderer> = (context) =

return argTypesMatchingRegex.reduce((acc, [name, argType]) => {
if (isInInitialArgs(name, initialArgs)) {
acc[name] = action(name);
acc[name] = action(name, { implicit: true });
}
return acc;
}, {} as Args);
Expand Down Expand Up @@ -61,3 +62,33 @@ export const addActionsFromArgTypes: ArgsEnhancer<Renderer> = (context) => {
return acc;
}, {} as Args);
};

export const attachActionsToFunctionMocks: ArgsEnhancer<Renderer> = (context) => {
const {
initialArgs,
argTypes,
parameters: { actions },
} = context;
if (actions?.disable || !argTypes) {
return {};
}

const argTypesWithAction = Object.entries(initialArgs).filter(
([, value]) =>
typeof value === 'function' &&
'_isMockFunction' in value &&
value._isMockFunction &&
!value._actionAttached
);

return argTypesWithAction.reduce((acc, [key, value]) => {
const previous = value.getMockImplementation();
value.mockImplementation((...args: unknown[]) => {
action(key)(...args);
return previous?.(...args);
});
// this enhancer is being called multiple times
value._actionAttached = true;
return acc;
}, {} as Args);
};
1 change: 1 addition & 0 deletions code/addons/actions/src/models/ActionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface Options {
depth: number; // backards compatibility, remove in 7.0
clearOnStoryChange: boolean;
limit: number;
implicit: boolean;
}

export type ActionOptions = Partial<Options> & Partial<TelejsonOptions>;
17 changes: 17 additions & 0 deletions code/addons/actions/src/runtime/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ export function action(name: string, options: ActionOptions = {}): HandlerFuncti
};

const handler = function actionHandler(...args: any[]) {
// TODO: Enable once codemods are finished
// if (options.implicit) {
// const preview =
// '__STORYBOOK_PREVIEW__' in global
// ? (global.__STORYBOOK_PREVIEW__ as PreviewWeb<Renderer>)
// : undefined;
// if (
// preview?.storyRenders.some(
// (render) => render.phase === 'playing' || render.phase === 'rendering'
// )
// ) {
// console.warn(
// 'Can not use implicit actions during rendering or playing of a story.'
// );
// }
// }

const channel = addons.getChannel();
// this makes sure that in js enviroments like react native you can still get an id
const id = generateId();
Expand Down
10 changes: 1 addition & 9 deletions code/addons/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ export default {
jsxOptions: {},
csfPluginOptions: null,
mdxPluginOptions: {},
transcludeMarkdown: true,
},
},
],
Expand All @@ -157,16 +156,9 @@ export default {

`csfPluginOptions` is an object for configuring `@storybook/csf-plugin`. When set to `null` it tells docs not to run the `csf-plugin` at all, which can be used as an optimization, or if you're already using `csf-plugin` in your `main.js`.

The `transcludeMarkdown` option enables mdx files to import `.md` files and render them as a component.

```mdx
import { Meta } from '@storybook/addon-docs';
import Changelog from '../CHANGELOG.md';
> With the release of version 7.0, it is no longer possible to import `.md` files directly into Storybook using the `transcludeMarkdown` [option](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#importing-plain-markdown-files-with-transcludemarkdown-has-changed). Instead, we recommend using the [`Markdown`](https://storybook.js.org/docs/react/api/doc-block-markdown) Doc Block for importing Markdown files into your Storybook documentation.

<Meta title="Changelog" />

<Changelog />
```

## TypeScript configuration

Expand Down
25 changes: 24 additions & 1 deletion code/addons/interactions/src/components/Interaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type Call, CallStates, type ControlStates } from '@storybook/instrument
import { styled, typography } from '@storybook/theming';
import { transparentize } from 'polished';

import { MatcherResult } from './MatcherResult';
import { Expected, MatcherResult, Received } from './MatcherResult';
import { MethodCall } from './MethodCall';
import { StatusIcon } from './StatusIcon';

Expand Down Expand Up @@ -120,6 +120,29 @@ const Exception = ({ exception }: { exception: Call['exception'] }) => {
return (
<RowMessage>
<pre>{paragraphs[0]}</pre>

{exception.showDiff && exception.diff ? (
<>
<br />
<MatcherResult message={exception.diff} style={{ padding: 0 }} />
</>
) : (
<pre>
<br />
{exception.expected && (
<>
Expected: <Expected value={exception.expected} />
<br />
</>
)}
{exception.actual && (
<>
Received: <Received value={exception.actual} />
<br />
</>
)}
</pre>
)}
{more && <p>See the full stack trace in the browser console.</p>}
</RowMessage>
);
Expand Down
9 changes: 8 additions & 1 deletion code/addons/interactions/src/components/MatcherResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,21 @@ export const Expected = ({ value, parsed }: { value: any; parsed?: boolean }) =>
return <StyledExpected>{value}</StyledExpected>;
};

export const MatcherResult = ({ message }: { message: string }) => {
export const MatcherResult = ({
message,
style = {},
}: {
message: string;
style?: React.CSSProperties;
}) => {
const lines = message.split('\n');
return (
<pre
style={{
margin: 0,
padding: '8px 10px 8px 36px',
fontSize: typography.size.s1,
...style,
}}
>
{lines.flatMap((line: string, index: number) => {
Expand Down
Loading