From a388c1f414b1d95bedce8eb385860ed1a4e5b578 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Wed, 25 Oct 2023 10:25:29 +0100 Subject: [PATCH] Fix and re-enable project list tests (#15417) GitOrigin-RevId: 9f4ea2bd28e99532af57bdcfb437519d038918ad --- .../components/project-list-root.test.tsx | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx b/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx index 1f55c8725e..e1b52aa19a 100644 --- a/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx +++ b/services/web/test/frontend/features/project-list/components/project-list-root.test.tsx @@ -781,22 +781,24 @@ describe('', function () { const filterButton = screen.getAllByText('All Projects')[0] fireEvent.click(filterButton) allCheckboxes = screen.getAllByRole('checkbox') - // first one is the select all checkbox - fireEvent.click(allCheckboxes[2]) - actionsToolbar = screen.getAllByRole('toolbar')[0] }) it('does not show the dropdown when more than 1 project is selected', async function () { + fireEvent.click(allCheckboxes[2]) // select a project + + const actionsToolbar = screen.getAllByRole('toolbar')[0] await waitFor(() => { within(actionsToolbar).getByText('More') }) - fireEvent.click(allCheckboxes[0]) + fireEvent.click(allCheckboxes[0]) // select all expect(within(actionsToolbar).queryByText('More')).to .be.null }) - // eslint-disable-next-line mocha/no-skipped-tests - it.skip('validates the project name', async function () { + it('validates the project name', async function () { + fireEvent.click(allCheckboxes[1]) // select a project owned by the current user + + const actionsToolbar = screen.getAllByRole('toolbar')[0] const moreDropdown = await within( actionsToolbar ).findByText('More') @@ -833,8 +835,10 @@ describe('', function () { expect(confirmButton.disabled).to.be.true }) - // eslint-disable-next-line mocha/no-skipped-tests - it.skip('opens the rename modal, and can rename the project, and view updated', async function () { + it('opens the rename modal, and can rename the project, and view updated', async function () { + fireEvent.click(allCheckboxes[1]) // select a project owned by the current user + const actionsToolbar = screen.getAllByRole('toolbar')[0] + const renameProjectMock = fetchMock.post( `express:/project/:id/rename`, { @@ -871,21 +875,26 @@ describe('', function () { await fetchMock.flush(true) expect( - renameProjectMock.called(`/project/${projectsData[1].id}/rename`) + renameProjectMock.called(`/project/${projectsData[0].id}/rename`) ).to.be.true const table = await screen.findByRole('table') within(table).getByText(newProjectName) expect(within(table).queryByText(oldName)).to.be.null - const allCheckboxes = await within( + const allCheckboxesInTable = await within( table ).findAllByRole('checkbox') - const allCheckboxesChecked = allCheckboxes.filter(c => c.checked) + const allCheckboxesChecked = allCheckboxesInTable.filter( + c => c.checked + ) expect(allCheckboxesChecked.length).to.equal(0) }) it('opens the copy modal, can copy the project, and view updated', async function () { + fireEvent.click(allCheckboxes[2]) + const actionsToolbar = screen.getAllByRole('toolbar')[0] + const tableRows = screen.getAllByRole('row') const linkForProjectToCopy = within(tableRows[1]).getByRole('link') const projectNameToCopy = linkForProjectToCopy.textContent || '' // needed for type checking