Skip to content

Commit 3f26fba

Browse files
authored
Merge pull request #31074 from storybookjs/jeppe/fix-coverage-run-all
Addon-vitest: Fix coverage being disabled with Run All button
2 parents f188ca8 + 79f6af6 commit 3f26fba

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

code/addons/vitest/src/components/TestProviderRender.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ import { addons } from 'storybook/manager-api';
1717
import type { API } from 'storybook/manager-api';
1818
import { styled } from 'storybook/theming';
1919

20-
import { A11Y_ADDON_ID, A11Y_PANEL_ID, COMPONENT_TESTING_PANEL_ID } from '../constants';
20+
import {
21+
A11Y_ADDON_ID,
22+
A11Y_PANEL_ID,
23+
COMPONENT_TESTING_PANEL_ID,
24+
FULL_RUN_TRIGGERS,
25+
} from '../constants';
2126
import type { StoreState } from '../types';
2227
import type { StatusValueToStoryIds } from '../use-test-provider-state';
2328
import { Description } from './Description';
@@ -322,7 +327,8 @@ export const TestProviderRender: FC<TestProviderRenderProps> = ({
322327
note={
323328
watching
324329
? 'Unavailable in watch mode'
325-
: currentRun.triggeredBy && currentRun.triggeredBy !== 'global'
330+
: currentRun.triggeredBy &&
331+
!FULL_RUN_TRIGGERS.includes(currentRun.triggeredBy)
326332
? 'Unavailable when running focused tests'
327333
: isRunning
328334
? 'Testing in progress'
@@ -335,7 +341,8 @@ export const TestProviderRender: FC<TestProviderRenderProps> = ({
335341
/>
336342
}
337343
>
338-
{watching || (currentRun.triggeredBy && currentRun.triggeredBy !== 'global') ? (
344+
{watching ||
345+
(currentRun.triggeredBy && !FULL_RUN_TRIGGERS.includes(currentRun.triggeredBy)) ? (
339346
<IconButton size="medium" disabled>
340347
<InfoIcon
341348
aria-label={

code/addons/vitest/src/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { StoreOptions } from 'storybook/internal/types';
22

3-
import type { StoreState } from './types';
3+
import type { RunTrigger, StoreState } from './types';
44

55
export { PANEL_ID as COMPONENT_TESTING_PANEL_ID } from '../../../core/src/component-testing/constants';
66
export {
@@ -66,6 +66,8 @@ export const storeOptions = {
6666
},
6767
} satisfies StoreOptions<StoreState>;
6868

69+
export const FULL_RUN_TRIGGERS: RunTrigger[] = ['global', 'run-all'] as const;
70+
6971
export const STORE_CHANNEL_EVENT_NAME = `UNIVERSAL_STORE:${storeOptions.id}`;
7072
export const STATUS_STORE_CHANNEL_EVENT_NAME = 'UNIVERSAL_STORE:storybook/status';
7173
export const TEST_PROVIDER_STORE_CHANNEL_EVENT_NAME = 'UNIVERSAL_STORE:storybook/test-provider';

0 commit comments

Comments
 (0)