-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from chromaui/test-status-3
Merge queue test example
- Loading branch information
Showing
5 changed files
with
528 additions
and
614 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,28 +12,28 @@ | |
"chromatic": "npx chromatic --project-token=b7e18a53b1f3 --only-changed --debug --trace-changed 'expanded' --exit-zero-on-changes --diagnostics --exit-once-uploaded --auto-accept-changes 'main'" | ||
}, | ||
"dependencies": { | ||
"chromatic": "10.2.2--canary.884.7480424995.0", | ||
"chromatic": "^11.0.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.18.13", | ||
"@storybook/addon-actions": "^7.6.7", | ||
"@storybook/addon-essentials": "^7.6.7", | ||
"@storybook/addon-interactions": "^7.6.7", | ||
"@storybook/addon-links": "^7.6.7", | ||
"@storybook/react": "^7.6.7", | ||
"@storybook/react-vite": "^7.6.7", | ||
"@storybook/test": "^7.6.7", | ||
"@storybook/addon-actions": "^7.6.12", | ||
"@storybook/addon-essentials": "^7.6.12", | ||
"@storybook/addon-interactions": "^7.6.12", | ||
"@storybook/addon-links": "^7.6.12", | ||
"@storybook/react": "^7.6.12", | ||
"@storybook/react-vite": "^7.6.12", | ||
"@storybook/test": "^7.6.12", | ||
"@types/react": "^18.0.17", | ||
"@types/react-dom": "^18.0.6", | ||
"@vitejs/plugin-react": "^2.0.1", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"babel-loader": "^8.2.5", | ||
"storybook": "^7.6.7", | ||
"storybook": "^7.6.12", | ||
"typescript": "^5.3.3", | ||
"vite": "^3.0.7", | ||
"vite-plugin-turbosnap": "^1.0.1", | ||
"vitest": "^1.1.3" | ||
"vite": "^5.0.12", | ||
"vite-plugin-turbosnap": "^1.0.3", | ||
"vitest": "^1.2.2" | ||
}, | ||
"readme": "ERROR: No README data found!", | ||
"_id": "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,51 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { within, userEvent } from '@storybook/test'; | ||
import { within, userEvent, fn, expect } from '@storybook/test'; | ||
import { Page } from './Page'; | ||
|
||
const meta: Meta<typeof Page> = { | ||
const meta = { | ||
title: 'Example/Page', | ||
component: Page, | ||
parameters: { | ||
// More on Story layout: https://storybook.js.org/docs/react/configure/story-layout | ||
layout: 'fullscreen', | ||
}, | ||
}; | ||
args: { | ||
onClick: fn(), | ||
onLogin: fn(), | ||
}, | ||
} satisfies Meta<typeof Page>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Page>; | ||
export const LoggedOut: Story = {}; | ||
type Story = StoryObj<typeof meta>; | ||
// export const LoggedOut: Story = {}; | ||
|
||
export const LoggedIn: Story = {}; | ||
export const LoggedIn: Story = { | ||
args: { | ||
user: { name: 'Test User' }, | ||
}, | ||
// play: async ({ args, canvasElement }) => { | ||
// const canvas = within(canvasElement); | ||
// const loginButton = await canvas.findByRole('button', { name: /Log in/i }); | ||
// await expect(loginButton).toBeInTheDocument(); | ||
|
||
// More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing | ||
LoggedIn.play = async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
const loginButton = await canvas.getByRole('button', { name: /Log in/i }); | ||
await userEvent.click(loginButton); | ||
// // const mockEvent = { preventDefault: fn() }; | ||
// userEvent.click(loginButton); | ||
// await expect(args.onLogin).toHaveBeenCalled(); | ||
// // expect(mockEvent.preventDefault).toBeCalled(); | ||
// // const clickHyperlink = createEvent.click(loginButton); | ||
// // const isPrevented = fireEvent(loginButton, clickHyperlink); | ||
// // expect(clickHyperlink.defaultPrevented).toBe(true); | ||
// // expect(isPrevented).toBe(false); | ||
// // await userEvent.click(clickHyperlink); | ||
// }, | ||
}; | ||
|
||
// // More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing | ||
// LoggedIn.play = async ({ canvasElement }) => { | ||
// const canvas = within(canvasElement); | ||
// const loginButton = await canvas.getByRole('button', { name: /Log out/i }); | ||
// const clickHyperlink = createEvent.click(loginButton); | ||
// fireEvent(loginButton, clickHyperlink); | ||
// // await userEvent.click(clickHyperlink); | ||
// }; |
Oops, something went wrong.