Docs: Add e2e test for useArgs inside a Stories block#35037
Docs: Add e2e test for useArgs inside a Stories block#35037TheSeydiCharyyev wants to merge 5 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a reusable React Storybook story that uses useArgs to set dynamic ChangesuseArgs Regression Test
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@code/e2e-tests/addon-docs.spec.ts`:
- Around line 176-186: The test is racy because awaiting storiesB.click()
doesn't guarantee async updateArgs (channel.emit(UPDATE_STORY_ARGS) →
Preview.onUpdateArgs) has finished before primary.click(); after calling
storiesB.click() add a deterministic "settled" gate that waits for the args
propagation to complete (for example await a channel/ack event, await a stable
DOM change tied to the updated args, or await a Preview.onUpdateArgs completion
signal) before calling primary.click(); reference the existing update flow
(updateArgs, UPDATE_STORY_ARGS, Preview.onUpdateArgs) and ensure the new wait
causes the test to fail on the pre-fix commit.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ddb91f00-caf5-4c2f-b10d-d47327dd71c1
📒 Files selected for processing (2)
code/e2e-tests/addon-docs.spec.tscode/renderers/react/template/stories/use-args.stories.tsx
Sidnioulz
left a comment
There was a problem hiding this comment.
Thanks @TheSeydiCharyyev! I don't think I've seen E2E tests before where we attempt to monitor or mock SB internals. Our goal for E2E tests is specifically to avoid doing these things so we catch broader issues as seen by end users (e.g. maybe what's emitted on the channel won't be how ArgsTable updates in a future major version).
Could you please check if there's another way to do this? Thanks!
0d29c72 to
891e565
Compare
|
Force pushing to your branch to resolve merge conflicts! |
What I did
Adds an end-to-end regression test for #28333 —
useArgscalled from a story rendered inside a<Stories>block used to update the page's primary story instead of the story it was called from. The bug no longer reproduces onnext, so this guards against a regression.renderers/react/template/stories/use-args.stories.tsx: a controlled component that updates its ownvaluearg throughuseArgs, with two stories (StoryA,StoryB) shown on the autodocs page.e2e-tests/addon-docs.spec.ts(React sandboxes only): triggeringupdateArgsfrom Story B inside the<Stories>block must route the update to Story B, not the primary story. The<Stories>renders are static snapshots, so the test asserts on thestoryIdof theUPDATE_STORY_ARGSchannel event — deterministic, and a direct check of which story the update targets.Invited by @Sidnioulz in #28333.
Manual testing
Against a
react-vite/default-tssandbox (yarn storybookin the sandbox, then fromcode/):Or open the
stories/renderers/react/use-argsautodocs page: clicking the Story B button in the<Stories>block updates Story B's args, leaving the primary story untouched.Closes #28333
Summary by CodeRabbit
Documentation
Tests