-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 #19659 from storybookjs/tom/sb-888-disable-play-fu…
…nctions-in-docs-if-not Disable play functions in docs mode, unless you set `parameters.docs.autoplay`
- Loading branch information
Showing
9 changed files
with
129 additions
and
6 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
33 changes: 33 additions & 0 deletions
33
code/addons/docs/template/stories/docspage/autoplay.stories.ts
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 globalThis from 'global'; | ||
import { expect } from '@storybook/jest'; | ||
import { within } from '@storybook/testing-library'; | ||
|
||
export default { | ||
component: globalThis.Components.Pre, | ||
tags: ['docsPage'], | ||
args: { text: 'Play has not run' }, | ||
parameters: { chromatic: { disable: true } }, | ||
}; | ||
|
||
// Should not autoplay | ||
export const NoAutoplay = { | ||
play: async ({ viewMode, canvasElement }) => { | ||
const pre = await within(canvasElement).findByText('Play has not run'); | ||
if (viewMode === 'docs') { | ||
pre.innerText = 'Play should not have run!'; | ||
// Sort of pointless | ||
expect(viewMode).not.toBe('docs'); | ||
} else { | ||
pre.innerText = 'Play has run'; | ||
} | ||
}, | ||
}; | ||
|
||
// Should autoplay | ||
export const Autoplay = { | ||
parameters: { docs: { autoplay: true } }, | ||
play: async ({ canvasElement }) => { | ||
const pre = await within(canvasElement).findByText('Play has not run'); | ||
pre.innerText = 'Play has run'; | ||
}, | ||
}; |
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
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