Skip to content

Commit

Permalink
Addon A11y: Update accessibility status handling in TestProviderRender
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Dec 11, 2024
1 parent 48d1d42 commit 67bf4f6
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 67bf4f6

Please sign in to comment.