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: Add config UI to Testing Module #29708

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

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Nov 26, 2024

What I did

Added a settings/config view to the Testing Module for the Test addon, which allows toggling coverage and a11y tests:

Screen.Recording.2024-11-26.at.09.38.48.mov

Whenever config is updated, the testing module briefly glows green.

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 -2.38 0%
initSize 143 MB 143 MB -1.43 kB -2.37 0%
diffSize 65.2 MB 65.2 MB -1.43 kB 2.04 0%
buildSize 6.83 MB 6.83 MB -543 B 0.08 0%
buildSbAddonsSize 1.51 MB 1.51 MB -211 B 0 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB -203 B 0.04 0%
buildSbPreviewSize 271 kB 271 kB -147 B 0.03 -0.1%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.84 MB 3.83 MB -561 B 0.04 0%
buildPreviewSize 3 MB 3 MB 18 B 4.56 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 27.6s 25.4s -2s -225ms 1.34 🔰-8.7%
generateTime 19.8s 23s 3.2s 1.82 🔺13.9%
initTime 13.6s 17.8s 4.1s 2.34 🔺23.4%
buildTime 9.4s 7.8s -1s -603ms -0.82 -20.5%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 5.5s 5.6s 139ms -0.35 2.5%
devManagerResponsive 3.4s 3.5s 84ms -0.26 2.3%
devManagerHeaderVisible 586ms 635ms 49ms -0.01 7.7%
devManagerIndexVisible 609ms 725ms 116ms 0.12 16%
devStoryVisibleUncached 1s 959ms -65ms -0.31 -6.8%
devStoryVisible 608ms 722ms 114ms 0.16 15.8%
devAutodocsVisible 501ms 675ms 174ms 0.72 25.8%
devMDXVisible 550ms 648ms 98ms 0.25 15.1%
buildManagerHeaderVisible 538ms 517ms -21ms -0.56 -4.1%
buildManagerIndexVisible 554ms 526ms -28ms -0.6 -5.3%
buildStoryVisible 537ms 518ms -19ms -0.55 -3.7%
buildAutodocsVisible 418ms 539ms 121ms 0.16 22.4%
buildMDXVisible 411ms 412ms 1ms -0.68 0.2%

Greptile Summary

Added settings UI to the Testing Module in Storybook's test addon, enabling users to toggle coverage and accessibility testing options with visual feedback for configuration changes.

  • Added TestProviderRender component with settings panel UI and state management in /code/addons/test/src/components/TestProviderRender.tsx
  • Added TestStatusIcon component in /code/addons/test/src/components/TestStatusIcon.tsx for visual status indicators with percentage display
  • Modified ListItem component in /code/core/src/components/components/tooltip/ListItem.tsx to support label elements for settings UI
  • Added config change animation feedback in /code/core/src/manager/components/sidebar/TestingModule.tsx with proper cleanup
  • Fixed potential memory leak by cleaning up event listeners and timeouts in TestingModule component

💡 (2/5) Greptile learns from your feedback when you react with 👍/👎!

@ghengeveld ghengeveld changed the base branch from next to norbert/testmodule-options November 26, 2024 08:43
@ghengeveld ghengeveld changed the title Core / Addon Test: Add settings view to Testing Module Core / Addon Test: Add config UI to Testing Module Nov 26, 2024
Copy link

nx-cloud bot commented Nov 26, 2024

☁️ Nx Cloud Report

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

Sent with 💌 from NxCloud.

@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Nov 26, 2024

Package Benchmarks

Commit: 2f3ec95, ran on 26 November 2024 at 14:43:06 UTC

No significant changes detected, all good. 👏

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.

19 file(s) reviewed, 9 comment(s)
Edit PR Review Bot Settings | Greptile

code/addons/test/src/components/TestProviderRender.tsx Outdated Show resolved Hide resolved
@@ -47,8 +48,6 @@ addons.register(ADDON_ID, (api) => {
return <ContextMenuItem context={context} state={state} />;
},

render: (state) => <TestProviderRender api={api} state={state} />,

mapStatusUpdate: (state) =>
Object.fromEntries(
(state.details.testResults || []).flatMap((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: flatMap().map().filter(Boolean) chain could be simplified to just flatMap with proper return type handling

),
...baseState,
watching: true,
},
];

let triggerUpdate: () => void;
const channel = mockChannel();
const managerContext: 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: avoid using 'any' type - consider creating proper type definition for managerContext

Comment on lines +125 to +127
const button = await canvas.findByRole('button', { name: /Expand/ });
await fireEvent.click(button);
await new Promise((resolve) => setTimeout(resolve, 500));
Copy link
Contributor

Choose a reason for hiding this comment

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

style: using regex for button text matching is fragile - consider using a more specific selector or data-testid

),
...baseState,
watching: true,
},
];

let triggerUpdate: () => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: triggerUpdate is mutable and could lead to race conditions in tests - consider using a more robust pattern

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.

9 file(s) reviewed, 5 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +7 to +15
({ percentage }) => ({
width: percentage ? 12 : 6,
height: percentage ? 12 : 6,
margin: percentage ? 1 : 4,
background: percentage
? `conic-gradient(var(--status-color) ${percentage}%, var(--status-background) ${percentage + 1}%)`
: 'var(--status-color)',
borderRadius: '50%',
}),
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 CSS custom properties for dimensions (width, height, margin) to make the component more maintainable and configurable

: 'var(--status-color)',
borderRadius: '50%',
}),
({ status, theme }) =>
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 or object literal for status color mapping to avoid repetitive code blocks

Comment on lines 177 to 188
useEffect(() => {
let timeout: NodeJS.Timeout;
const handler = () => {
setUpdated(true);
timeout = setTimeout(setUpdated, 1000, false);
};
api.on(TESTING_MODULE_CONFIG_CHANGE, handler);
return () => {
api.off(TESTING_MODULE_CONFIG_CHANGE, handler);
clearTimeout(timeout);
};
}, [api]);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: potential memory leak if component unmounts during the 1000ms timeout - consider using AbortController or similar for cleaner cancellation

Comment on lines 213 to 215
display: testing ? 'block' : 'none',
maxHeight: collapsed ? 0 : maxHeight,
maxHeight: collapsed ? 0 : animating ? maxHeight : 'auto',
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

style: maxHeight transition can cause layout shift when content height changes while expanded - consider using CSS height: auto with transition

backgroundColor: `var(--sb-sidebar-bottom-card-background, ${theme.background.content})`,
borderRadius:
`var(--sb-sidebar-bottom-card-border-radius, ${theme.appBorderRadius + 1}px)` as any,
boxShadow: `inset 0 0 0 1px ${crashed && !running ? theme.color.negative : updated ? theme.color.positive : theme.appBorderColor}, var(--sb-sidebar-bottom-card-box-shadow, 0 1px 2px 0 rgba(0, 0, 0, 0.05), 0px -5px 20px 10px ${theme.background.app})`,
Copy link
Contributor

Choose a reason for hiding this comment

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

style: long line with complex template literal makes code hard to maintain - consider breaking into multiple lines or variables

Base automatically changed from norbert/testmodule-options to next November 26, 2024 13:04
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.

1 participant