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 / Addon Test: Support intercepting and modifying internal test provider state updates #29680

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Nov 21, 2024

What I did

Replaces mapStatusUpdate with a stateUpdater callback function, which is called whenever the internal test provider state is about to be updated, and is supposed to return the new state value. It can also be used to trigger side-effects based on the state update, such as calling experimental_updateStatus, addNotification etc.

stateUpdater?: (
  state: TestProviderConfig & Addon_TestProviderState<Details>,
  update: Partial<Addon_TestProviderState<Details>>
) => Partial<TestProviderConfig & Addon_TestProviderState<Details>>;

This change is needed to support coverage reporting which needs to merge the details property, but we cannot safely do that by default.

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

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 78.4 MB 78.4 MB 0 B -0.61 0%
initSize 144 MB 144 MB 228 B -0.9 0%
diffSize 65.1 MB 65.1 MB 228 B -0.68 0%
buildSize 6.83 MB 6.83 MB -70 B -0.84 0%
buildSbAddonsSize 1.51 MB 1.51 MB 0 B - 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB -70 B -0.86 0%
buildSbPreviewSize 271 kB 271 kB 0 B - 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.83 MB 3.83 MB -70 B -0.86 0%
buildPreviewSize 3 MB 3 MB 0 B 0.77 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 8.3s 21.1s 12.7s 0.66 60.2%
generateTime 22.4s 20s -2s -418ms -0.39 -12.1%
initTime 16.4s 14.1s -2s -295ms -0.47 -16.3%
buildTime 7.3s 7.3s -47ms -1.56 -0.6%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.4s 6.1s 609ms 0.44 10%
devManagerResponsive 3.3s 3.7s 457ms 0.62 12.1%
devManagerHeaderVisible 566ms 684ms 118ms 1.87 🔺17.3%
devManagerIndexVisible 639ms 787ms 148ms 1.88 🔺18.8%
devStoryVisibleUncached 636ms 1.1s 556ms 0.84 46.6%
devStoryVisible 637ms 782ms 145ms 2.07 🔺18.5%
devAutodocsVisible 508ms 473ms -35ms -0.71 -7.4%
devMDXVisible 535ms 541ms 6ms 0.38 1.1%
buildManagerHeaderVisible 561ms 640ms 79ms 1.36 🔺12.3%
buildManagerIndexVisible 582ms 660ms 78ms 1.35 🔺11.8%
buildStoryVisible 560ms 639ms 79ms 1.34 🔺12.4%
buildAutodocsVisible 502ms 511ms 9ms 0.61 1.8%
buildMDXVisible 412ms 462ms 50ms 0.2 10.8%

Greptile Summary

Here's my review of the pull request:

Replaces mapStatusUpdate with a new stateUpdater callback function across test provider modules, enabling more flexible state management and side effect handling for test results.

  • Added stateUpdater callback in code/core/src/types/modules/addons.ts that receives current state and update to return modified state
  • Modified updateTestProviderState in code/core/src/manager-api/modules/experimental_testmodule.ts to support state interception via stateUpdater
  • Updated test addon in code/addons/test/src/manager.tsx to use stateUpdater for handling test results and status updates
  • Simplified state handling in code/core/src/manager/components/sidebar/SidebarBottom.tsx by removing separate status mapping

…odifying the internal test provider state updates
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.

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

code/addons/test/src/manager.tsx Show resolved Hide resolved
Copy link

nx-cloud bot commented Nov 21, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit b86bc64. 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 1 target

Sent with 💌 from NxCloud.

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