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

Addon Test: Add support for previewHead #29808

Merged
merged 10 commits into from
Dec 10, 2024

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Dec 4, 2024

Closes #29776
Closes: #29775

What I did

  • hoist the preset creation up
  • load the preview-head.html (and related) files and replace content in vite's html file

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 77.7 MB 77.7 MB 0 B -0.29 0%
initSize 133 MB 133 MB 3 kB 2.62 0%
diffSize 55.1 MB 55.1 MB 3 kB 2.61 0%
buildSize 6.87 MB 6.87 MB 0 B 0.89 0%
buildSbAddonsSize 1.51 MB 1.51 MB 0 B 2.65 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 0 B 2.64 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.57 MB 3.57 MB 0 B 2.64 0%
buildPreviewSize 3.3 MB 3.3 MB 0 B 0.82 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.7s 7.5s -1s -200ms -0.87 -15.8%
generateTime 24.5s 21.8s -2s -679ms 0.19 -12.2%
initTime 14.4s 16.7s 2.3s 1.2 14.1%
buildTime 8.8s 8.1s -694ms -1.37 🔰-8.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.5s 4.7s 144ms -0.5 3.1%
devManagerResponsive 3.5s 3.6s 60ms -0.14 1.7%
devManagerHeaderVisible 467ms 535ms 68ms -0.38 12.7%
devManagerIndexVisible 494ms 565ms 71ms -0.64 12.6%
devStoryVisibleUncached 970ms 1.7s 786ms 0.25 44.8%
devStoryVisible 537ms 566ms 29ms -0.95 5.1%
devAutodocsVisible 430ms 458ms 28ms -1.04 6.1%
devMDXVisible 435ms 492ms 57ms -0.36 11.6%
buildManagerHeaderVisible 513ms 493ms -20ms -1.25 -4.1%
buildManagerIndexVisible 588ms 588ms 0ms -1.07 0%
buildStoryVisible 464ms 459ms -5ms -1.15 -1.1%
buildAutodocsVisible 406ms 381ms -25ms -0.97 -6.6%
buildMDXVisible 375ms 382ms 7ms -1.09 1.8%

Greptile Summary

Enhanced Vitest plugin to support custom HTML injection from Storybook's preview-head.html and preview-body.html files, along with programmatic preview head/body modifications via main.js configuration.

  • Added support for previewHead and previewBody configuration in code/addons/test/src/vitest-plugin/index.ts
  • Implemented transformIndexHtml hook to inject HTML snippets from Storybook presets
  • Fixed critical bug where HTML transformations were not being assigned back to html parameter
  • Hoisted preset creation for better configuration management
  • Added support for environment-specific script injection through main.js configuration

@ndelangen ndelangen changed the title add support for preview-head.html files from storybook AddonTest: Add support for preview-head.html Dec 4, 2024
@ndelangen ndelangen self-assigned this Dec 4, 2024
Copy link

nx-cloud bot commented Dec 4, 2024

☁️ Nx Cloud Report

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

@ndelangen ndelangen changed the title AddonTest: Add support for preview-head.html AddonTest: Add support for previewHead Dec 4, 2024
@ndelangen ndelangen marked this pull request as ready for review December 4, 2024 13:57
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, 1 comment(s)
Edit PR Review Bot Settings | Greptile

code/addons/test/src/vitest-plugin/index.ts Outdated Show resolved Hide resolved
@ndelangen ndelangen requested a review from ghengeveld December 9, 2024 12:16
…rybookjs/storybook into norbert/vitest-support-preview-html
…rybookjs/storybook into norbert/vitest-support-preview-html
Base automatically changed from norbert/custom-vitest-config-support to next December 10, 2024 12:54
@JReinhold JReinhold merged commit cf80d5c into next Dec 10, 2024
54 of 56 checks passed
@JReinhold JReinhold deleted the norbert/vitest-support-preview-html branch December 10, 2024 12:55
@github-actions github-actions bot mentioned this pull request Dec 10, 2024
11 tasks
@shilman shilman changed the title AddonTest: Add support for previewHead Addon Test: Add support for previewHead Dec 10, 2024
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.

[Bug] HTML Injection ignored by vitest plugin [Bug] Vitest Plugin ignores custom scripts in preview config
3 participants