From 5452e3b8f01b5bb241383bc24eb99751d5e399fa Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Mon, 11 Nov 2024 16:23:43 +0100 Subject: [PATCH] add member invite dialog --- frontend/cypress/e2e/objective-backlog.cy.ts | 4 +- frontend/cypress/e2e/teammanagement.cy.ts | 24 ++++------- .../helper/pom-helper/dialogs/dialog.ts | 11 +++-- .../pom-helper/dialogs/inviteMembersDialog.ts | 41 +++++++++++++++++++ .../pom-helper/dialogs/keyResultDialog.ts | 16 ++++---- .../pom-helper/dialogs/objectiveDialog.ts | 4 +- .../helper/pom-helper/dialogs/teamDialog.ts | 2 +- .../helper/pom-helper/pageObjectMapperBase.ts | 2 +- 8 files changed, 71 insertions(+), 33 deletions(-) create mode 100644 frontend/cypress/support/helper/pom-helper/dialogs/inviteMembersDialog.ts diff --git a/frontend/cypress/e2e/objective-backlog.cy.ts b/frontend/cypress/e2e/objective-backlog.cy.ts index c0e0c86580..464ddf4e26 100644 --- a/frontend/cypress/e2e/objective-backlog.cy.ts +++ b/frontend/cypress/e2e/objective-backlog.cy.ts @@ -15,8 +15,8 @@ describe('OKR Objective Backlog e2e tests', () => { op.addObjective() .fillObjectiveTitle('Objective in quarter backlog') .selectQuarter('Backlog') - .check(cy.contains('Speichern').should('not.exist')) - .check(cy.contains('Als Draft speichern')) + .run(cy.contains('Speichern').should('not.exist')) + .run(cy.contains('Als Draft speichern')) .submitDraftObjective(); cy.contains('Objective in quarter backlog').should('not.exist'); diff --git a/frontend/cypress/e2e/teammanagement.cy.ts b/frontend/cypress/e2e/teammanagement.cy.ts index 9d6d05a90e..1f6fa4ea60 100644 --- a/frontend/cypress/e2e/teammanagement.cy.ts +++ b/frontend/cypress/e2e/teammanagement.cy.ts @@ -3,6 +3,7 @@ import { uniqueSuffix } from '../support/helper/utils'; import ConfirmDialog from '../support/helper/pom-helper/dialogs/confirmDialog'; import TeammanagementPage from '../support/helper/pom-helper/pages/teammanagementPage'; import CyOverviewPage from '../support/helper/pom-helper/pages/overviewPage'; +import InviteMembersDialog from '../support/helper/pom-helper/dialogs/inviteMembersDialog'; describe('Team management tests', () => { const teamName = uniqueSuffix('New Team'); @@ -176,21 +177,13 @@ describe('Team management tests', () => { describe('invite members', () => { it('invite two members', () => { - const mailUserClaudia = uniqueSuffix('claudia.meier@test') + '.ch'; - const mailUserStefan = uniqueSuffix('stefan.schmidt@test') + '.ch'; - const firstNameClaudia = uniqueSuffix('Claudia'); - const firstNameStefan = uniqueSuffix('Stefan'); + teammanagementPage.elements.registerMember().click(); + const firstNames = InviteMembersDialog.do() + .enterUser('Claudia', 'Meier', 'claudia.meier@test.ch') + .addAnotherUser() + .enterUser('Stefan', 'Schmidt', 'stefan.schmidt@test.ch') + .getFirstNames(); - cy.getByTestId('invite-member').click(); - cy.wait(1000); // wait for dialog to open - cy.tabForward(); - cy.contains('Members registrieren'); - - fillOutNewUser(firstNameClaudia, 'Meier', mailUserClaudia); - cy.tabForward(); - cy.tabForward(); - cy.realPress('Enter'); - fillOutNewUser(firstNameStefan, 'Schmidt', mailUserStefan); cy.tabForward(); cy.tabForward(); cy.realPress('Enter'); @@ -217,8 +210,7 @@ describe('Team management tests', () => { // save cy.getByTestId('invite').click(); cy.contains('Die Members wurden erfolgreich registriert'); - cy.contains(firstNameClaudia); - cy.contains(firstNameStefan); + firstNames.forEach((email) => cy.contains(email)); }); }); diff --git a/frontend/cypress/support/helper/pom-helper/dialogs/dialog.ts b/frontend/cypress/support/helper/pom-helper/dialogs/dialog.ts index 6902bed0ef..cae1054e29 100644 --- a/frontend/cypress/support/helper/pom-helper/dialogs/dialog.ts +++ b/frontend/cypress/support/helper/pom-helper/dialogs/dialog.ts @@ -22,9 +22,14 @@ export default abstract class Dialog extends PageObjectMapperBase { cy.getByTestId('close-dialog').click(); } - protected fillInput(testId: string, value: string) { - cy.getByTestId(testId).clear(); - cy.getByTestId(testId).type(value); + protected fillInputByTestId(testId: string, value: string) { + const elem = cy.getByTestId(testId); + this.fillInput(elem, value); + } + + protected fillInput(elem: Cypress.Chainable>, value: string) { + elem.clear(); + elem.type(value); } abstract getPage(): Cypress.Chainable>; diff --git a/frontend/cypress/support/helper/pom-helper/dialogs/inviteMembersDialog.ts b/frontend/cypress/support/helper/pom-helper/dialogs/inviteMembersDialog.ts new file mode 100644 index 0000000000..fcea19b118 --- /dev/null +++ b/frontend/cypress/support/helper/pom-helper/dialogs/inviteMembersDialog.ts @@ -0,0 +1,41 @@ +import Dialog from './dialog'; +import { uniqueSuffix } from '../../utils'; + +export default class InviteMembersDialog extends Dialog { + private readonly firstnames: string[] = []; + + override validatePage() { + super.validatePage(); + this.getPage().contains('Members registrieren').should('exist'); + } + + enterUser(firstName: string, lastName: string, email: string) { + firstName = uniqueSuffix(firstName); + email = uniqueSuffix(email); + this.firstnames.push(firstName); + const firstNameInput = cy.get('[formcontrolname="firstname"]').last(); + const lastNameInput = cy.get('[formcontrolname="lastname"]').last(); + const emailInput = cy.get('[formcontrolname="email"]').last(); + this.fillInput(firstNameInput, firstName); + this.fillInput(lastNameInput, lastName); + this.fillInput(emailInput, email); + return this; + } + + addAnotherUser() { + cy.contains('Weiterer Member hinzufügen').click(); + return this; + } + getFirstNames() { + return this.firstnames; + } + + override submit() { + cy.getByTestId('invite').click(); + return this.firstnames; + } + + getPage(): Cypress.Chainable> { + return cy.get('app-invite-user-dialog'); + } +} diff --git a/frontend/cypress/support/helper/pom-helper/dialogs/keyResultDialog.ts b/frontend/cypress/support/helper/pom-helper/dialogs/keyResultDialog.ts index d557b6f047..6e984a39e7 100644 --- a/frontend/cypress/support/helper/pom-helper/dialogs/keyResultDialog.ts +++ b/frontend/cypress/support/helper/pom-helper/dialogs/keyResultDialog.ts @@ -3,33 +3,33 @@ import { Unit } from '../../../../../src/app/shared/types/enums/Unit'; export default class KeyResultDialog extends Dialog { fillKeyresultTitle(title: string) { - this.fillInput('titleInput', title); + this.fillInputByTestId('titleInput', title); return this; } fillKeyresultDescription(description: string) { - this.fillInput('descriptionInput', description); + this.fillInputByTestId('descriptionInput', description); return this; } withMetricValues(unit: Unit, baseline: string, stretchGoal: string) { cy.getByTestId('metricTab').click(); cy.getByTestId('unit').select(unit); - this.fillInput('baseline', baseline); - this.fillInput('stretchGoal', stretchGoal); + this.fillInputByTestId('baseline', baseline); + this.fillInputByTestId('stretchGoal', stretchGoal); return this; } withOrdinalValues(commitZone: string, targetZone: string, stretchGoal: string) { cy.getByTestId('ordinalTab').click(); - this.fillInput('commitZone', commitZone); - this.fillInput('targetZone', targetZone); - this.fillInput('stretchZone', stretchGoal); + this.fillInputByTestId('commitZone', commitZone); + this.fillInputByTestId('targetZone', targetZone); + this.fillInputByTestId('stretchZone', stretchGoal); return this; } fillOwner(owner: string) { - this.fillInput('ownerInput', owner); + this.fillInputByTestId('ownerInput', owner); return this; } diff --git a/frontend/cypress/support/helper/pom-helper/dialogs/objectiveDialog.ts b/frontend/cypress/support/helper/pom-helper/dialogs/objectiveDialog.ts index ef952e5c13..efad504a23 100644 --- a/frontend/cypress/support/helper/pom-helper/dialogs/objectiveDialog.ts +++ b/frontend/cypress/support/helper/pom-helper/dialogs/objectiveDialog.ts @@ -2,12 +2,12 @@ import Dialog from './dialog'; export default class ObjectiveDialog extends Dialog { fillObjectiveTitle(title: string) { - this.fillInput('title', title); + this.fillInputByTestId('title', title); return this; } fillObjectiveDescription(description: string) { - this.fillInput('description', description); + this.fillInputByTestId('description', description); return this; } diff --git a/frontend/cypress/support/helper/pom-helper/dialogs/teamDialog.ts b/frontend/cypress/support/helper/pom-helper/dialogs/teamDialog.ts index 5cb3d7ec72..6eed3098ce 100644 --- a/frontend/cypress/support/helper/pom-helper/dialogs/teamDialog.ts +++ b/frontend/cypress/support/helper/pom-helper/dialogs/teamDialog.ts @@ -7,7 +7,7 @@ export default class TeamDialog extends Dialog { } fillName(name: string) { - this.fillInput('add-team-name', name); + this.fillInputByTestId('add-team-name', name); return this; } diff --git a/frontend/cypress/support/helper/pom-helper/pageObjectMapperBase.ts b/frontend/cypress/support/helper/pom-helper/pageObjectMapperBase.ts index bfaba39114..8d5f7a89e3 100644 --- a/frontend/cypress/support/helper/pom-helper/pageObjectMapperBase.ts +++ b/frontend/cypress/support/helper/pom-helper/pageObjectMapperBase.ts @@ -5,7 +5,7 @@ export abstract class PageObjectMapperBase { return new this(); } - check(arg: any) { + run(arg: any) { return this; }