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 A11y: Update accessibility status handling in TestProviderRender #30027

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
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
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
Loading