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

Types: Fix typing issues in addon-test #30164

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

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Jan 2, 2025

Closes #

What I did

  • I amended the types tovallow for TestResult.results.status to be undefined in types, which the runtime seems to support.

TypeScript was convinced that this could never happen, and so provided an error.

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.8 MB 77.8 MB 0 B 2.27 0%
initSize 133 MB 133 MB 0 B -0.73 0%
diffSize 55.3 MB 55.3 MB 0 B -0.73 0%
buildSize 7.19 MB 7.19 MB 0 B -1.18 0%
buildSbAddonsSize 1.85 MB 1.85 MB 0 B -1.19 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.87 MB 1.87 MB 0 B 0.88 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.91 MB 3.91 MB 0 B -1.18 0%
buildPreviewSize 3.28 MB 3.28 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 7s 6.6s -357ms -0.7 -5.4%
generateTime 19.7s 19.4s -278ms -0.57 -1.4%
initTime 13.2s 13.8s 629ms -0.27 4.5%
buildTime 9.4s 10s 574ms 0.49 5.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.5s 4.6s 75ms -0.82 1.6%
devManagerResponsive 3.3s 3.4s 46ms -0.9 1.3%
devManagerHeaderVisible 558ms 574ms 16ms -0.53 2.8%
devManagerIndexVisible 569ms 586ms 17ms -0.62 2.9%
devStoryVisibleUncached 1.9s 946ms -982ms -4.26 🔰-103.8%
devStoryVisible 588ms 605ms 17ms -0.58 2.8%
devAutodocsVisible 534ms 492ms -42ms -0.85 -8.5%
devMDXVisible 459ms 518ms 59ms -0.38 11.4%
buildManagerHeaderVisible 548ms 563ms 15ms -0.54 2.7%
buildManagerIndexVisible 687ms 645ms -42ms -0.55 -6.5%
buildStoryVisible 536ms 544ms 8ms -0.6 1.5%
buildAutodocsVisible 427ms 423ms -4ms -1.07 -0.9%
buildMDXVisible 423ms 423ms 0ms -0.97 0%

Greptile Summary

Based on the provided files, I'll create a concise summary of the changes in this PR:

Fixes typing issues in addon-test module by allowing undefined status values in TestResultResult type, aligning TypeScript types with existing runtime behavior.

  • Modified TestResultResult type in reporter.ts to support undefined status for failed/warning states
  • Added 'unknown' status handling in TestProviderRender.tsx status mapping and sorting logic
  • Updated status mapping in manager.tsx to properly handle undefined test result statuses
  • Added proper type handling for accessibility test results in status updates
  • Several @ts-expect-error comments remain that should be addressed properly

The changes appear focused on type definitions rather than runtime behavior changes, making the types match what the code already supports. The key files modified are in the addon-test module and primarily affect type checking rather than functionality.

@ndelangen ndelangen changed the title Tfix typescript issues in addon-test Types: Fix typing issues in addon-test Jan 2, 2025
@ndelangen ndelangen self-assigned this Jan 2, 2025
Copy link

nx-cloud bot commented Jan 2, 2025

View your CI Pipeline Execution ↗ for commit 7308107.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 36s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-02 11:12:38 UTC

@ndelangen ndelangen marked this pull request as ready for review January 2, 2025 11:16
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.

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

Comment on lines +200 to +201
statusOrder.indexOf(a.status || state.running ? 'pending' : 'unknown') -
statusOrder.indexOf(b.status || state.running ? 'pending' : 'unknown')
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: operator precedence issue - parentheses needed around ternary to avoid incorrect evaluation

Copy link
Member

Choose a reason for hiding this comment

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

I suggest extracting state.running ? 'pending' : 'unknown' to a variable for clarity and because it's used twice. This would avoid the need for parenthesis.

@ndelangen ndelangen requested a review from ghengeveld January 3, 2025 08:41
@ndelangen
Copy link
Member Author

I'll open a alternative PR to unblock next. I am confused as to why the code is now showing failure and success at the same time.

@ghengeveld can you please visit this, and ensure all the types are accurate? Please remove the // @ts-expect-error: TODO: Fix types, as they are likely an indicator things aren't correct. I'll be happy to assist.

@ndelangen ndelangen assigned ghengeveld and unassigned ndelangen Jan 3, 2025
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