Skip to content

Commit

Permalink
Merge pull request #30027 from storybookjs/valentin/do-not-show-state…
Browse files Browse the repository at this point in the history
…-while-running

Addon A11y: Update accessibility status handling in TestProviderRender
  • Loading branch information
valentinpalkovic authored Dec 11, 2024
2 parents ed64194 + 67bf4f6 commit 7b56f57
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions code/addons/test/src/components/TestProviderRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export const TestProviderRender: FC<
}, [isA11yAddon, state.details?.testResults, entryId]);

const a11yStatus = useMemo<'positive' | 'warning' | 'negative' | 'unknown'>(() => {
if (state.running) {
return 'unknown';
}

if (!isA11yAddon || config.a11y === false) {
return 'unknown';
}
Expand All @@ -136,7 +140,7 @@ export const TestProviderRender: FC<
}

return 'positive';
}, [a11yResults, isA11yAddon, config.a11y]);
}, [state.running, isA11yAddon, config.a11y, a11yResults]);

const a11yNotPassedAmount = a11yResults?.filter(
(result) => result?.status === 'failed' || result?.status === 'warning'
Expand All @@ -154,7 +158,11 @@ export const TestProviderRender: FC<
})
.sort((a, b) => statusOrder.indexOf(a.status) - statusOrder.indexOf(b.status));

const status = (state.failed ? 'failed' : results[0]?.status) || 'unknown';
const status = state.running
? 'unknown'
: state.failed
? 'failed'
: (results[0]?.status ?? 'unknown');

const openPanel = (id: string, panelId: string) => {
api.selectStory(id);
Expand Down

0 comments on commit 7b56f57

Please sign in to comment.