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 3 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 1.1 0%
initSize 131 MB 131 MB 0 B 0.08 0%
diffSize 52.9 MB 52.9 MB 0 B -2 0%
buildSize 7.19 MB 7.19 MB 0 B -1.98 0%
buildSbAddonsSize 1.85 MB 1.85 MB 0 B -2 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.87 MB 1.87 MB 0 B -2 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.91 MB 3.91 MB 0 B -2 0%
buildPreviewSize 3.28 MB 3.28 MB 0 B 2.38 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 6.8s 6.7s -125ms -0.93 -1.9%
generateTime 19.3s 25.8s 6.4s 3.63 🔺24.9%
initTime 12.7s 15.6s 2.9s 1.32 🔺18.6%
buildTime 9.3s 9s -320ms -0.59 -3.6%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 6s 6.2s 252ms 2.1 4%
devManagerResponsive 4.3s 4.5s 222ms 2.12 4.9%
devManagerHeaderVisible 998ms 535ms -463ms -1.12 -86.5%
devManagerIndexVisible 1s 544ms -503ms -1.42 🔰-92.5%
devStoryVisibleUncached 2.2s 1.5s -745ms -1.24 🔰-48.7%
devStoryVisible 1s 568ms -469ms -1.23 -82.6%
devAutodocsVisible 858ms 659ms -199ms 0.74 -30.2%
devMDXVisible 779ms 526ms -253ms -0.5 -48.1%
buildManagerHeaderVisible 801ms 585ms -216ms -0.28 -36.9%
buildManagerIndexVisible 818ms 674ms -144ms -0.25 -21.4%
buildStoryVisible 792ms 566ms -226ms -0.32 -39.9%
buildAutodocsVisible 612ms 493ms -119ms 0.19 -24.1%
buildMDXVisible 614ms 504ms -110ms 0.42 -21.8%

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 99c6b71.

Command Status Duration Result
nx affected -t check -c production --parallel=7 ❌ Failed 5s View ↗
nx run-many -t build -c production --parallel=3 ✅ Succeeded 14s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-13 10:07:00 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