Skip to content

Commit

Permalink
fix errors in accessibility test (mozilla#218)
Browse files Browse the repository at this point in the history
* fix errors in accessibility test

* commented out test and added note explaining why
  • Loading branch information
kimberlythegeek authored Aug 22, 2022
1 parent baf125e commit 66485b5
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/__tests__/accessiblity/accessibility.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { axe, toHaveNoViolations } from 'jest-axe';
import { act } from 'react-dom/test-utils';

import CompareResultsView from '../../components/CompareResults/CompareResultsView';
import SearchDropdown from '../../components/Search/SearchDropdown';
Expand All @@ -22,9 +23,11 @@ describe('Accessibility', () => {
});

it('SearchInput should have no violations', async () => {
const { container } = renderWithRouter(<SearchView />);
const results = await axe(container);
expect(results).toHaveNoViolations();
await act(async () => {
const { container } = renderWithRouter(<SearchView />);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
});

it('SearchResultsList should have no violations', async () => {
Expand All @@ -41,7 +44,7 @@ describe('Accessibility', () => {
const { testData } = getTestData();
store.dispatch(updateSearchResults(testData));

const { container } = renderWithRouter(<SearchDropdown />);
const { container } = renderWithRouter(<SearchDropdown view="search" />);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
Expand All @@ -58,7 +61,7 @@ describe('Accessibility', () => {
expect(results).toHaveNoViolations();
});

it('CompareResultsView should have no violations', async () => {
it('CompareResultsView should have no violations in light mode', async () => {
const { testData } = getTestData();
const selectedRevisions = testData.slice(0, 4);
store.dispatch(setSelectedRevisions(selectedRevisions));
Expand All @@ -67,4 +70,16 @@ describe('Accessibility', () => {
const results = await axe(container);
expect(results).toHaveNoViolations();
});

// TO DO: resolve 'Axe is already running' issue and re-enable test
// https://github.com/mozilla/perfcompare/issues/222
// it('CompareResultsView should have no violations in dark mode', async () => {
// const { testData } = getTestData();
// const selectedRevisions = testData.slice(0, 4);
// store.dispatch(setSelectedRevisions(selectedRevisions));

// const { container } = renderWithRouter(<CompareResultsView mode="dark" />);
// const results = await axe(container);
// expect(results).toHaveNoViolations();
// });
});

0 comments on commit 66485b5

Please sign in to comment.