Skip to content

Commit d19522f

Browse files
committed
fix tests
1 parent c45c686 commit d19522f

File tree

9 files changed

+2187
-786
lines changed

9 files changed

+2187
-786
lines changed

src/__tests__/CompareResults/__snapshots__/ResultsTable.test.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ exports[`Results Table Should match snapshot 1`] = `
212212
>
213213
<div
214214
class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root search-text-field base css-cmpglg-MuiFormControl-root-MuiTextField-root"
215+
role="textbox"
215216
>
216217
<div
217218
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedStart MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-1e4fo0f-MuiInputBase-root-MuiOutlinedInput-root"
@@ -537,6 +538,7 @@ exports[`Results Table Should match snapshot 1`] = `
537538
>
538539
<div
539540
class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root search-text-field new css-cmpglg-MuiFormControl-root-MuiTextField-root"
541+
role="textbox"
540542
>
541543
<div
542544
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedStart MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-1e4fo0f-MuiInputBase-root-MuiOutlinedInput-root"

src/__tests__/Search/SearchResultsList.test.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ describe('SearchResultsList', () => {
3232
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
3333

3434
await renderComponent();
35+
36+
const placeholder = Strings.components.searchDefault.base.collapsed.base.inputPlaceholder;
37+
3538
// focus input to show results
36-
const searchInput = screen.getAllByRole('textbox')[0];
39+
const searchInput = screen.getAllByPlaceholderText(placeholder)[0];
3740
await user.click(searchInput);
3841
await screen.findByText(/flesh wound/);
3942
expect(document.body).toMatchSnapshot();
@@ -48,6 +51,9 @@ describe('SearchResultsList', () => {
4851
const searchInput = screen.getAllByRole('textbox')[0];
4952
await user.click(searchInput);
5053

54+
// Wait for the dropdown to open and results to load
55+
await screen.findByRole('listbox');
56+
5157
const fleshWound = await screen.findAllByText("it's just a flesh wound");
5258

5359
await user.click(fleshWound[0]);
@@ -111,8 +117,11 @@ describe('SearchResultsList', () => {
111117
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
112118

113119
await renderComponent();
120+
121+
const placeholder = Strings.components.searchDefault.base.collapsed.base.inputPlaceholder;
122+
114123
// focus input to show results
115-
const searchInput = screen.getAllByRole('textbox')[1];
124+
const searchInput = screen.getAllByPlaceholderText(placeholder)[1];
116125
await user.click(searchInput);
117126

118127
const noArmsLeft = await screen.findByText(/no arms left/);
@@ -139,16 +148,17 @@ describe('SearchResultsList', () => {
139148

140149
it('Should apply dark and light mode styles when theme button is toggled', async () => {
141150
await renderComponent();
151+
const placeholder = Strings.components.searchDefault.base.collapsed.base.inputPlaceholder;
142152
const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
143153
const darkModeToggle = screen.getByRole('checkbox', {
144154
name: /Dark mode switch/,
145155
});
146156

147157
await user.click(darkModeToggle);
148158
expect(screen.getByLabelText('Light mode')).toBeInTheDocument();
149-
const searchInput = screen.getAllByRole('textbox')[0];
159+
const searchInput = screen.getAllByPlaceholderText(placeholder)[0];
150160
await user.click(searchInput);
151-
const resultsList = screen.getByTestId('list-mode');
161+
const resultsList = screen.getByRole('listbox');
152162
expect(resultsList).toMatchSnapshot('after toggling dark mode');
153163
expect(resultsList).toHaveClass('results-list-dark');
154164
});

0 commit comments

Comments
 (0)