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

Progress reporting for Testing Module #29311

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Oct 9, 2024

Closes #29262

What I did

Adds progress reporting to addon-test and updates Testing Module to handle progress updates.

Screen.Recording.2024-10-09.at.15.17.59.mov

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 pull request has been released as version 0.0.0-pr-29311-sha-c4d3ed03. Try it out in a new sandbox by running npx [email protected] sandbox or in an existing project with npx [email protected] upgrade.

More information
Published version 0.0.0-pr-29311-sha-c4d3ed03
Triggered by @ghengeveld
Repository storybookjs/storybook
Branch ui-testing-progress
Commit c4d3ed03
Datetime Wed Oct 9 13:58:54 UTC 2024 (1728482334)
Workflow run 11256540412

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=29311

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 78.7 MB 78.7 MB 0 B 1.01 0%
initSize 147 MB 147 MB 2.62 kB -2.35 0%
diffSize 68.3 MB 68.3 MB 2.62 kB -2.32 0%
buildSize 7.09 MB 7.09 MB 2.58 kB -0.99 0%
buildSbAddonsSize 1.78 MB 1.78 MB 871 B -1.13 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.85 MB 1.85 MB 1.74 kB -1.11 0.1%
buildSbPreviewSize 271 kB 271 kB -29 B -1.16 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.09 MB 4.1 MB 2.58 kB -1.13 0.1%
buildPreviewSize 3 MB 3 MB 0 B 2.44 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 20.6s 13.8s -6s -750ms -0.56 -48.6%
generateTime 19.4s 20.2s 794ms 0.01 3.9%
initTime 13.3s 13.1s -218ms -1.72 -1.7%
buildTime 8.8s 8.7s -40ms -1.01 -0.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 6.2s 6.5s 359ms -0.12 5.5%
devManagerResponsive 4.1s 4.2s 123ms -0.11 2.9%
devManagerHeaderVisible 595ms 609ms 14ms 0.1 2.3%
devManagerIndexVisible 619ms 641ms 22ms 0.02 3.4%
devStoryVisibleUncached 903ms 1s 148ms -0.41 14.1%
devStoryVisible 627ms 640ms 13ms -0.01 2%
devAutodocsVisible 534ms 589ms 55ms 0.38 9.3%
devMDXVisible 535ms 552ms 17ms 0.24 3.1%
buildManagerHeaderVisible 600ms 538ms -62ms -0.65 -11.5%
buildManagerIndexVisible 606ms 618ms 12ms 0.71 1.9%
buildStoryVisible 641ms 614ms -27ms 0.07 -4.4%
buildAutodocsVisible 529ms 496ms -33ms -0.65 -6.7%
buildMDXVisible 579ms 533ms -46ms 0.29 -8.6%

Greptile Summary

This PR adds progress reporting functionality to the Testing Module in Storybook, enhancing its ability to handle and display test status updates.

  • Implemented new TestingModuleProgressReportPayload type for detailed progress reporting
  • Updated SidebarBottom and TestingModule components to handle and display real-time test status
  • Added support for cancellable tests and watch mode in the UI
  • Improved error handling and logging in the test runner process
  • Replaced TESTING_MODULE_RUN_PROGRESS_RESPONSE with TESTING_MODULE_PROGRESS_REPORT event

@ghengeveld ghengeveld marked this pull request as ready for review October 9, 2024 13:15
Copy link

nx-cloud bot commented Oct 9, 2024

☁️ Nx Cloud Report

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

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.

13 file(s) reviewed, 9 comment(s)
Edit PR Review Bot Settings

Comment on lines +34 to +38
const statusMap: Record<any['status'], API_StatusValue> = {
failed: 'error',
passed: 'success',
pending: 'pending',
};
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using a more specific type for the status key instead of 'any'

pending: 'pending',
};

export function getRelativeTimeString(date: Date): string {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This function could be moved to a separate utility file for better organization

});

title: ({ failed }) => (failed ? "Component tests didn't complete" : 'Component tests'),
description: ({ failed, running, watching, progress }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This function is quite long and complex. Consider breaking it down into smaller, more focused functions

return 'Not run';
},

mapStatusUpdate: (state) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This complex mapping function could benefit from additional comments explaining its logic

.filter(Boolean)
)
),
} as Addon_TestProviderType<{ testResults: TestResult[] }>);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The use of 'as' for type assertion should be avoided when possible. Consider using a type guard instead

@@ -24,6 +26,7 @@ const vitestModulePath = join(__dirname, 'node', 'vitest.mjs');
export const bootTestRunner = async (channel: Channel, initEvent?: string, initArgs?: any[]) => {
let aborted = false;
let child: null | ChildProcess;
let stderr: string[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider initializing stderr as const to prevent accidental reassignment

Comment on lines 64 to 70
child.stderr?.on('data', (data) => {
const message = data.toString();
// TODO: improve this error handling. Example use case is Playwright is not installed
if (message.includes('Error: browserType.launch')) {
channel.emit(TESTING_MODULE_CRASH_REPORT, message);
// Ignore deprecation warnings which appear in yellow ANSI color
if (!data.toString().match(/^\u001B\[33m/)) {
log(data);
stderr.push(data.toString());
}

log(data);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The stderr handling logic could be moved to a separate function for better readability

}

log(data);
});

child.on('message', (result: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using a switch statement for better readability of the message handling logic

Comment on lines +184 to +189
const { mapStatusUpdate, ...state } = testProviders[providerId];
const statusUpdate = mapStatusUpdate?.({ ...state, ...update });
if (statusUpdate) {
api.experimental_updateStatus(providerId, statusUpdate);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider moving this logic to a separate function for better readability

);

useEffect(() => {
const wrapper = document.getElementById('sidebar-bottom');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use a const for the id and reuse it in the sidebar for the sidebar-bottom element as well?

@valentinpalkovic
Copy link
Contributor

I just looked at the code, though. As soon as it is testable, let's thoroughly test the base PR.

@yannbf
Copy link
Member

yannbf commented Oct 9, 2024

Feedback:
The red solid border should only be shown on global errors
image

@valentinpalkovic valentinpalkovic merged commit 4dc91e6 into unified-ui-testing Oct 10, 2024
55 of 60 checks passed
@valentinpalkovic valentinpalkovic deleted the ui-testing-progress branch October 10, 2024 13:49
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