From d43f09ca4f5e24bdd538f0f6d18da18f5f81df02 Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:06:05 +0100 Subject: [PATCH] Merge pull request #27798 from overleaf/td-project-list-frontend-tests-fix Fix and reinstate project list front-end tests GitOrigin-RevId: 5f9343a56a5cf6e4da04c161b9f17b9282fdccbb --- .../table/project-list-table.test.tsx | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 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 e870478076..89bd6f33f3 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 @@ -9,7 +9,7 @@ const userId = '624333f147cfd8002622a1d3' // TODO(25331): re-enable // eslint-disable-next-line mocha/no-skipped-tests -describe.skip('', function () { +describe('', function () { beforeEach(function () { window.metaAttributesCache.set('ol-tags', []) window.metaAttributesCache.set('ol-user_id', userId) @@ -30,7 +30,7 @@ describe.skip('', function () { let foundSortedColumn = false const columns = screen.getAllByRole('columnheader') columns.forEach(col => { - if (col.getAttribute('aria-label') === 'Last Modified') { + if (col.getAttribute('aria-label') === 'Last modified') { expect(col.getAttribute('aria-sort')).to.equal('descending') foundSortedColumn = true } else { @@ -60,7 +60,7 @@ describe.skip('', function () { renderWithProjectListContext() screen.getByRole('button', { name: 'Sort by Title' }) screen.getByRole('button', { name: 'Sort by Owner' }) - screen.getByRole('button', { name: 'Reverse Last Modified sort order' }) // currently sorted + screen.getByRole('button', { name: 'Reverse Last modified sort order' }) // currently sorted }) it('renders project title, owner, last modified, and action buttons', async function () { @@ -146,6 +146,14 @@ describe.skip('', function () { renderWithProjectListContext() await fetchMock.callHistory.flush(true) const checkbox = await screen.findByLabelText('Select all projects') + + // Wait for project checkboxes to be visible before clicking the select-all + // checkbox + await waitFor(() => { + const allCheckboxes = screen.queryAllByRole('checkbox') + expect(allCheckboxes.length).to.equal(currentProjects.length + 1) + }) + fireEvent.click(checkbox) await waitFor(() => { @@ -161,6 +169,13 @@ describe.skip('', function () { await fetchMock.callHistory.flush(true) const checkbox = await screen.findByLabelText('Select all projects') + // Wait for project checkboxes to be visible before clicking the select-all + // checkbox + await waitFor(() => { + const allCheckboxes = screen.queryAllByRole('checkbox') + expect(allCheckboxes.length).to.equal(currentProjects.length + 1) + }) + fireEvent.click(checkbox) await waitFor(() => { @@ -181,6 +196,14 @@ describe.skip('', function () { renderWithProjectListContext() await fetchMock.callHistory.flush(true) const checkbox = await screen.findByLabelText('Select all projects') + + // Wait for project checkboxes to be visible before clicking the select-all + // checkbox + await waitFor(() => { + const allCheckboxes = screen.queryAllByRole('checkbox') + expect(allCheckboxes.length).to.equal(currentProjects.length + 1) + }) + fireEvent.click(checkbox) // make sure we are unchecking a project checkbox and that it is already @@ -188,15 +211,16 @@ describe.skip('', function () { await waitFor(() => { expect( screen - .getAllByRole('checkbox', { checked: true })[1] - .getAttribute('data-project-id') + .queryAllByRole('checkbox', { checked: true })?.[1] + ?.getAttribute('data-project-id') ).to.exist }) fireEvent.click(screen.getAllByRole('checkbox')[1]) await waitFor(() => { - const allCheckboxes = screen.getAllByRole('checkbox') + const allCheckboxes = screen.queryAllByRole('checkbox') + expect(allCheckboxes.length).to.equal(currentProjects.length + 1) const allCheckboxesChecked = allCheckboxes.filter(c => c.checked) expect(allCheckboxesChecked.length).to.equal(currentProjects.length - 1) }) @@ -210,6 +234,7 @@ describe.skip('', function () { ) fireEvent.click(checkbox) const allCheckboxes = screen.getAllByRole('checkbox') + expect(allCheckboxes.length).to.equal(currentProjects.length + 1) const allCheckboxesChecked = allCheckboxes.filter(c => c.checked) expect(allCheckboxesChecked.length).to.equal(1) })