-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storybook): interaction testing story generator React
- Loading branch information
Showing
11 changed files
with
111 additions
and
55 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
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
32 changes: 0 additions & 32 deletions
32
...ages/react/src/generators/component-story/files/__componentFileName__.stories.__fileExt__
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
.../react/src/generators/component-story/files/jsx/__componentFileName__.stories.jsx__tmpl__
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import componentName from './<%= componentImportFileName %>'; | ||
<% if ( interactionTests ) { %> | ||
import { within } from '@storybook/testing-library'; | ||
import { expect } from '@storybook/jest'; | ||
<% } %> | ||
|
||
export default { | ||
component: <%= componentName %>, | ||
title: '<%= componentName %>',<% if ( argTypes && argTypes.length > 0 ) { %> | ||
argTypes: {<% for (let argType of argTypes) { %> | ||
<%= argType.name %>: { <%- argType.type %> : "<%- argType.actionText %>" },<% } %> | ||
} | ||
<% } %> | ||
}; | ||
|
||
export const Primary = { | ||
args: {<% for (let prop of props) { %> | ||
<%= prop.name %>: <%- prop.defaultValue %>,<% } %> | ||
}, | ||
}; | ||
|
||
<% if ( interactionTests ) { %> | ||
export const Heading: Story = { | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
expect(canvas.getByText(/Welcome to <%=componentName%>!/gi)).toBeTruthy(); | ||
}, | ||
}; | ||
<% } %> |
33 changes: 33 additions & 0 deletions
33
.../react/src/generators/component-story/files/tsx/__componentFileName__.stories.tsx__tmpl__
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { <%= componentName %> } from './<%= componentImportFileName %>'; | ||
<% if ( interactionTests ) { %> | ||
import { within } from '@storybook/testing-library'; | ||
import { expect } from '@storybook/jest'; | ||
<% } %> | ||
|
||
const meta: Meta<typeof <%= componentName %>> = { | ||
component: <%= componentName %>, | ||
title: '<%= componentName %>',<% if ( argTypes && argTypes.length > 0 ) { %> | ||
argTypes: {<% for (let argType of argTypes) { %> | ||
<%= argType.name %>: { <%- argType.type %> : "<%- argType.actionText %>" },<% } %> | ||
} | ||
<% } %> | ||
}; | ||
export default meta; | ||
type Story = StoryObj<typeof <%= componentName %>>; | ||
|
||
|
||
export const Primary = { | ||
args: {<% for (let prop of props) { %> | ||
<%= prop.name %>: <%- prop.defaultValue %>,<% } %> | ||
}, | ||
}; | ||
|
||
<% if ( interactionTests ) { %> | ||
export const Heading: Story = { | ||
play: async ({ canvasElement }) => { | ||
const canvas = within(canvasElement); | ||
expect(canvas.getByText(/Welcome to <%=componentName%>!/gi)).toBeTruthy(); | ||
}, | ||
}; | ||
<% } %> |
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
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