diff --git a/config/jest-config-ibm-cloud-cognitive/setup/matchers/toHaveNoAxeViolations.js b/config/jest-config-ibm-cloud-cognitive/setup/matchers/toHaveNoAxeViolations.js index fd78502248..184abf141c 100644 --- a/config/jest-config-ibm-cloud-cognitive/setup/matchers/toHaveNoAxeViolations.js +++ b/config/jest-config-ibm-cloud-cognitive/setup/matchers/toHaveNoAxeViolations.js @@ -1,5 +1,5 @@ /** - * Copyright IBM Corp. 2020, 2020 + * Copyright IBM Corp. 2020, 2024 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. @@ -29,33 +29,22 @@ const defaultOptions = { }, }; -function toHaveNoAxeViolations(node, options = {}) { - return new Promise((resolve) => { - axe.run( - node, - { - ...defaultOptions, - ...options, - }, - (error, result) => { - if (error) { - throw error; - } +async function toHaveNoAxeViolations(node, options = {}) { + const result = await axe.run(node, { + ...defaultOptions, + ...options, + }); - if (result.violations.length > 0) { - resolve({ - message: () => formatOutput(result.violations), - pass: false, - }); - return; - } + if (result.violations.length > 0) { + return { + message: () => formatOutput(result.violations), + pass: false, + }; + } - resolve({ - pass: true, - }); - } - ); - }); + return { + pass: true, + }; } function formatOutput(violations) { diff --git a/packages/ibm-products/src/components/AboutModal/AboutModal.test.js b/packages/ibm-products/src/components/AboutModal/AboutModal.test.js index 2f0add463a..1a61d5daad 100644 --- a/packages/ibm-products/src/components/AboutModal/AboutModal.test.js +++ b/packages/ibm-products/src/components/AboutModal/AboutModal.test.js @@ -1,5 +1,5 @@ /** - * Copyright IBM Corp. 2021, 2021 + * Copyright IBM Corp. 2021, 2024 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. @@ -93,17 +93,16 @@ describe(componentName, () => { expect(screen.getByRole('presentation')).toHaveClass(blockClass); }); - // Currently fails due to https://github.com/carbon-design-system/carbon/issues/14135 regarding focusable button - it.skip('has no accessibility violations when closed', async () => { + it('has no accessibility violations when closed', async () => { const { container } = renderComponent({ open: false }); - expect(container).toBeAccessible(`${componentName} closed`); - expect(container).toHaveNoAxeViolations(); + await expect(container).toBeAccessible(`${componentName} closed`); + await expect(container).toHaveNoAxeViolations(); }); it('has no accessibility violations', async () => { const { container } = renderComponent({ open: true }); - expect(container).toBeAccessible(componentName); - expect(container).toHaveNoAxeViolations(); + await expect(container).toBeAccessible(componentName); + await expect(container).toHaveNoAxeViolations(); }); it('renders closeIconDescription, title, logo, and version', async () => { diff --git a/packages/ibm-products/src/components/CreateFullPage/CreateFullPage.test.js b/packages/ibm-products/src/components/CreateFullPage/CreateFullPage.test.js index 4eacb7543f..db9df6f44c 100644 --- a/packages/ibm-products/src/components/CreateFullPage/CreateFullPage.test.js +++ b/packages/ibm-products/src/components/CreateFullPage/CreateFullPage.test.js @@ -1,5 +1,5 @@ /** - * Copyright IBM Corp. 2021, 2022 + * Copyright IBM Corp. 2021, 2024 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. @@ -185,8 +185,7 @@ describe(componentName, () => { window.ResizeObserver = ResizeObserver; }); - // Currently fails due to https://github.com/carbon-design-system/carbon/issues/14135 regarding focusable button - it.skip('has no accessibility violations', async () => { + it('has no accessibility violations', async () => { const { container } = renderComponent({ ...defaultFullPageProps }); expect(container).toBeAccessible(componentName); diff --git a/packages/ibm-products/src/components/CreateTearsheetNarrow/CreateTearsheetNarrow.test.js b/packages/ibm-products/src/components/CreateTearsheetNarrow/CreateTearsheetNarrow.test.js index 308e0c5d0a..1b454392f4 100644 --- a/packages/ibm-products/src/components/CreateTearsheetNarrow/CreateTearsheetNarrow.test.js +++ b/packages/ibm-products/src/components/CreateTearsheetNarrow/CreateTearsheetNarrow.test.js @@ -1,5 +1,5 @@ /** - * Copyright IBM Corp. 2021, 2021 + * Copyright IBM Corp. 2021, 2024 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. @@ -76,17 +76,16 @@ describe(componentName, () => { expect(screen.getByText(defaultProps.primaryButtonText)).toBeVisible(); }); - it.skip('has no accessibility violations when closed', async () => { - // Currently fails due to https://github.com/carbon-design-system/carbon/issues/14135 regarding focusable button + it('has no accessibility violations when closed', async () => { const { container } = renderComponent({ open: false }); - expect(container).toBeAccessible(componentName); - expect(container).toHaveNoAxeViolations(); + await expect(container).toBeAccessible(componentName); + await expect(container).toHaveNoAxeViolations(); }); it('has no accessibility violations', async () => { const { container } = renderComponent(); - expect(container).toBeAccessible(componentName); - expect(container).toHaveNoAxeViolations(); + await expect(container).toBeAccessible(componentName); + await expect(container).toHaveNoAxeViolations(); }); it(`renders children`, async () => { diff --git a/packages/ibm-products/src/components/Tearsheet/Tearsheet.test.js b/packages/ibm-products/src/components/Tearsheet/Tearsheet.test.js index 61db0b1e32..2cb1b2222a 100644 --- a/packages/ibm-products/src/components/Tearsheet/Tearsheet.test.js +++ b/packages/ibm-products/src/components/Tearsheet/Tearsheet.test.js @@ -1,5 +1,5 @@ /** - * Copyright IBM Corp. 2020, 2023 + * Copyright IBM Corp. 2020, 2024 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. @@ -106,8 +106,7 @@ const commonTests = (Ts, name, props, testActions) => { }); }); - // Currently fails due to https://github.com/carbon-design-system/carbon/issues/14135 regarding focusable button - it.skip('has no accessibility violations when closed', async () => { + it('has no accessibility violations when closed', async () => { const { container } = render( );