From 67bf4f6e1ae0cf9db94c4965aa99639f4e47fd81 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Wed, 11 Dec 2024 13:26:00 +0100 Subject: [PATCH] Addon A11y: Update accessibility status handling in TestProviderRender --- .../test/src/components/TestProviderRender.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/code/addons/test/src/components/TestProviderRender.tsx b/code/addons/test/src/components/TestProviderRender.tsx index 017ecc2cf27f..d84ea249cdd6 100644 --- a/code/addons/test/src/components/TestProviderRender.tsx +++ b/code/addons/test/src/components/TestProviderRender.tsx @@ -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'; } @@ -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' @@ -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);