@storybook/react-vite 11.0.0-beta.0 → 11.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_node-chunks/chunk-DWGDBIRG.js +49 -0
- package/dist/_node-chunks/react-docgen-2UF7RHED.js +5041 -0
- package/dist/{chunk--ndSXwBc.d.ts → chunk-DzJdQ4En.d.ts} +22 -3
- package/dist/index.d.ts +2 -2
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +7 -6
- package/dist/preset.d.ts +1 -1
- package/dist/preset.js +25 -24
- package/package.json +23 -10
- package/template/cli/js/Button.stories.js +11 -10
- package/template/cli/js/Header.stories.js +6 -5
- package/template/cli/js/Page.stories.js +6 -5
- package/template/cli/ts/Button.stories.ts +11 -14
- package/template/cli/ts/Header.stories.ts +6 -9
- package/template/cli/ts/Page.stories.ts +6 -9
- package/dist/_node-chunks/react-docgen-NQN6BMDC.js +0 -215
|
@@ -1,8 +1,27 @@
|
|
|
1
|
+
import { ReactDocgenTypescriptParserOptions } from "@storybook/react";
|
|
1
2
|
import { CompatibleString, StorybookConfig, TypescriptOptions } from "storybook/internal/types";
|
|
2
3
|
import { BuilderOptions, StorybookConfigVite } from "@storybook/builder-vite";
|
|
3
|
-
import docgenTypescript from "@joshwooding/vite-plugin-react-docgen-typescript";
|
|
4
4
|
|
|
5
5
|
//#region code/frameworks/react-vite/.dts-emit/code/frameworks/react-vite/src/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Options of `@joshwooding/vite-plugin-react-docgen-typescript` 0.7 to 0.9, copied from its
|
|
8
|
+
* declarations. Its TypeScript 7.1 `native` mode is left out: Storybook uses the docgen server there.
|
|
9
|
+
*/
|
|
10
|
+
type ReactDocgenTypescriptOptions = ReactDocgenTypescriptParserOptions & {
|
|
11
|
+
docgenMode?: 'legacy' | 'project-service';
|
|
12
|
+
setDisplayName?: boolean;
|
|
13
|
+
typePropName?: string;
|
|
14
|
+
tsconfigPath?: string; /** TypeScript `CompilerOptions`. */
|
|
15
|
+
compilerOptions?: Record<string, any>;
|
|
16
|
+
exclude?: string[];
|
|
17
|
+
include?: string[];
|
|
18
|
+
fileSystemCache?: boolean | {
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
directory?: string;
|
|
21
|
+
};
|
|
22
|
+
EXPERIMENTAL_useWatchProgram?: boolean;
|
|
23
|
+
EXPERIMENTAL_useProjectService?: boolean;
|
|
24
|
+
};
|
|
6
25
|
type FrameworkName = CompatibleString<'@storybook/react-vite'>;
|
|
7
26
|
type BuilderName = CompatibleString<'@storybook/builder-vite'>;
|
|
8
27
|
type FrameworkOptions = {
|
|
@@ -42,11 +61,11 @@ type TypescriptOptions$1 = TypescriptOptions & {
|
|
|
42
61
|
*
|
|
43
62
|
* @deprecated Builder docgen is removed in Storybook 12. Use `features.docgenServer`.
|
|
44
63
|
*/
|
|
45
|
-
reactDocgenTypescriptOptions:
|
|
64
|
+
reactDocgenTypescriptOptions: ReactDocgenTypescriptOptions;
|
|
46
65
|
};
|
|
47
66
|
/** The interface for Storybook configuration in `main.ts` files. */
|
|
48
67
|
type StorybookConfig$1 = Omit<StorybookConfig, keyof StorybookConfigVite | keyof StorybookConfigFramework | 'typescript'> & StorybookConfigVite & StorybookConfigFramework & {
|
|
49
68
|
typescript?: Partial<TypescriptOptions$1>;
|
|
50
69
|
};
|
|
51
70
|
//#endregion
|
|
52
|
-
export { StorybookConfig$1 as
|
|
71
|
+
export { ReactDocgenTypescriptOptions as n, StorybookConfig$1 as r, FrameworkOptions as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as StorybookConfig, t as FrameworkOptions } from "./chunk
|
|
1
|
+
import { n as ReactDocgenTypescriptOptions, r as StorybookConfig, t as FrameworkOptions } from "./chunk-DzJdQ4En.js";
|
|
2
2
|
import { __definePreview as definePreview } from "@storybook/react";
|
|
3
3
|
export * from "@storybook/react";
|
|
4
|
-
export { FrameworkOptions, StorybookConfig, definePreview };
|
|
4
|
+
export { FrameworkOptions, ReactDocgenTypescriptOptions, StorybookConfig, definePreview };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as StorybookConfig } from "../chunk-DzJdQ4En.js";
|
|
2
2
|
|
|
3
3
|
//#region code/frameworks/react-vite/.dts-emit/code/frameworks/react-vite/src/node/index.d.ts
|
|
4
4
|
declare function defineMain(config: StorybookConfig): StorybookConfig;
|
package/dist/node/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_nzxf5xgjq2 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_nzxf5xgjq2 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_nzxf5xgjq2 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_nzxf5xgjq2.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_nzxf5xgjq2.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_nzxf5xgjq2.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
+
import "../_node-chunks/chunk-DWGDBIRG.js";
|
|
12
13
|
|
|
13
14
|
// src/node/index.ts
|
|
14
15
|
function defineMain(config) {
|
package/dist/preset.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as StorybookConfig$1 } from "./chunk-DzJdQ4En.js";
|
|
2
2
|
import { PresetProperty } from "storybook/internal/types";
|
|
3
3
|
|
|
4
4
|
//#region code/frameworks/react-vite/.dts-emit/code/frameworks/react-vite/src/preset.d.ts
|
package/dist/preset.js
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_nzxf5xgjq2 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_nzxf5xgjq2 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_nzxf5xgjq2 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_nzxf5xgjq2.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_nzxf5xgjq2.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_nzxf5xgjq2.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
+
import "./_node-chunks/chunk-DWGDBIRG.js";
|
|
12
13
|
|
|
13
14
|
// src/preset.ts
|
|
14
15
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "storybook/internal/
|
|
18
|
-
import { deprecate } from "storybook/internal/node-logger";
|
|
16
|
+
isReactBuilderDocgenPackageInstalled,
|
|
17
|
+
prepareReactBuilderDocgen
|
|
18
|
+
} from "@storybook/react/internal/builder-docgen";
|
|
19
19
|
var core = {
|
|
20
20
|
builder: import.meta.resolve("@storybook/builder-vite"),
|
|
21
21
|
renderer: import.meta.resolve("@storybook/react/preset")
|
|
22
|
-
}, viteFinal = async (config, options) => {
|
|
22
|
+
}, resolve = (specifier) => import.meta.resolve(specifier), viteFinal = async (config, options) => {
|
|
23
23
|
let { presets } = options;
|
|
24
24
|
if ((await presets.apply("features", {}))?.docgenServer)
|
|
25
25
|
return config;
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
35
|
-
|
|
26
|
+
let { reactDocgen: reactDocgenOption, reactDocgenTypescriptOptions } = await presets.apply("typescript", {});
|
|
27
|
+
if (typeof reactDocgenOption != "string")
|
|
28
|
+
return config;
|
|
29
|
+
let mode = await prepareReactBuilderDocgen({
|
|
30
|
+
reactDocgen: reactDocgenOption,
|
|
31
|
+
builder: "vite",
|
|
32
|
+
resolve,
|
|
33
|
+
options
|
|
34
|
+
});
|
|
35
|
+
if (!mode)
|
|
36
|
+
return config;
|
|
37
|
+
let useReactDocgenTypescript = mode === "react-docgen-typescript", plugins = [...config?.plugins ?? []];
|
|
36
38
|
if (useReactDocgenTypescript && plugins.push(
|
|
37
39
|
(await import("@joshwooding/vite-plugin-react-docgen-typescript")).default({
|
|
38
40
|
...reactDocgenTypescriptOptions,
|
|
39
41
|
// We *need* this set so that RDT returns default values in the same format as react-docgen
|
|
40
42
|
savePropValueAsString: !0
|
|
41
43
|
})
|
|
42
|
-
),
|
|
43
|
-
let { reactDocgen } = await import("./_node-chunks/react-docgen-
|
|
44
|
+
), !useReactDocgenTypescript || isReactBuilderDocgenPackageInstalled(resolve, "react-docgen")) {
|
|
45
|
+
let { reactDocgen } = await import("./_node-chunks/react-docgen-2UF7RHED.js");
|
|
44
46
|
plugins.unshift(
|
|
45
|
-
// react-docgen reads every file, except TypeScript files when react-docgen-typescript reads them
|
|
46
47
|
await reactDocgen({
|
|
47
48
|
include: useReactDocgenTypescript ? /\.(mjs|jsx?)$/ : /\.(mjs|tsx?|jsx?)$/
|
|
48
49
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-vite",
|
|
3
|
-
"version": "11.0.0-beta.
|
|
3
|
+
"version": "11.0.0-beta.1",
|
|
4
4
|
"description": "Storybook for React and Vite: Develop, document, and test UI components in isolation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -52,28 +52,41 @@
|
|
|
52
52
|
"!src/**/*"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@
|
|
55
|
+
"@storybook/builder-vite": "11.0.0-beta.1",
|
|
56
|
+
"@storybook/react": "11.0.0-beta.1"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@joshwooding/vite-plugin-react-docgen-typescript": "^0.9.0",
|
|
56
60
|
"@rollup/pluginutils": "^5.0.2",
|
|
57
|
-
"@
|
|
58
|
-
"@storybook/react": "11.0.0-beta.0",
|
|
59
|
-
"empathic": "^2.0.0",
|
|
61
|
+
"@types/node": "^22.19.1",
|
|
60
62
|
"magic-string": "^1.1.0",
|
|
61
63
|
"react-docgen": "^8.0.2",
|
|
62
64
|
"resolve": "^1.22.8",
|
|
63
|
-
"tsconfig-paths": "^4.2.0"
|
|
64
|
-
},
|
|
65
|
-
"devDependencies": {
|
|
66
|
-
"@types/node": "^22.19.1",
|
|
65
|
+
"tsconfig-paths": "^4.2.0",
|
|
67
66
|
"typescript": "^6.0.3",
|
|
68
67
|
"vite": "^7.0.4"
|
|
69
68
|
},
|
|
70
69
|
"peerDependencies": {
|
|
70
|
+
"@joshwooding/vite-plugin-react-docgen-typescript": "^0.7.0 || ^0.8.0 || ^0.9.0",
|
|
71
71
|
"react": "^18.0.0 || ^19.0.0",
|
|
72
|
+
"react-docgen": "^8.0.2",
|
|
73
|
+
"react-docgen-typescript": "^2.2.2",
|
|
72
74
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
73
|
-
"storybook": "^11.0.0-beta.
|
|
75
|
+
"storybook": "^11.0.0-beta.1",
|
|
74
76
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0",
|
|
75
77
|
"vite": "^6.3.0 || ^7.0.0 || ^8.0.0"
|
|
76
78
|
},
|
|
79
|
+
"peerDependenciesMeta": {
|
|
80
|
+
"@joshwooding/vite-plugin-react-docgen-typescript": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"react-docgen": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
86
|
+
"react-docgen-typescript": {
|
|
87
|
+
"optional": true
|
|
88
|
+
}
|
|
89
|
+
},
|
|
77
90
|
"publishConfig": {
|
|
78
91
|
"access": "public"
|
|
79
92
|
},
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
1
2
|
import { fn } from 'storybook/test';
|
|
2
3
|
|
|
3
4
|
import { Button } from './Button';
|
|
4
5
|
|
|
5
6
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
6
|
-
|
|
7
|
+
const meta = preview.meta({
|
|
7
8
|
title: 'Example/Button',
|
|
8
9
|
component: Button,
|
|
9
10
|
parameters: {
|
|
@@ -18,32 +19,32 @@ export default {
|
|
|
18
19
|
},
|
|
19
20
|
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args
|
|
20
21
|
args: { onClick: fn() },
|
|
21
|
-
};
|
|
22
|
+
});
|
|
22
23
|
|
|
23
24
|
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
24
|
-
export const Primary = {
|
|
25
|
+
export const Primary = meta.story({
|
|
25
26
|
args: {
|
|
26
27
|
primary: true,
|
|
27
28
|
label: 'Button',
|
|
28
29
|
},
|
|
29
|
-
};
|
|
30
|
+
});
|
|
30
31
|
|
|
31
|
-
export const Secondary = {
|
|
32
|
+
export const Secondary = meta.story({
|
|
32
33
|
args: {
|
|
33
34
|
label: 'Button',
|
|
34
35
|
},
|
|
35
|
-
};
|
|
36
|
+
});
|
|
36
37
|
|
|
37
|
-
export const Large = {
|
|
38
|
+
export const Large = meta.story({
|
|
38
39
|
args: {
|
|
39
40
|
size: 'large',
|
|
40
41
|
label: 'Button',
|
|
41
42
|
},
|
|
42
|
-
};
|
|
43
|
+
});
|
|
43
44
|
|
|
44
|
-
export const Small = {
|
|
45
|
+
export const Small = meta.story({
|
|
45
46
|
args: {
|
|
46
47
|
size: 'small',
|
|
47
48
|
label: 'Button',
|
|
48
49
|
},
|
|
49
|
-
};
|
|
50
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
1
2
|
import { fn } from 'storybook/test';
|
|
2
3
|
|
|
3
4
|
import { Header } from './Header';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
const meta = preview.meta({
|
|
6
7
|
title: 'Example/Header',
|
|
7
8
|
component: Header,
|
|
8
9
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
@@ -16,14 +17,14 @@ export default {
|
|
|
16
17
|
onLogout: fn(),
|
|
17
18
|
onCreateAccount: fn(),
|
|
18
19
|
},
|
|
19
|
-
};
|
|
20
|
+
});
|
|
20
21
|
|
|
21
|
-
export const LoggedIn = {
|
|
22
|
+
export const LoggedIn = meta.story({
|
|
22
23
|
args: {
|
|
23
24
|
user: {
|
|
24
25
|
name: 'Jane Doe',
|
|
25
26
|
},
|
|
26
27
|
},
|
|
27
|
-
};
|
|
28
|
+
});
|
|
28
29
|
|
|
29
|
-
export const LoggedOut =
|
|
30
|
+
export const LoggedOut = meta.story();
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
1
2
|
import { expect, userEvent, within } from 'storybook/test';
|
|
2
3
|
|
|
3
4
|
import { Page } from './Page';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
const meta = preview.meta({
|
|
6
7
|
title: 'Example/Page',
|
|
7
8
|
component: Page,
|
|
8
9
|
parameters: {
|
|
9
10
|
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
10
11
|
layout: 'fullscreen',
|
|
11
12
|
},
|
|
12
|
-
};
|
|
13
|
+
});
|
|
13
14
|
|
|
14
|
-
export const LoggedOut =
|
|
15
|
+
export const LoggedOut = meta.story();
|
|
15
16
|
|
|
16
17
|
// More on component testing: https://storybook.js.org/docs/writing-tests/interaction-testing
|
|
17
|
-
export const LoggedIn = {
|
|
18
|
+
export const LoggedIn = meta.story({
|
|
18
19
|
play: async ({ canvasElement }) => {
|
|
19
20
|
const canvas = within(canvasElement);
|
|
20
21
|
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
@@ -25,4 +26,4 @@ export const LoggedIn = {
|
|
|
25
26
|
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
26
27
|
await expect(logoutButton).toBeInTheDocument();
|
|
27
28
|
},
|
|
28
|
-
};
|
|
29
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
2
2
|
|
|
3
3
|
import { fn } from 'storybook/test';
|
|
4
4
|
|
|
5
5
|
import { Button } from './Button';
|
|
6
6
|
|
|
7
7
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
8
|
-
const meta = {
|
|
8
|
+
const meta = preview.meta({
|
|
9
9
|
title: 'Example/Button',
|
|
10
10
|
component: Button,
|
|
11
11
|
parameters: {
|
|
@@ -20,35 +20,32 @@ const meta = {
|
|
|
20
20
|
},
|
|
21
21
|
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args
|
|
22
22
|
args: { onClick: fn() },
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default meta;
|
|
26
|
-
type Story = StoryObj<typeof meta>;
|
|
23
|
+
});
|
|
27
24
|
|
|
28
25
|
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
29
|
-
export const Primary
|
|
26
|
+
export const Primary = meta.story({
|
|
30
27
|
args: {
|
|
31
28
|
primary: true,
|
|
32
29
|
label: 'Button',
|
|
33
30
|
},
|
|
34
|
-
};
|
|
31
|
+
});
|
|
35
32
|
|
|
36
|
-
export const Secondary
|
|
33
|
+
export const Secondary = meta.story({
|
|
37
34
|
args: {
|
|
38
35
|
label: 'Button',
|
|
39
36
|
},
|
|
40
|
-
};
|
|
37
|
+
});
|
|
41
38
|
|
|
42
|
-
export const Large
|
|
39
|
+
export const Large = meta.story({
|
|
43
40
|
args: {
|
|
44
41
|
size: 'large',
|
|
45
42
|
label: 'Button',
|
|
46
43
|
},
|
|
47
|
-
};
|
|
44
|
+
});
|
|
48
45
|
|
|
49
|
-
export const Small
|
|
46
|
+
export const Small = meta.story({
|
|
50
47
|
args: {
|
|
51
48
|
size: 'small',
|
|
52
49
|
label: 'Button',
|
|
53
50
|
},
|
|
54
|
-
};
|
|
51
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
2
2
|
|
|
3
3
|
import { fn } from 'storybook/test';
|
|
4
4
|
|
|
5
5
|
import { Header } from './Header';
|
|
6
6
|
|
|
7
|
-
const meta = {
|
|
7
|
+
const meta = preview.meta({
|
|
8
8
|
title: 'Example/Header',
|
|
9
9
|
component: Header,
|
|
10
10
|
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
@@ -18,17 +18,14 @@ const meta = {
|
|
|
18
18
|
onLogout: fn(),
|
|
19
19
|
onCreateAccount: fn(),
|
|
20
20
|
},
|
|
21
|
-
}
|
|
21
|
+
});
|
|
22
22
|
|
|
23
|
-
export
|
|
24
|
-
type Story = StoryObj<typeof meta>;
|
|
25
|
-
|
|
26
|
-
export const LoggedIn: Story = {
|
|
23
|
+
export const LoggedIn = meta.story({
|
|
27
24
|
args: {
|
|
28
25
|
user: {
|
|
29
26
|
name: 'Jane Doe',
|
|
30
27
|
},
|
|
31
28
|
},
|
|
32
|
-
};
|
|
29
|
+
});
|
|
33
30
|
|
|
34
|
-
export const LoggedOut
|
|
31
|
+
export const LoggedOut = meta.story();
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import preview from '../../.storybook/preview';
|
|
2
2
|
|
|
3
3
|
import { expect, userEvent, within } from 'storybook/test';
|
|
4
4
|
|
|
5
5
|
import { Page } from './Page';
|
|
6
6
|
|
|
7
|
-
const meta = {
|
|
7
|
+
const meta = preview.meta({
|
|
8
8
|
title: 'Example/Page',
|
|
9
9
|
component: Page,
|
|
10
10
|
parameters: {
|
|
11
11
|
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
12
12
|
layout: 'fullscreen',
|
|
13
13
|
},
|
|
14
|
-
}
|
|
14
|
+
});
|
|
15
15
|
|
|
16
|
-
export
|
|
17
|
-
type Story = StoryObj<typeof meta>;
|
|
18
|
-
|
|
19
|
-
export const LoggedOut: Story = {};
|
|
16
|
+
export const LoggedOut = meta.story();
|
|
20
17
|
|
|
21
18
|
// More on component testing: https://storybook.js.org/docs/writing-tests/interaction-testing
|
|
22
|
-
export const LoggedIn
|
|
19
|
+
export const LoggedIn = meta.story({
|
|
23
20
|
play: async ({ canvasElement }) => {
|
|
24
21
|
const canvas = within(canvasElement);
|
|
25
22
|
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
@@ -30,4 +27,4 @@ export const LoggedIn: Story = {
|
|
|
30
27
|
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
31
28
|
await expect(logoutButton).toBeInTheDocument();
|
|
32
29
|
},
|
|
33
|
-
};
|
|
30
|
+
});
|