Repository navigation
test(interaction-harness): openStory returns once Storybook has finished the story's render - #9772
Conversation
…hed the story's render openStory also waits until __STORYBOOK_PREVIEW__.currentRender is this story at phase finished, so a proof measuring from its return no longer measures Storybook's post-render tail. The self-test records listeners added to the document and the window and checks that none lands after openStory returns, over a window longer than that tail (two frames and 300 ms). Rebuilt on main from the pull request's own change. Co-authored-by: Cindy Zhang <cindyxz@meta.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
This looks ready to approve.
openStory now returns only once Storybook reports the story's render finished. The new self-test fails against main's story.ts (phase completing, with a late document pointermove listener) and passes with this change. The specs that call openStory still pass in Chromium. Nothing else is needed.
[Automated review]
Supersedes #8913 by @vjeux, who stays the author of this commit. #8913's branch carries all of the open #8360, about 27,300 lines, while its own change is the
openStorywait and its self-test. Both files are onmain, so this pull request is that change alone, rebuilt onmain.Maintainer impact
openStoryreturned at the story's first render, while Storybook was still finishing it. Storybook waits out the story's animations (phasecompleting), runsafterEach, and only then reports the story finished (STORY_FINISHED, phasefinished), about 150 ms later. Its decorators' effects, a listener on the document among them, landed inside a proof's first measurement window, so a proof measuring fromopenStory's return measured Storybook too.Intended invariant
No product behavior change. This is test harness only.
Change
openStoryalso waits until__STORYBOOK_PREVIEW__.currentRenderis this story at phasefinished.openStoryreturns at phasefinishedwith no listener landing after it, over two frames and 300 ms, which is longer than Storybook's post-render tail. CodeBunny noted on test(interaction-harness): openStory returns once Storybook has finished the story's render #8913 that two frames and a task was shorter than that tail; with the wider window, the late-listener check catches a regression on its own.Evidence
main'sstory.ts, the self-test fails in Chromium, returning at phasecompletingwith listeners landing after the return.Scope
Testing
pnpm test:interaction internal/interaction-harness/src/storybook.interaction.browser.spec.ts --project=chromiumagainst a fresh Storybook build: 6 passed with--repeat-each=3, and red onmain'sstory.ts. WebKit runs in CI.