Skip to content

Commit 3b12d84

Browse files
authored
Merge pull request #32390 from storybookjs/version-patch-from-9.1.4
Release: Patch 9.1.5
2 parents 9f02684 + 7a47f95 commit 3b12d84

File tree

11 files changed

+754
-36
lines changed

11 files changed

+754
-36
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 9.1.5
2+
3+
- CSF: Support `satisfies x as y` syntax - [#32169](https://github.com/storybookjs/storybook/pull/32169), thanks @diagramatics!
4+
- Vitest addon: Handle Playwright installation errors gracefully - [#32329](https://github.com/storybookjs/storybook/pull/32329), thanks @ndelangen!
5+
16
## 9.1.4
27

38
- Angular: Properly merge builder options and browserTarget options - [#32272](https://github.com/storybookjs/storybook/pull/32272), thanks @kroeder!

code/addons/vitest/src/postinstall.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,14 @@ export default async function postInstall(options: PostinstallOptions) {
292292
} else {
293293
logger.plain(`${step} Configuring Playwright with Chromium (this might take some time):`);
294294
logger.plain(' npx playwright install chromium --with-deps');
295-
await packageManager.executeCommand({
296-
command: 'npx',
297-
args: ['playwright', 'install', 'chromium', '--with-deps'],
298-
});
295+
try {
296+
await packageManager.executeCommand({
297+
command: 'npx',
298+
args: ['playwright', 'install', 'chromium', '--with-deps'],
299+
});
300+
} catch (e) {
301+
console.error('Failed to install Playwright. Please install it manually');
302+
}
299303
}
300304

301305
const fileExtension =

code/core/src/csf-tools/CsfFile.test.ts

Lines changed: 189 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,57 @@ describe('CsfFile', () => {
515515
`);
516516
});
517517

518+
it('typescript satisfies as', () => {
519+
expect(
520+
parse(
521+
dedent`
522+
import type { Meta, StoryFn, StoryObj } from '@storybook/react';
523+
type PropTypes = {};
524+
export default { title: 'foo/bar' } satisfies Meta<PropTypes> as Meta<PropTypes>;
525+
export const A = { name: 'AA' } satisfies StoryObj<PropTypes>;
526+
export const B = ((args) => {}) satisfies StoryFn<PropTypes>;
527+
`,
528+
true
529+
)
530+
).toMatchInlineSnapshot(`
531+
meta:
532+
title: foo/bar
533+
stories:
534+
- id: foo-bar--a
535+
name: AA
536+
parameters:
537+
__isArgsStory: true
538+
__id: foo-bar--a
539+
__stats:
540+
factory: false
541+
play: false
542+
render: false
543+
loaders: false
544+
beforeEach: false
545+
globals: false
546+
tags: false
547+
storyFn: false
548+
mount: false
549+
moduleMock: false
550+
- id: foo-bar--b
551+
name: B
552+
parameters:
553+
__isArgsStory: true
554+
__id: foo-bar--b
555+
__stats:
556+
factory: false
557+
play: false
558+
render: false
559+
loaders: false
560+
beforeEach: false
561+
globals: false
562+
tags: false
563+
storyFn: false
564+
mount: false
565+
moduleMock: false
566+
`);
567+
});
568+
518569
it('typescript meta var', () => {
519570
expect(
520571
parse(
@@ -605,6 +656,136 @@ describe('CsfFile', () => {
605656
`);
606657
});
607658

659+
it('typescript satisfies as meta', () => {
660+
expect(
661+
parse(
662+
dedent`
663+
import type { Meta, StoryFn } from '@storybook/react';
664+
type PropTypes = {};
665+
const meta = { title: 'foo/bar/baz' } satisfies Meta<PropTypes> as Meta<PropTypes>;
666+
export default meta;
667+
export const A: StoryFn<PropTypes> = () => <>A</>;
668+
export const B: StoryFn<PropTypes> = () => <>B</>;
669+
`
670+
)
671+
).toMatchInlineSnapshot(`
672+
meta:
673+
title: foo/bar/baz
674+
stories:
675+
- id: foo-bar-baz--a
676+
name: A
677+
__stats:
678+
factory: false
679+
play: false
680+
render: false
681+
loaders: false
682+
beforeEach: false
683+
globals: false
684+
tags: false
685+
storyFn: true
686+
mount: false
687+
moduleMock: false
688+
- id: foo-bar-baz--b
689+
name: B
690+
__stats:
691+
factory: false
692+
play: false
693+
render: false
694+
loaders: false
695+
beforeEach: false
696+
globals: false
697+
tags: false
698+
storyFn: true
699+
mount: false
700+
moduleMock: false
701+
`);
702+
});
703+
704+
it('typescript satisfies as stories', () => {
705+
expect(
706+
parse(
707+
dedent`
708+
import type { Meta, StoryFn, StoryObj } from '@storybook/react';
709+
type PropTypes = {};
710+
export default { title: 'foo/bar' } as Meta<PropTypes>;
711+
export const A = { name: 'AA' } satisfies StoryObj<PropTypes> as StoryObj<PropTypes>;
712+
export const B = ((args) => {}) satisfies StoryFn<PropTypes> as StoryFn<PropTypes>;
713+
`,
714+
true
715+
)
716+
).toMatchInlineSnapshot(`
717+
meta:
718+
title: foo/bar
719+
stories:
720+
- id: foo-bar--a
721+
name: AA
722+
parameters:
723+
__isArgsStory: true
724+
__id: foo-bar--a
725+
__stats:
726+
factory: false
727+
play: false
728+
render: false
729+
loaders: false
730+
beforeEach: false
731+
globals: false
732+
tags: false
733+
storyFn: false
734+
mount: false
735+
moduleMock: false
736+
- id: foo-bar--b
737+
name: B
738+
parameters:
739+
__isArgsStory: true
740+
__id: foo-bar--b
741+
__stats:
742+
factory: false
743+
play: false
744+
render: false
745+
loaders: false
746+
beforeEach: false
747+
globals: false
748+
tags: false
749+
storyFn: false
750+
mount: false
751+
moduleMock: false
752+
`);
753+
});
754+
755+
it('typescript satisfies as export specifier', () => {
756+
expect(
757+
parse(
758+
dedent`
759+
import type { Meta, StoryFn } from '@storybook/react';
760+
type PropTypes = {};
761+
const meta = { title: 'foo/bar/baz' } satisfies Meta<PropTypes> as Meta<PropTypes>;
762+
const story = { name: 'Story A' };
763+
export { meta as default, story as A };
764+
`,
765+
true
766+
)
767+
).toMatchInlineSnapshot(`
768+
meta:
769+
title: foo/bar/baz
770+
stories:
771+
- id: foo-bar-baz--a
772+
name: A
773+
localName: story
774+
parameters:
775+
__id: foo-bar-baz--a
776+
__stats:
777+
play: false
778+
render: false
779+
loaders: false
780+
beforeEach: false
781+
globals: false
782+
tags: false
783+
storyFn: false
784+
mount: false
785+
moduleMock: false
786+
`);
787+
});
788+
608789
it('component object', () => {
609790
expect(
610791
parse(
@@ -1995,7 +2176,7 @@ describe('CsfFile', () => {
19952176
const { indexInputs } = loadCsf(
19962177
dedent`
19972178
const Component = (props) => <div>hello</div>;
1998-
2179+
19992180
export default {
20002181
title: 'custom foo title',
20012182
component: Component,
@@ -2513,7 +2694,7 @@ describe('CsfFile', () => {
25132694
).toThrowErrorMatchingInlineSnapshot(`
25142695
[MultipleMetaError: CSF: multiple meta objects (line 4, col 24)
25152696
2516-
More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error]
2697+
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export]
25172698
`);
25182699
});
25192700

@@ -2531,7 +2712,7 @@ describe('CsfFile', () => {
25312712
).toThrowErrorMatchingInlineSnapshot(`
25322713
[MultipleMetaError: CSF: multiple meta objects (line 3, col 25)
25332714
2534-
More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error]
2715+
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export]
25352716
`);
25362717
});
25372718

@@ -2549,7 +2730,7 @@ describe('CsfFile', () => {
25492730
).toThrowErrorMatchingInlineSnapshot(`
25502731
[MultipleMetaError: CSF: multiple meta objects
25512732
2552-
More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error]
2733+
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export]
25532734
`);
25542735
});
25552736

@@ -2565,7 +2746,7 @@ describe('CsfFile', () => {
25652746
).toThrowErrorMatchingInlineSnapshot(`
25662747
[BadMetaError: CSF: meta() factory must be imported from .storybook/preview configuration (line 1, col 0)
25672748
2568-
More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error]
2749+
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export]
25692750
`);
25702751
});
25712752

@@ -2582,7 +2763,7 @@ describe('CsfFile', () => {
25822763
).toThrowErrorMatchingInlineSnapshot(`
25832764
[BadMetaError: CSF: meta() factory must be imported from .storybook/preview configuration (line 4, col 28)
25842765
2585-
More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error]
2766+
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export]
25862767
`);
25872768
});
25882769

@@ -2599,7 +2780,7 @@ describe('CsfFile', () => {
25992780
).toThrowErrorMatchingInlineSnapshot(`
26002781
[MixedFactoryError: CSF: expected factory story (line 4, col 17)
26012782
2602-
More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error]
2783+
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export]
26032784
`);
26042785
});
26052786

@@ -2616,7 +2797,7 @@ describe('CsfFile', () => {
26162797
).toThrowErrorMatchingInlineSnapshot(`
26172798
[MixedFactoryError: CSF: expected non-factory story (line 4, col 28)
26182799
2619-
More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error]
2800+
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export]
26202801
`);
26212802
});
26222803
});

0 commit comments

Comments
 (0)