diff --git a/code/frameworks/angular/template/cli/Page.stories.ts b/code/frameworks/angular/template/cli/Page.stories.ts index e7f3c0e9a3b6..9d751ca18cb7 100644 --- a/code/frameworks/angular/template/cli/Page.stories.ts +++ b/code/frameworks/angular/template/cli/Page.stories.ts @@ -1,7 +1,7 @@ import type { Meta, StoryObj } from '@storybook/angular'; import { moduleMetadata } from '@storybook/angular'; -import { within, userEvent } from '@storybook/testing-library'; import { CommonModule } from '@angular/common'; +import { within, userEvent, expect } from '@storybook/test'; import Button from './button.component'; import Header from './header.component'; @@ -41,6 +41,13 @@ export const LoggedIn: Story = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/frameworks/nextjs/template/cli/js/Page.stories.js b/code/frameworks/nextjs/template/cli/js/Page.stories.js index 5bd1d6eba765..84ab959afa1d 100644 --- a/code/frameworks/nextjs/template/cli/js/Page.stories.js +++ b/code/frameworks/nextjs/template/cli/js/Page.stories.js @@ -1,4 +1,4 @@ -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { Page } from './Page'; export default { @@ -19,6 +19,13 @@ export const LoggedIn = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/frameworks/nextjs/template/cli/ts-3-8/Page.stories.ts b/code/frameworks/nextjs/template/cli/ts-3-8/Page.stories.ts index 0e48941ab149..3f319abbf9b9 100644 --- a/code/frameworks/nextjs/template/cli/ts-3-8/Page.stories.ts +++ b/code/frameworks/nextjs/template/cli/ts-3-8/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { Page } from './Page'; @@ -24,6 +24,13 @@ export const LoggedIn: Story = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/frameworks/nextjs/template/cli/ts-4-9/Page.stories.ts b/code/frameworks/nextjs/template/cli/ts-4-9/Page.stories.ts index 69852a2bdc00..307fc90db7c3 100644 --- a/code/frameworks/nextjs/template/cli/ts-4-9/Page.stories.ts +++ b/code/frameworks/nextjs/template/cli/ts-4-9/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { Page } from './Page'; @@ -24,6 +24,13 @@ export const LoggedIn: Story = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/lib/cli/src/generators/baseGenerator.ts b/code/lib/cli/src/generators/baseGenerator.ts index 48b2f8affd5b..a7bdb1764668 100644 --- a/code/lib/cli/src/generators/baseGenerator.ts +++ b/code/lib/cli/src/generators/baseGenerator.ts @@ -251,7 +251,14 @@ export async function baseGenerator( if (hasInteractiveStories(rendererId)) { addons.push('@storybook/addon-interactions'); - addonPackages.push('@storybook/addon-interactions', '@storybook/testing-library@^0.2.0-next.0'); + addonPackages.push('@storybook/addon-interactions'); + + // TODO: migrate template stories in solid and qwik to use @storybook/test + if (['solid', 'qwik'].includes(rendererId)) { + addonPackages.push('@storybook/testing-library'); + } else { + addonPackages.push('@storybook/test'); + } } const files = await fse.readdir(process.cwd()); diff --git a/code/renderers/html/template/cli/js/Page.stories.js b/code/renderers/html/template/cli/js/Page.stories.js index a80a4c4a9d24..120f07681696 100644 --- a/code/renderers/html/template/cli/js/Page.stories.js +++ b/code/renderers/html/template/cli/js/Page.stories.js @@ -1,4 +1,4 @@ -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { createPage } from './Page'; export default { @@ -19,6 +19,13 @@ export const LoggedIn = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/html/template/cli/ts-3-8/Page.stories.ts b/code/renderers/html/template/cli/ts-3-8/Page.stories.ts index 04b893f795fc..ceacaf6c12c9 100644 --- a/code/renderers/html/template/cli/ts-3-8/Page.stories.ts +++ b/code/renderers/html/template/cli/ts-3-8/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/html'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { createPage } from './Page'; const meta: Meta = { @@ -22,6 +22,13 @@ export const LoggedIn: StoryObj = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/html/template/cli/ts-4-9/Page.stories.ts b/code/renderers/html/template/cli/ts-4-9/Page.stories.ts index 6de6300e49a0..436435bb69fe 100644 --- a/code/renderers/html/template/cli/ts-4-9/Page.stories.ts +++ b/code/renderers/html/template/cli/ts-4-9/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/html'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { createPage } from './Page'; const meta = { @@ -22,6 +22,13 @@ export const LoggedIn: StoryObj = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/preact/template/cli/Page.stories.jsx b/code/renderers/preact/template/cli/Page.stories.jsx index d49ca397aaee..f5a5dd3c333f 100644 --- a/code/renderers/preact/template/cli/Page.stories.jsx +++ b/code/renderers/preact/template/cli/Page.stories.jsx @@ -1,4 +1,4 @@ -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { Page } from './Page'; @@ -20,6 +20,13 @@ export const LoggedIn = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/react/template/cli/js/Page.stories.js b/code/renderers/react/template/cli/js/Page.stories.js index 7467c98cf48a..f839ec1ada96 100644 --- a/code/renderers/react/template/cli/js/Page.stories.js +++ b/code/renderers/react/template/cli/js/Page.stories.js @@ -1,4 +1,4 @@ -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { Page } from './Page'; @@ -20,6 +20,13 @@ export const LoggedIn = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/react/template/cli/ts-3-8/Page.stories.ts b/code/renderers/react/template/cli/ts-3-8/Page.stories.ts index 52c4cb406233..7bf85faefe95 100644 --- a/code/renderers/react/template/cli/ts-3-8/Page.stories.ts +++ b/code/renderers/react/template/cli/ts-3-8/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { Page } from './Page'; @@ -24,6 +24,13 @@ export const LoggedIn: Story = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/react/template/cli/ts-4-9/Page.stories.ts b/code/renderers/react/template/cli/ts-4-9/Page.stories.ts index 69852a2bdc00..307fc90db7c3 100644 --- a/code/renderers/react/template/cli/ts-4-9/Page.stories.ts +++ b/code/renderers/react/template/cli/ts-4-9/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/react'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import { Page } from './Page'; @@ -24,6 +24,13 @@ export const LoggedIn: Story = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/svelte/template/cli/js/Page.stories.js b/code/renderers/svelte/template/cli/js/Page.stories.js index 9c6008b4c705..d72b78c5ce9e 100644 --- a/code/renderers/svelte/template/cli/js/Page.stories.js +++ b/code/renderers/svelte/template/cli/js/Page.stories.js @@ -1,4 +1,4 @@ -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import Page from './Page.svelte'; @@ -20,6 +20,13 @@ export const LoggedIn = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/svelte/template/cli/ts-3-8/Page.stories.ts b/code/renderers/svelte/template/cli/ts-3-8/Page.stories.ts index 3aba1302bf24..6596fe91c6e7 100644 --- a/code/renderers/svelte/template/cli/ts-3-8/Page.stories.ts +++ b/code/renderers/svelte/template/cli/ts-3-8/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/svelte'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import Page from './Page.svelte'; @@ -24,6 +24,13 @@ export const LoggedIn: Story = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/svelte/template/cli/ts-4-9/Page.stories.ts b/code/renderers/svelte/template/cli/ts-4-9/Page.stories.ts index 78665a28bfae..434e0f19865a 100644 --- a/code/renderers/svelte/template/cli/ts-4-9/Page.stories.ts +++ b/code/renderers/svelte/template/cli/ts-4-9/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/svelte'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import Page from './Page.svelte'; @@ -24,6 +24,13 @@ export const LoggedIn: Story = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/vue/template/cli/Page.stories.js b/code/renderers/vue/template/cli/Page.stories.js index 8bd022352948..9dbb953e19ee 100644 --- a/code/renderers/vue/template/cli/Page.stories.js +++ b/code/renderers/vue/template/cli/Page.stories.js @@ -1,4 +1,4 @@ -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import MyPage from './Page.vue'; export default { @@ -22,6 +22,13 @@ export const LoggedIn = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/vue3/template/cli/js/Page.stories.js b/code/renderers/vue3/template/cli/js/Page.stories.js index f11ff44e5bdf..bb8d599f5ab8 100644 --- a/code/renderers/vue3/template/cli/js/Page.stories.js +++ b/code/renderers/vue3/template/cli/js/Page.stories.js @@ -1,4 +1,4 @@ -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import MyPage from './Page.vue'; export default { @@ -25,6 +25,13 @@ export const LoggedIn = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/vue3/template/cli/ts-3-8/Page.stories.ts b/code/renderers/vue3/template/cli/ts-3-8/Page.stories.ts index 1ac73cf4433d..6302490699ae 100644 --- a/code/renderers/vue3/template/cli/ts-3-8/Page.stories.ts +++ b/code/renderers/vue3/template/cli/ts-3-8/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/vue3'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import MyPage from './Page.vue'; const meta: Meta = { @@ -27,7 +27,14 @@ export const LoggedIn: Story = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, }; diff --git a/code/renderers/vue3/template/cli/ts-4-9/Page.stories.ts b/code/renderers/vue3/template/cli/ts-4-9/Page.stories.ts index e9988015819d..e72ad9467508 100644 --- a/code/renderers/vue3/template/cli/ts-4-9/Page.stories.ts +++ b/code/renderers/vue3/template/cli/ts-4-9/Page.stories.ts @@ -1,5 +1,5 @@ import type { Meta, StoryObj } from '@storybook/vue3'; -import { within, userEvent } from '@storybook/testing-library'; +import { within, userEvent, expect } from '@storybook/test'; import MyPage from './Page.vue'; const meta = { @@ -27,7 +27,14 @@ export const LoggedIn: Story = { const loginButton = await canvas.getByRole('button', { name: /Log in/i, }); + await expect(loginButton).toBeInTheDocument(); await userEvent.click(loginButton); + await expect(loginButton).not.toBeInTheDocument(); + + const logoutButton = await canvas.getByRole('button', { + name: /Log out/i, + }); + await expect(logoutButton).toBeInTheDocument(); }, };