Skip to content
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

Core: Track test provider state in sessionStorage #29450

Merged
merged 5 commits into from
Oct 30, 2024

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Oct 25, 2024

Keeps state for the Testing Module in sessionStorage so that it survives browser refreshes and stays in sync with story statuses (which are also kept in sessionStorage).

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

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

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/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 canary-release-pr.yml --field pr=<PR_NUMBER>

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 0 B 0.96 0%
initSize 143 MB 143 MB 198 B -0.9 0%
diffSize 65.1 MB 65.1 MB 198 B -0.9 0%
buildSize 6.87 MB 6.87 MB 198 B 1.01 0%
buildSbAddonsSize 1.51 MB 1.51 MB 0 B 0.92 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.9 MB 1.9 MB 198 B 1.01 0%
buildSbPreviewSize 271 kB 271 kB 0 B - 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.88 MB 3.88 MB 198 B 1.01 0%
buildPreviewSize 3 MB 3 MB 0 B - 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 22.1s 13.6s -8s -485ms -0.03 -62.3%
generateTime 19.4s 25.6s 6.1s 1.42 🔺24.1%
initTime 13.7s 17.6s 3.9s 0.92 22.1%
buildTime 8.9s 7.7s -1s -239ms -1.78 🔰-16.1%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 6.6s 7.3s 651ms 0.37 8.9%
devManagerResponsive 4.2s 4.4s 198ms 0 4.4%
devManagerHeaderVisible 593ms 770ms 177ms 1.12 23%
devManagerIndexVisible 621ms 852ms 231ms 1.09 27.1%
devStoryVisibleUncached 1.2s 1.4s 215ms 1.06 14.4%
devStoryVisible 620ms 847ms 227ms 1.09 26.8%
devAutodocsVisible 541ms 645ms 104ms 0.41 16.1%
devMDXVisible 593ms 622ms 29ms 0.3 4.7%
buildManagerHeaderVisible 667ms 669ms 2ms 0.44 0.3%
buildManagerIndexVisible 696ms 684ms -12ms 0.39 -1.8%
buildStoryVisible 669ms 668ms -1ms 0.44 -0.1%
buildAutodocsVisible 518ms 617ms 99ms 0.97 16%
buildMDXVisible 495ms 489ms -6ms -0.39 -1.2%

Greptile Summary

Added sessionStorage persistence for the Testing Module state in the Storybook sidebar to maintain test provider state across browser refreshes and sync with story statuses.

  • Added sessionStorage initialization in SidebarBottom.tsx using STORAGE_KEY = '@storybook/manager/test-providers'
  • Implemented state persistence through updateTestProvider callback that updates both React state and sessionStorage
  • Added storage cleanup in clearState function when tests are rerun
  • Added error handling for JSON parsing of stored state during initialization

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

nx-cloud bot commented Oct 25, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 80a4687. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@ghengeveld ghengeveld merged commit 42a7c6c into next Oct 30, 2024
59 checks passed
@ghengeveld ghengeveld deleted the testing-module-session-storage branch October 30, 2024 11:13
@github-actions github-actions bot mentioned this pull request Oct 30, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants