diff --git a/frontend/cypress/e2e/team.cy.ts b/frontend/cypress/e2e/team.cy.ts index d228c4e204..3f979912a1 100644 --- a/frontend/cypress/e2e/team.cy.ts +++ b/frontend/cypress/e2e/team.cy.ts @@ -1,15 +1,21 @@ import * as users from '../fixtures/users.json'; import FilterHelper from '../support/helper/pom-helper/filterHelper'; +import CyOverviewPage from '../support/helper/pom-helper/pages/overviewPage'; describe('OKR team e2e tests', () => { describe('tests via click', () => { beforeEach(() => { cy.loginAsUser(users.gl); - cy.visit('/?quarter=2'); + CyOverviewPage.do().visitCurrentQuarter(); }); - it.only('Should select teams from teamfilter', () => { - const filterHelper = FilterHelper.do().optionShouldBeSelected('Puzzle ITC').optionShouldBeSelected('LoremIpsum'); + it('Should select teams from teamfilter', () => { + const filterHelper = FilterHelper.do() + .optionShouldBeSelected('Puzzle ITC') + .optionShouldBeSelected('LoremIpsum') + .optionShouldNotBeSelected('Alle') + .optionShouldNotBeSelected('/BBT') + .optionShouldNotBeSelected('we are cube'); filterHelper .toggleOption('Alle') @@ -37,57 +43,42 @@ describe('OKR team e2e tests', () => { }); it('Deselect all teams from filter will display text on overview', () => { - cy.getByTestId('team-filter-alle').should('have.css', 'background-color').and('eq', 'rgb(255, 255, 255)'); - cy.get('mat-chip:visible:contains("/BBT")') - .should('have.css', 'background-color') - .and('eq', 'rgb(255, 255, 255)'); - cy.get('mat-chip:visible:contains("Puzzle ITC")') - .should('have.css', 'background-color') - .and('eq', 'rgb(30, 90, 150)'); - cy.get('mat-chip:visible:contains("LoremIpsum")') - .should('have.css', 'background-color') - .and('eq', 'rgb(30, 90, 150)'); - cy.get('mat-chip:visible:contains("we are cube")') - .should('have.css', 'background-color') - .and('eq', 'rgb(255, 255, 255)'); - cy.get('mat-chip:visible:contains("Puzzle ITC")').click(); - cy.get('mat-chip:visible:contains("LoremIpsum")').click(); + const filterHelper = FilterHelper.do() + .optionShouldBeSelected('Puzzle ITC') + .optionShouldBeSelected('LoremIpsum') + .optionShouldNotBeSelected('Alle') + .optionShouldNotBeSelected('/BBT') + .optionShouldNotBeSelected('we are cube'); + + filterHelper.toggleOption('Puzzle ITC').toggleOption('LoremIpsum'); + cy.contains('Kein Team ausgewählt'); }); it('URL changes to the selected teams', () => { - cy.url().should('include', 'teams='); - cy.url().should('include', '5'); - cy.url().should('include', '6'); + const filterHelper = FilterHelper.do() + .optionShouldBeSelected('Puzzle ITC') + .optionShouldBeSelected('LoremIpsum') + .optionShouldNotBeSelected('Alle') + .optionShouldNotBeSelected('/BBT') + .optionShouldNotBeSelected('we are cube'); - cy.get('mat-chip:visible:contains("/BBT")').click(); - cy.url().should('include', 'teams='); - cy.url().should('include', '5'); - cy.url().should('include', '6'); - cy.url().should('include', '4'); - cy.get('mat-chip:visible:contains("Puzzle ITC")').click(); - cy.get('mat-chip:visible:contains("LoremIpsum")').click(); - cy.get('mat-chip:visible:contains("/BBT")').click(); - cy.url().should('not.include', 'teams='); + filterHelper.validateUrl('teams', ['5', '6']); + + filterHelper.toggleOption('/BBT').validateUrl('teams', ['4', '5', '6']); + filterHelper.toggleOption('Puzzle ITC').toggleOption('LoremIpsum').toggleOption('/BBT'); }); it('Select teams by url', () => { - cy.url().should('not.include', 'team'); + cy.url().should('not.include', 'teams'); cy.visit('/?quarter=2&teams=4,5,8'); - cy.wait(1000); - cy.getByTestId('team-filter-alle').should('have.css', 'background-color').and('eq', 'rgb(255, 255, 255)'); - cy.get('mat-chip:visible:contains("/BBT")').should('have.css', 'background-color').and('eq', 'rgb(30, 90, 150)'); - cy.get('mat-chip:visible:contains("Puzzle ITC")') - .should('have.css', 'background-color') - .and('eq', 'rgb(30, 90, 150)'); - cy.get('mat-chip:visible:contains("LoremIpsum")') - .should('have.css', 'background-color') - .and('eq', 'rgb(255, 255, 255)'); - cy.get('mat-chip:visible:contains("we are cube")') - .should('have.css', 'background-color') - .and('eq', 'rgb(30, 90, 150)'); - cy.get('h1:visible:contains("LoremIpsum")').should('not.exist'); + FilterHelper.do() + .optionShouldNotBeSelected('Alle') + .optionShouldBeSelected('/BBT') + .optionShouldBeSelected('Puzzle ITC') + .optionShouldBeSelected('we are cube') + .optionShouldNotBeSelected('LoremIpsum'); }); }); }); diff --git a/frontend/cypress/support/helper/pom-helper/pageObjectMapperBase.ts b/frontend/cypress/support/helper/pom-helper/pageObjectMapperBase.ts index 8d5f7a89e3..3b726973e7 100644 --- a/frontend/cypress/support/helper/pom-helper/pageObjectMapperBase.ts +++ b/frontend/cypress/support/helper/pom-helper/pageObjectMapperBase.ts @@ -12,4 +12,13 @@ export abstract class PageObjectMapperBase { checkForToaster(content: any) { return this; } + + validateUrl(key: string, value: any[]) { + cy.url().then((url) => { + const params = new URL(url).searchParams; + const queryParamValues = params.get(key)?.split(','); + expect(queryParamValues).to.have.length(value.length); + value.forEach((v) => expect(queryParamValues).to.include(v)); + }); + } } diff --git a/frontend/cypress/support/helper/pom-helper/pages/overviewPage.ts b/frontend/cypress/support/helper/pom-helper/pages/overviewPage.ts index 3289d56dcf..30f5e55df0 100644 --- a/frontend/cypress/support/helper/pom-helper/pages/overviewPage.ts +++ b/frontend/cypress/support/helper/pom-helper/pages/overviewPage.ts @@ -97,7 +97,7 @@ export default class CyOverviewPage extends Page { validatePage(): void {} - doVisit(): void { + protected doVisit(): void { this.elements.logo().click(); } } diff --git a/frontend/cypress/support/helper/pom-helper/pages/teammanagementPage.ts b/frontend/cypress/support/helper/pom-helper/pages/teammanagementPage.ts index c3f67d8884..f695b799f8 100644 --- a/frontend/cypress/support/helper/pom-helper/pages/teammanagementPage.ts +++ b/frontend/cypress/support/helper/pom-helper/pages/teammanagementPage.ts @@ -24,7 +24,7 @@ export default class TeammanagementPage extends Page { this.elements.registerMember().contains('Member registrieren'); } - doVisit(): this { + protected doVisit(): this { this.elements.logo().click(); return this; }