Skip to content

Docs: Add test proving scroll is reset across nav#34973

Merged
Sidnioulz merged 2 commits into
nextfrom
sidnioulz/e2e-test-scroll-reset
Jun 8, 2026
Merged

Docs: Add test proving scroll is reset across nav#34973
Sidnioulz merged 2 commits into
nextfrom
sidnioulz/e2e-test-scroll-reset

Conversation

@Sidnioulz

@Sidnioulz Sidnioulz commented May 29, 2026

Copy link
Copy Markdown
Contributor

Confirms #12497 is fixed

What I did

Added e2e test proving that when you navigate to a new docs page, scroll position gets reset.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Run e2e test suite or wait for CI.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Tests
    • Added an end-to-end test that verifies the documentation preview resets its scroll position when navigating between docs pages via the sidebar. This ensures consistent behavior and prevents unexpected scroll carryover when switching pages, improving reliability of docs navigation and the user experience when browsing different documentation entries.

Copilot AI review requested due to automatic review settings May 29, 2026 13:03
@Sidnioulz Sidnioulz added addon: docs build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs). labels May 29, 2026
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5a640448-ed76-4d35-be5e-e7363c43e039

📥 Commits

Reviewing files that changed from the base of the PR and between 28c385f and d571fa0.

📒 Files selected for processing (1)
  • code/e2e-sandbox/addon-docs.spec.ts
💤 Files with no reviewable changes (1)
  • code/e2e-sandbox/addon-docs.spec.ts

📝 Walkthrough

Walkthrough

Added a Playwright E2E test that scrolls the docs preview iframe, navigates to another docs story via the sidebar, and verifies the iframe's scroll position resets to zero.

Changes

Docs Preview Scroll Reset Verification

Layer / File(s) Summary
Scroll position reset test
code/e2e-sandbox/addon-docs.spec.ts
Test scrolls the docs preview iframe to a large scrollTop, confirms scrolling occurred via expect.poll, navigates to another docs story, and verifies scrollTop resets to 0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • storybookjs/storybook#35021: The new test verifies scroll reset behavior on docs navigation, which directly exercises the prepareForDocs({ scrollReset }) logic that resets scroll only on story/view navigation rather than HMR.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI 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.

Pull request overview

Adds an end-to-end regression test to confirm that navigating between Docs pages resets the preview iframe’s scroll position (covering the behavior reported in #12497).

Changes:

  • Add Playwright e2e test that scrolls a long Docs page, navigates to another Docs entry via the sidebar, and asserts scroll resets to top.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread code/e2e-sandbox/addon-docs.spec.ts Outdated
@storybook-app-bot

storybook-app-bot Bot commented May 29, 2026

Copy link
Copy Markdown

Package Benchmarks

Commit: d571fa0, ran on 5 June 2026 at 19:02:58 UTC

The following packages have significant changes to their size or dependencies:

storybook

Before After Difference
Dependency count 74 74 0
Self size 20.43 MB 20.40 MB 🎉 -26 KB 🎉
Dependency size 36.65 MB 36.65 MB 0 B
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 205 205 0
Self size 908 KB 908 KB 🎉 -144 B 🎉
Dependency size 89.16 MB 89.13 MB 🎉 -26 KB 🎉
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 198 198 0
Self size 32 KB 32 KB 🚨 +36 B 🚨
Dependency size 87.65 MB 87.62 MB 🎉 -26 KB 🎉
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 75 75 0
Self size 1.08 MB 1.08 MB 0 B
Dependency size 57.08 MB 57.05 MB 🎉 -26 KB 🎉
Bundle Size Analyzer node node

@Sidnioulz Sidnioulz force-pushed the sidnioulz/e2e-test-scroll-reset branch from 4066755 to 28c385f Compare June 5, 2026 12:51
@Sidnioulz Sidnioulz enabled auto-merge June 5, 2026 12:51

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
code/e2e-sandbox/addon-docs.spec.ts (1)

293-293: ⚡ Quick win

Remove redundant page navigation.

The beforeEach hook at line 14 already navigates to storybookUrl. This duplicate navigation is unnecessary and adds latency to the test. Other tests in this file (e.g., lines 28-29, 49-50, 76-77) create a new SbPage instance without re-navigating.

♻️ Proposed fix
   test('should reset scroll position between pages', async ({ page }) => {
-    await page.goto(storybookUrl);
     const sbPage = new SbPage(page, expect);
🤖 Prompt for 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.

In `@code/e2e-sandbox/addon-docs.spec.ts` at line 293, Remove the redundant
navigation call by deleting the await page.goto(storybookUrl); statement in the
test; rely on the existing beforeEach navigation to storybookUrl and instantiate
SbPage (or use the existing page variable) without re-calling page.goto — locate
the statement referencing page.goto(storybookUrl) in the test and remove it so
the test uses the prior beforeEach setup.
🤖 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.

Nitpick comments:
In `@code/e2e-sandbox/addon-docs.spec.ts`:
- Line 293: Remove the redundant navigation call by deleting the await
page.goto(storybookUrl); statement in the test; rely on the existing beforeEach
navigation to storybookUrl and instantiate SbPage (or use the existing page
variable) without re-calling page.goto — locate the statement referencing
page.goto(storybookUrl) in the test and remove it so the test uses the prior
beforeEach setup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bef3855e-3870-42fd-bd5a-7969e113394f

📥 Commits

Reviewing files that changed from the base of the PR and between 4066755 and 28c385f.

📒 Files selected for processing (1)
  • code/e2e-sandbox/addon-docs.spec.ts

@Sidnioulz Sidnioulz disabled auto-merge June 5, 2026 18:45
@Sidnioulz Sidnioulz added the qa:skip Pull Requests that do not need any QA. label Jun 5, 2026
Comment thread code/e2e-sandbox/addon-docs.spec.ts Outdated
@Sidnioulz Sidnioulz merged commit 07163ba into next Jun 8, 2026
143 checks passed
@Sidnioulz Sidnioulz deleted the sidnioulz/e2e-test-scroll-reset branch June 8, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addon: docs build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs). qa:skip Pull Requests that do not need any QA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants