Skip to content

Commit

Permalink
fix objective-backlog tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 8, 2024
1 parent 7426ddd commit d03a83b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 115 deletions.
105 changes: 20 additions & 85 deletions frontend/cypress/e2e/objective-backlog.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as users from '../fixtures/users.json';
import { getObjectiveByNameAndState, selectFromThreeDotMenu } from '../support/objective-helper';

describe('OKR Objective Backlog e2e tests', () => {
beforeEach(() => {
Expand All @@ -16,49 +17,33 @@ describe('OKR Objective Backlog e2e tests', () => {
cy.contains('Als Draft speichern');
cy.getByTestId('safe-draft').click();

cy.get('Objective in quarter backlog').should('not.exist');
cy.contains('Objective in quarter backlog').should('not.exist');

cy.visit('/?quarter=999');

cy.contains('Objective in quarter backlog');
});

it(`Edit Objective and move to backlog`, () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('Move to another quarter on edit', 'safe-draft', undefined, '', false);

cy.getByTestId('objective')
.filter(':contains("Move to another quarter on edit")')
.last()
.findByTestId('three-dot-menu')
.click()
.wait(500)
.get('.objective-menu-option')
.contains('Objective bearbeiten')
.click();
getObjectiveByNameAndState('Move to another quarter on edit', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective bearbeiten');

cy.fillOutObjective('This goes now to backlog', 'safe', 'Backlog', '', false);

cy.get('This goes now to backlog').should('not.exist');
cy.contains('This goes now to backlog').should('not.exist');

cy.visit('/?quarter=999');

cy.contains('This goes now to backlog');
});

it(`Edit ongoing Objective can not choose backlog in quarter select`, () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('We can not move this to backlog', 'safe', undefined, '', false);

cy.getByTestId('objective')
.filter(':contains("We can not move this to backlog")')
.last()
.findByTestId('three-dot-menu')
.click()
.wait(500)
.get('.objective-menu-option')
.contains('Objective bearbeiten')
.click();
getObjectiveByNameAndState('We can not move this to backlog', 'ongoing').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective bearbeiten');

cy.get('select#quarter').should('contain', 'GJ ForTests');
cy.get('select#quarter').should('not.contain', 'Backlog');
Expand All @@ -67,25 +52,12 @@ describe('OKR Objective Backlog e2e tests', () => {
it(`Can release Objective to another quarter from backlog`, () => {
cy.visit('/?quarter=999');
cy.getByTestId('add-objective').first().click();
cy.getByTestId('title').first().clear().type('We can not release this');
cy.getByTestId('safe').should('not.exist');
cy.getByTestId('safe-draft').click();
cy.fillOutObjective('We can not release this', 'safe-draft', 'Backlog', '', false);

cy.getByTestId('objective')
.filter(':contains("We can not release this")')
.last()
.findByTestId('three-dot-menu')
.click();
getObjectiveByNameAndState('We can not release this', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective veröffentlichen');

cy.wait(500);
cy.contains('Objective bearbeiten');
cy.contains('Objective duplizieren');
cy.contains('Objective veröffentlichen');

cy.get('.objective-menu-option').contains('Objective veröffentlichen').click();

cy.contains('Objective veröffentlichen');

cy.getByTestId('title').first().clear().type('This is our first released objective');

cy.get('select#quarter').should('not.contain', 'Backlog');
Expand All @@ -98,7 +70,6 @@ describe('OKR Objective Backlog e2e tests', () => {
cy.contains('This is our first released objective').should('not.exist');

cy.visit('/?quarter=998');

cy.contains('This is our first released objective');
});

Expand All @@ -109,18 +80,10 @@ describe('OKR Objective Backlog e2e tests', () => {

cy.contains('This is possible for edit');

cy.getByTestId('objective')
.filter(':contains("This is possible for edit")')
.last()
.getByTestId('three-dot-menu')
.click()
.wait(500)
.get('.objective-menu-option')
.contains('Objective bearbeiten')
.click();
getObjectiveByNameAndState('This is possible for edit', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective bearbeiten');

cy.fillOutObjective('My new title', 'safe', undefined, '', false);

cy.contains('My new title');
});

Expand All @@ -129,15 +92,8 @@ describe('OKR Objective Backlog e2e tests', () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('This goes to other quarter later', 'safe-draft', undefined, '', false);

cy.getByTestId('objective')
.filter(':contains("This goes to other quarter later")')
.last()
.getByTestId('three-dot-menu')
.click()
.wait(500)
.get('.objective-menu-option')
.contains('Objective bearbeiten')
.click();
getObjectiveByNameAndState('This goes to other quarter later', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective bearbeiten');

cy.get('select#quarter').select('GJ ForTests');
cy.getByTestId('safe').first().click();
Expand All @@ -151,30 +107,16 @@ describe('OKR Objective Backlog e2e tests', () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('Ready for duplicate', 'safe-draft', undefined, '', false);

cy.getByTestId('objective')
.filter(':contains("Ready for duplicate")')
.last()
.getByTestId('three-dot-menu')
.click()
.wait(500)
.get('.objective-menu-option')
.contains('Objective duplizieren')
.click();
getObjectiveByNameAndState('Ready for duplicate', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective duplizieren');

cy.fillOutObjective('This is a new duplication', 'safe', undefined, '', false);

cy.contains('Ready for duplicate');
cy.contains('This is a new duplication');

cy.getByTestId('objective')
.filter(':contains("Ready for duplicate")')
.last()
.getByTestId('three-dot-menu')
.click()
.wait(500)
.get('.objective-menu-option')
.contains('Objective duplizieren')
.click();
getObjectiveByNameAndState('Ready for duplicate', 'draft').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective duplizieren');

cy.fillOutObjective('New duplication for other quarter', 'safe', 'GJ ForTests', '', false);
cy.get('New duplication for other quarter').should('not.exist');
Expand All @@ -186,15 +128,8 @@ describe('OKR Objective Backlog e2e tests', () => {
cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('Possible to duplicate into backlog', 'safe', undefined, '', false);

cy.getByTestId('objective')
.filter(':contains("Possible to duplicate into backlog")')
.last()
.getByTestId('three-dot-menu')
.click()
.wait(500)
.get('.objective-menu-option')
.contains('Objective duplizieren')
.click();
getObjectiveByNameAndState('Possible to duplicate into backlog', 'ongoing').findByTestId('three-dot-menu').click();
selectFromThreeDotMenu('Objective duplizieren');

cy.get('select#quarter').select('Backlog');
cy.getByTestId('safe').first().click();
Expand Down
27 changes: 1 addition & 26 deletions frontend/cypress/e2e/objective.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as users from '../fixtures/users.json';
import { onlyOn } from '@cypress/skip-test';
import { getObjectiveByNameAndState, selectFromThreeDotMenu } from '../support/objective-helper';

describe('OKR Objective e2e tests', () => {
describe('tests via click', () => {
Expand Down Expand Up @@ -181,29 +182,3 @@ describe('tests via keyboard', () => {
cy.url().should('include', 'objective');
});
});

function getObjectiveByNameAndState(objectiveName: string, state: string) {
return getObjectivesByNameAndState(objectiveName, state).first().should('exist');
}

function selectFromThreeDotMenu(optionName: string) {
cy.contains(optionName).should('exist');
cy.get('.objective-three-dot-menu').contains(optionName).should('have.class', 'objective-menu-option').click();
}

function getObjectivesByNameAndState(objectiveName: string, state: string) {
return getObjectiveColumns()
.filter((index, element) => filterByObjectiveName(element, objectiveName))
.filter((index, element) => filterByState(element, state));
}

const filterByState = (element: HTMLElement, icon: string) => {
return Cypress.$(element).find(`[src='assets/icons/${icon}-icon.svg']`).length > 0;
};
const filterByObjectiveName = (element: HTMLElement, objectiveName: string) => {
return Cypress.$(element).find(`:contains("${objectiveName}")`).length > 0;
};

function getObjectiveColumns() {
return cy.get('.objective');
}
8 changes: 4 additions & 4 deletions frontend/cypress/e2e/teammanagement.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Team management tests', () => {
});

describe('Search', () => {
it('Search user', () => {
it.only('Search user', () => {
cy.get('app-team-management-banner').getByTestId('teamManagementSearch').click().type('pa');

cy.contains('.mat-mdc-autocomplete-panel mat-option', 'Paco Eggimann ([email protected])');
Expand All @@ -159,15 +159,15 @@ describe('Team management tests', () => {
cy.contains('app-member-detail h2', 'Robin Papierer');
});

it('Search team', () => {
it.only('Search team', () => {
cy.get('app-team-management-banner').getByTestId('teamManagementSearch').click().type('we are');

cy.contains('.mat-mdc-autocomplete-panel mat-option', 'we are cube.³').click();

cy.contains('app-member-list h2', 'we are cube.³');
});

it('Search mixed', () => {
it.only('Search mixed', () => {
cy.get('app-team-management-banner').getByTestId('teamManagementSearch').click().type('puz');

cy.contains('.mat-mdc-autocomplete-panel .mat-mdc-optgroup-label', 'Members');
Expand Down Expand Up @@ -280,7 +280,7 @@ describe('Team management tests', () => {
});
});

it.only('Navigate to user Esha and set as okr champion', () => {
it('Navigate to user Esha and set as okr champion', () => {
navigateToUser(nameEsha);
cy.getByTestId('edit-okr-champion-readonly').contains('OKR Champion:');
cy.getByTestId('edit-okr-champion-readonly').contains('Nein');
Expand Down
25 changes: 25 additions & 0 deletions frontend/cypress/support/objective-helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export function getObjectiveByNameAndState(objectiveName: string, state: string) {
return getObjectivesByNameAndState(objectiveName, state).first().should('exist');
}

export function selectFromThreeDotMenu(optionName: string) {
cy.contains(optionName).should('exist');
cy.get('.objective-three-dot-menu').contains(optionName).should('have.class', 'objective-menu-option').click();
}

function getObjectivesByNameAndState(objectiveName: string, state: string) {
return getObjectiveColumns()
.filter((index, element) => filterByObjectiveName(element, objectiveName))
.filter((index, element) => filterByState(element, state));
}

const filterByState = (element: HTMLElement, icon: string) => {
return Cypress.$(element).find(`[src='assets/icons/${icon}-icon.svg']`).length > 0;
};
const filterByObjectiveName = (element: HTMLElement, objectiveName: string) => {
return Cypress.$(element).find(`:contains("${objectiveName}")`).length > 0;
};

function getObjectiveColumns() {
return cy.get('.objective');
}

0 comments on commit d03a83b

Please sign in to comment.