diff --git a/server-ce/test/admin.spec.ts b/server-ce/test/admin.spec.ts index 2b17504e92..9c65de2b14 100644 --- a/server-ce/test/admin.spec.ts +++ b/server-ce/test/admin.spec.ts @@ -10,9 +10,9 @@ describe('admin panel', function () { const user1 = 'user@example.com' const user2 = 'user2@example.com' - const testProjectName = `project-${uuid()}` + let testProjectName = '' let testProjectId = '' - const deletedProjectName = `deleted-project-${uuid()}` + let deletedProjectName = '' let projectToDeleteId = '' const findProjectRow = (projectName: string) => { @@ -29,6 +29,8 @@ describe('admin panel', function () { ensureUserExists({ email: user2 }) beforeWithReRunOnTestRetry(() => { + testProjectName = `project-${uuid()}` + deletedProjectName = `deleted-project-${uuid()}` login(user1) cy.visit('/project') createProject(testProjectName).then(id => (testProjectId = id)) @@ -180,7 +182,7 @@ describe('admin panel', function () { cy.log('delete project') findProjectRow(deletedProjectName).within(() => - cy.get('button[aria-label="Trash"]').click() + cy.contains('Trash').click() ) cy.get('button').contains('Confirm').click() cy.findByText(deletedProjectName).should('not.exist') @@ -190,7 +192,7 @@ describe('admin panel', function () { cy.findByText('Trashed Projects').click() }) findProjectRow(deletedProjectName).within(() => - cy.get('button[aria-label="Delete"]').click() + cy.contains('Delete').click() ) cy.get('button').contains('Confirm').click() cy.findByText(deletedProjectName).should('not.exist') diff --git a/server-ce/test/project-list.spec.ts b/server-ce/test/project-list.spec.ts index e144b147d3..a78bf241f7 100644 --- a/server-ce/test/project-list.spec.ts +++ b/server-ce/test/project-list.spec.ts @@ -28,15 +28,12 @@ describe('Project List', () => { describe('user with projects', () => { const projectName = `test-project-${uuid()}` - let projectId: string | undefined ensureUserExists({ email: REGULAR_USER }) before(() => { login(REGULAR_USER) cy.visit('/project') - createProject(projectName, { type: 'Example Project' }).then( - id => (projectId = id) - ) + createProject(projectName, { type: 'Example Project' }) }) it('Can download project sources', () => { @@ -44,7 +41,7 @@ describe('Project List', () => { cy.visit('/project') findProjectRow(projectName).within(() => - cy.get(`[aria-label="Download .zip file"]`).click() + cy.contains(`Download .zip file`).click() ) cy.task('readFileInZip', { @@ -58,7 +55,7 @@ describe('Project List', () => { cy.visit('/project') findProjectRow(projectName).within(() => - cy.get(`[aria-label="Download PDF"]`).click() + cy.contains(`Download PDF`).click() ) const pdfName = projectName.replaceAll('-', '_') @@ -74,7 +71,7 @@ describe('Project List', () => { cy.visit('/project') cy.log('select project') - cy.get(`[id="select-project-${projectId}"`).click() + cy.get(`[aria-label="Select ${projectName}"]`).click() cy.log('add tag to project') cy.get('button[aria-label="Tags"]').click() @@ -98,7 +95,7 @@ describe('Project List', () => { cy.visit('/project') cy.log('select project') - cy.get(`[id="select-project-${projectId}"`).click() + cy.get(`[aria-label="Select ${projectName}"]`).click() cy.log('add tag to project') const tagName = uuid().slice(0, 7) // long tag names are truncated in the UI, which affects selectors