diff --git a/lib/DocumentFilter/DocumentFilter.test.js b/lib/DocumentFilter/DocumentFilter.test.js index b9ba7779..f2be2941 100644 --- a/lib/DocumentFilter/DocumentFilter.test.js +++ b/lib/DocumentFilter/DocumentFilter.test.js @@ -87,7 +87,8 @@ describe('DocumentFilter', () => { expectedParsedFilterData ) => { describe(activeFilterTitle, () => { - beforeEach(() => { + beforeEach(async () => { + await mockPFD.mockClear(); renderComponent = renderWithIntl( { describe('testing parsedFilterData', () => { beforeEach(async () => { - mockPFD.mockClear(); await waitFor(async () => { await Button('Test parsed filter data').click(); }); }); - test('parsed filter data is as expected', () => { - expect(mockPFD.mock.calls[0][0]).toEqual(expectedParsedFilterData); + test('parsed filter data is as expected', async () => { + await waitFor(async () => { + await expect(mockPFD.mock.calls[0][0]).toEqual(expectedParsedFilterData); + }); }); }); }); diff --git a/lib/DocumentFilter/DocumentFilterForm.test.js b/lib/DocumentFilter/DocumentFilterForm.test.js index 2a92d18a..3b3417bc 100644 --- a/lib/DocumentFilter/DocumentFilterForm.test.js +++ b/lib/DocumentFilter/DocumentFilterForm.test.js @@ -85,9 +85,11 @@ describe('DocumentFilterForm', () => { await Button('Edit document filters').exists(); }); - test('filter form is not open', () => { + test('filter form is not open', async () => { const { queryByText } = renderComponent; - expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument(); + await waitFor(async () => { + await expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument(); + }) }); describe('opening the filter form', () => { @@ -97,9 +99,11 @@ describe('DocumentFilterForm', () => { }); }); - test('filter form is open', () => { + test('filter form is open', async () => { const { queryByText } = renderComponent; - expect(queryByText('DocumentFilterFieldArray')).toBeInTheDocument(); + await waitFor(async () => { + await expect(queryByText('DocumentFilterFieldArray')).toBeInTheDocument(); + }); }); }); }); @@ -144,9 +148,11 @@ describe('DocumentFilterForm', () => { }); }); - test('filter form is open', () => { + test('filter form is open', async () => { const { queryByText } = renderComponent; - expect(queryByText('DocumentFilterFieldArray')).toBeInTheDocument(); + await waitFor(async () => { + await expect(queryByText('DocumentFilterFieldArray')).toBeInTheDocument(); + }); }); describe('making form dirty for submittal', () => { @@ -167,19 +173,22 @@ describe('DocumentFilterForm', () => { beforeEach(async () => { // Submit form await waitFor(async () => { - // screen.debug(); // There is no translation for this across stripes-erm-components rn, so no use for intlKey. await Button('ui-test-implementor.saveAndClose').click(); }); }); - test(`submit handler acted as expected for ${filtersInfo}`, () => { - expect(filterHandlers.state.mock.calls[0][0]).toEqual(expectedSubmit); + test(`submit handler acted as expected for ${filtersInfo}`, async () => { + await waitFor(async () => { + await expect(filterHandlers.state.mock.calls[0][0]).toEqual(expectedSubmit); + }); }); - test('filter form is not open', () => { + test('filter form is not open', async () => { const { queryByText } = renderComponent; - expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument(); + await waitFor(async () => { + await expect(queryByText('DocumentFilterFieldArray')).not.toBeInTheDocument(); + }); }); }); });