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: Clear coverage data when starting or watching #30072

Merged
merged 19 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e1f59e9
Clear coverageSummary when disabling the coverage feature
ghengeveld Dec 13, 2024
51ab99b
Build: Add text suggestions for incorrect task names
yannbf Dec 13, 2024
77f94d9
Update exclude details
kylegach Dec 13, 2024
39259b3
Remove mention of Vitest prompting of coverage support pkgs
kylegach Dec 13, 2024
25545c2
Write changelog for 8.5.0-alpha.22 [skip ci]
storybook-bot Dec 13, 2024
7ef7a0e
Bump version from "8.5.0-alpha.21" to "8.5.0-alpha.22" [skip ci]
storybook-bot Dec 13, 2024
b57db9e
Build: Improve waiting detection on E2E to fix flake
yannbf Dec 13, 2024
a57336a
add deps optimization in react kitchen sink
yannbf Dec 13, 2024
a48c774
improve story loading
yannbf Dec 13, 2024
87daadd
Refactor addonA11yAddonTest to improve setup file transformation and …
valentinpalkovic Dec 13, 2024
fe9fc42
Build: Refactor e2e test for composition to make it more stable
valentinpalkovic Dec 15, 2024
377493e
Build: Update GitHub Actions workflow to set fetch-depth for improved…
valentinpalkovic Dec 15, 2024
6180caa
Build: Add verbose flag to compile commands for better output clarity
valentinpalkovic Dec 15, 2024
86a5191
Update NX
valentinpalkovic Dec 15, 2024
861c7c3
NX: Use legacy cache
valentinpalkovic Dec 15, 2024
8622881
Remove verbose flag from nx build commands
valentinpalkovic Dec 15, 2024
cf1e4a7
Next.js: Support v15.1
valentinpalkovic Dec 15, 2024
0ca7b7c
Clear coverageSummary when starting test run or enabling watch mode
ghengeveld Dec 16, 2024
fc703e2
Merge branch 'next' into clear-coverage-on-start
ghengeveld Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 64 additions & 53 deletions code/addons/test/src/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,64 +73,75 @@ addons.register(ADDON_ID, (api) => {
},

stateUpdater: (state, update) => {
if (!update.details?.testResults) {
return;
const updated = {
...state,
...update,
details: { ...state.details, ...update.details },
};

if ((!state.running && update.running) || (!state.watching && update.watching)) {
// Clear coverage data when starting test run or enabling watch mode
delete updated.details.coverageSummary;
}
ghengeveld marked this conversation as resolved.
Show resolved Hide resolved
ghengeveld marked this conversation as resolved.
Show resolved Hide resolved

(async () => {
await api.experimental_updateStatus(
TEST_PROVIDER_ID,
Object.fromEntries(
update.details.testResults.flatMap((testResult) =>
testResult.results
.filter(({ storyId }) => storyId)
.map(({ storyId, status, testRunId, ...rest }) => [
storyId,
{
title: 'Component tests',
status: statusMap[status],
description:
'failureMessages' in rest && rest.failureMessages
? rest.failureMessages.join('\n')
: '',
data: { testRunId },
onClick: openTestsPanel,
sidebarContextMenu: false,
} satisfies API_StatusObject,
])
if (update.details?.testResults) {
(async () => {
await api.experimental_updateStatus(
TEST_PROVIDER_ID,
Object.fromEntries(
update.details.testResults.flatMap((testResult) =>
testResult.results
.filter(({ storyId }) => storyId)
.map(({ storyId, status, testRunId, ...rest }) => [
storyId,
{
title: 'Component tests',
status: statusMap[status],
description:
'failureMessages' in rest && rest.failureMessages
? rest.failureMessages.join('\n')
: '',
data: { testRunId },
onClick: openTestsPanel,
sidebarContextMenu: false,
} satisfies API_StatusObject,
])
)
)
)
);
);

await api.experimental_updateStatus(
'storybook/addon-a11y/test-provider',
Object.fromEntries(
update.details.testResults.flatMap((testResult) =>
testResult.results
.filter(({ storyId }) => storyId)
.map(({ storyId, testRunId, reports }) => {
const a11yReport = reports.find((r: any) => r.type === 'a11y');
return [
storyId,
a11yReport
? ({
title: 'Accessibility tests',
description: '',
status: statusMap[a11yReport.status],
data: { testRunId },
onClick: () => {
api.setSelectedPanel('storybook/a11y/panel');
api.togglePanel(true);
},
sidebarContextMenu: false,
} satisfies API_StatusObject)
: null,
];
})
await api.experimental_updateStatus(
'storybook/addon-a11y/test-provider',
Object.fromEntries(
update.details.testResults.flatMap((testResult) =>
testResult.results
.filter(({ storyId }) => storyId)
.map(({ storyId, testRunId, reports }) => {
const a11yReport = reports.find((r: any) => r.type === 'a11y');
ghengeveld marked this conversation as resolved.
Show resolved Hide resolved
return [
storyId,
a11yReport
? ({
title: 'Accessibility tests',
description: '',
status: statusMap[a11yReport.status],
data: { testRunId },
onClick: () => {
api.setSelectedPanel('storybook/a11y/panel');
api.togglePanel(true);
},
sidebarContextMenu: false,
} satisfies API_StatusObject)
: null,
];
})
)
)
)
);
})();
);
})();
}

return updated;
},
} as Addon_TestProviderType<Details, Config>);
}
Expand Down
Loading