From 774c2a1b8d16532d8ef1283152febc51bd3d12a5 Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Tue, 6 May 2025 16:45:56 +0100 Subject: [PATCH] Merge pull request #25348 from overleaf/td-react-18-flaky-tests Attempt to fix two flaky frontend project dashboard tests GitOrigin-RevId: 1d5c3a05f7439ad3e22e5de96da8628ad8dd27c5 --- .../table/project-list-table.test.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/services/web/test/frontend/features/project-list/components/table/project-list-table.test.tsx b/services/web/test/frontend/features/project-list/components/table/project-list-table.test.tsx index f1d4a0755d..f8f9143c16 100644 --- a/services/web/test/frontend/features/project-list/components/table/project-list-table.test.tsx +++ b/services/web/test/frontend/features/project-list/components/table/project-list-table.test.tsx @@ -154,17 +154,24 @@ describe('', function () { }) }) - it('unselects all projects when select all checkbox uchecked', async function () { + it('unselects all projects when select all checkbox unchecked', async function () { renderWithProjectListContext() await fetchMock.callHistory.flush(true) const checkbox = await screen.findByLabelText('Select all projects') - fireEvent.click(checkbox) + fireEvent.click(checkbox) await waitFor(() => { const allCheckboxes = screen.queryAllByRole('checkbox') const allCheckboxesChecked = allCheckboxes.filter(c => c.checked) - expect(allCheckboxesChecked.length).to.equal(0) + expect(allCheckboxesChecked).to.have.length(currentProjects.length + 1) + }) + + fireEvent.click(checkbox) + + await waitFor(() => { + const allCheckboxes = screen.queryAllByRole('checkbox') + expect(allCheckboxes.every(c => !c.checked)).to.be.true }) }) @@ -174,12 +181,14 @@ describe('', function () { const checkbox = await screen.findByLabelText('Select all projects') fireEvent.click(checkbox) + // make sure we are unchecking a project checkbox and that it is already + // checked await waitFor(() => { expect( screen - .getAllByRole('checkbox')[1] + .getAllByRole('checkbox', { checked: true })[1] .getAttribute('data-project-id') - ).to.exist // make sure we are unchecking a project checkbox + ).to.exist }) fireEvent.click(screen.getAllByRole('checkbox')[1])