From 78ce8b0b0cd64a308adeebbe5cf286ea14c1e367 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Wed, 6 Sep 2023 14:40:01 +0200 Subject: [PATCH] fix(e2e): improve test stabily with the same sample data --- .../src/e2e/project/settings/members.cy.ts | 47 +++++++++++++++++-- .../src/support/helpers/api.helpers.ts | 1 + 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/javascript/apps/taiga-e2e/src/e2e/project/settings/members.cy.ts b/javascript/apps/taiga-e2e/src/e2e/project/settings/members.cy.ts index 74ca2706c..6f0523e2b 100644 --- a/javascript/apps/taiga-e2e/src/e2e/project/settings/members.cy.ts +++ b/javascript/apps/taiga-e2e/src/e2e/project/settings/members.cy.ts @@ -21,20 +21,57 @@ import { } from '@test/support/helpers/settings.helpers'; import { createWorkspaceRequest } from '@test/support/helpers/workspace.helpers'; +const workspace = WorkspaceMockFactory(); +const projectMock = ProjectMockFactory(); + describe('Settings > members', () => { before(() => { cy.login(); cy.visit('/'); + + void createWorkspaceRequest(workspace.name) + .then((responseCreateWorkspace) => { + return createFullProjectInWSRequest( + responseCreateWorkspace.body.id, + projectMock.name + ); + }) + .then((responseCreateProject) => { + projectMock.slug = responseCreateProject.body.slug; + projectMock.id = responseCreateProject.body.id; + + const invitations = [ + { username: '2user', roleSlug: 'admin' }, + { username: '3user', roleSlug: 'admin' }, + { username: '4user', roleSlug: 'admin' }, + { username: '5user', roleSlug: 'general' }, + { username: '6user', roleSlug: 'general' }, + { username: '7user', roleSlug: 'general' }, + ]; + + invitations.forEach((invitation) => { + void inviteToProjectRequest( + responseCreateProject.body.id, + [invitation], + invitation.username + ); + }); + }); }); beforeEach(() => { cy.login(); cy.visit('/'); - cy.initAxe(); - cy.getBySel('project-card').contains('Several Roles').click(); + + cy.visit(`/project/${projectMock.id}/${projectMock.slug}`); + cy.log(`/project/${projectMock.id}/${projectMock.slug}`); navigateToSettings(); navigateToMembersSettings(); + }); + + it('is a11y', () => { + cy.initAxe(); cy.tgCheckA11y(); }); @@ -112,16 +149,16 @@ describe('change role', () => { .catch(console.error); }); - it.skip('change own admin role', () => { + it('change own admin role', () => { cy.getBySel('project-card').contains('Several Roles').click(); navigateToSettings(); navigateToMembersSettings(); cy.tgCheckA11y(); - cy.get('[data-test=1user]').should('be.visible'); + cy.getBySel('1user').should('be.visible'); cy.getBySel('disabled-change-role').should('not.exist'); - cy.get('[data-test=1user]').find('input').click(); + cy.getBySel('1user').find('input').click(); cy.getBySel('permissions-warning').should('be.visible'); }); }); diff --git a/javascript/apps/taiga-e2e/src/support/helpers/api.helpers.ts b/javascript/apps/taiga-e2e/src/support/helpers/api.helpers.ts index 0d3f2e5a8..aa798cd15 100644 --- a/javascript/apps/taiga-e2e/src/support/helpers/api.helpers.ts +++ b/javascript/apps/taiga-e2e/src/support/helpers/api.helpers.ts @@ -56,6 +56,7 @@ export function getEmails(): Cypress.Chainable< text: string; html: string; to: string; + subject: string; }[]; }> > {