-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Test: Introduce disable user event feature flag #33108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
valentinpalkovic
wants to merge
2
commits into
next
from
valentin/introduce-disable-user-event-feature-flag
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
177 changes: 0 additions & 177 deletions
177
code/core/src/component-testing/components/test-fn.stories.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
51 changes: 51 additions & 0 deletions
51
docs/_snippets/main-config-features-user-event-instrumentation.md
This file contains hidden or 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,51 @@ | ||
| ```js filename=".storybook/main.js" renderer="common" language="js" tabTitle="CSF 3" | ||
| export default { | ||
| // Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc. | ||
| framework: '@storybook/your-framework', | ||
| stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
| features: { | ||
| userEventSetup: false, | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| ```ts filename=".storybook/main.ts" renderer="common" language="ts" tabTitle="CSF 3" | ||
| // Replace your-framework with the framework you are using, e.g. react-vite, nextjs, vue3-vite, etc. | ||
| import type { StorybookConfig } from '@storybook/your-framework'; | ||
|
|
||
| const config: StorybookConfig = { | ||
| framework: '@storybook/your-framework', | ||
| stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
| features: { | ||
| userEventSetup: false, | ||
| }, | ||
| }; | ||
|
|
||
| export default config; | ||
| ``` | ||
|
|
||
| ```ts filename=".storybook/main.ts" renderer="react" language="ts" tabTitle="CSF Next 🧪" | ||
| // Replace your-framework with the framework you are using (e.g., react-vite, nextjs, nextjs-vite) | ||
| import { defineMain } from '@storybook/your-framework/node'; | ||
|
|
||
| export default defineMain({ | ||
| framework: '@storybook/your-framework', | ||
| stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
| features: { | ||
| userEventSetup: false, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| ```js filename=".storybook/main.js" renderer="react" language="js" tabTitle="CSF Next 🧪" | ||
| // Replace your-framework with the framework you are using (e.g., react-vite, nextjs, nextjs-vite) | ||
| import { defineMain } from '@storybook/your-framework/node'; | ||
|
|
||
| export default defineMain({ | ||
| framework: '@storybook/your-framework', | ||
| stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
| features: { | ||
| userEventSetup: false, | ||
| }, | ||
| }); | ||
| ``` |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Story-level
disableUserEventparameter is not consumed.The code defines
userEventDisabledbased solely on the global feature flagglobalThis?.FEATURES?.userEventSetup, but the story-level parameterparameters.test.disableUserEvent(defined at lines 163-164) is never checked or used in theenhanceContextfunction.The
UserEventDisabledstory intest-fn.stories.tsxsetsparameters: { test: { disableUserEvent: true } }and expectsuserEventto be undefined, but this won't work because the parameter is not being consumed.Apply this diff to check the story-level parameter:
const enhanceContext: LoaderFunction = async (context) => { if (globalThis.HTMLElement && context.canvasElement instanceof globalThis.HTMLElement) { context.canvas = within(context.canvasElement); } // userEvent.setup() cannot be called in non browser environment and will attempt to access window.navigator.clipboard // which will throw an error in react native for example. - const userEventDisabled = globalThis?.FEATURES?.userEventSetup === false; + const userEventDisabled = + globalThis?.FEATURES?.userEventSetup === false || + context.parameters?.test?.disableUserEvent === true; const clipboard = globalThis.window?.navigator?.clipboard; // TODO: Remove clipboard check in SB 11 if (!userEventDisabled && clipboard) {📝 Committable suggestion
🤖 Prompt for AI Agents