Skip to content

Commit

Permalink
refactor team e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 12, 2024
1 parent ac80c57 commit 8569a3a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
79 changes: 35 additions & 44 deletions frontend/cypress/e2e/team.cy.ts
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class CyOverviewPage extends Page {

validatePage(): void {}

doVisit(): void {
protected doVisit(): void {
this.elements.logo().click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8569a3a

Please sign in to comment.