Skip to content

test(interaction-harness): openStory returns once Storybook has finished the story's render - #9772

Merged
cixzhang merged 1 commit into
mainfrom
harness/open-story-finished
Nov 3, 2026
Merged

cixzhang merged 1 commit into
mainfrom
harness/open-story-finished

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

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 openStory wait and its self-test. Both files are on main, so this pull request is that change alone, rebuilt on main.

Maintainer impact

openStory returned at the story's first render, while Storybook was still finishing it. Storybook waits out the story's animations (phase completing), runs afterEach, and only then reports the story finished (STORY_FINISHED, phase finished), 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 from openStory's return measured Storybook too.

Intended invariant

No product behavior change. This is test harness only.

Change

  • openStory also waits until __STORYBOOK_PREVIEW__.currentRender is this story at phase finished.
  • The self-test records every listener added to the document or the window from before Storybook loads. It checks that openStory returns at phase finished with 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

  • Failure before the change: on main's story.ts, the self-test fails in Chromium, returning at phase completing with listeners landing after the return.
  • Success after the change: the storybook self-test spec passes 6 of 6 (both tests, run 3 times) in Chromium.
  • Product/runtime behavior verified unchanged: harness only.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm test:interaction internal/interaction-harness/src/storybook.interaction.browser.spec.ts --project=chromium against a fresh Storybook build: 6 passed with --repeat-each=3, and red on main's story.ts. WebKit runs in CI.
  • Strict ESLint and Prettier on both files: pass.

…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>
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 3, 2026 4:44pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 3, 2026
@astracat-bot

astracat-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 4:55 PM UTC

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · ff6eb35

Storybook · Sandbox · built from this PR's head

Package size: no published package changed; no new dependencies.

API changes: none in this pull request

Committed API report behind this build: core 2 rows; run pnpm api:report.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 16:59
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 3, 2026
@cixzhang
cixzhang marked this pull request as draft November 3, 2026 17:03
@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 17:03
@cixzhang
cixzhang merged commit a24f7e0 into main Nov 3, 2026
126 of 158 checks passed
@github-actions
github-actions Bot deleted the harness/open-story-finished branch November 4, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — ff6eb356 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants