Skip to content

Commit

Permalink
clean up objective tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 8, 2024
1 parent bcdec4e commit 86b30e1
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 133 deletions.
260 changes: 129 additions & 131 deletions frontend/cypress/e2e/objective.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,190 +5,188 @@ import CyObjectiveFormPage from '../support/objectiveFormPage';

describe('OKR Objective e2e tests', () => {
let op = new CyOverviewPage();
describe('tests via click', () => {
describe('Functionality', () => {
beforeEach(() => {
op = new CyOverviewPage();
cy.loginAsUser(users.gl);
op.visitCurrentQuarter();
});
beforeEach(() => {
op = new CyOverviewPage();
cy.loginAsUser(users.gl);
op.visitCurrentQuarter();
});

it(`Release Objective from Draft to Ongoing`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
ofp.fillObjectiveTitle('A objective in state draft');
ofp.submitDraftObjective();
describe('tests via click', () => {
it(`Release Objective from Draft to Ongoing`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
ofp.fillObjectiveTitle('A objective in state draft');
ofp.submitDraftObjective();

op.getObjectiveByNameAndState('A objective in state draft', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective veröffentlichen');
op.getObjectiveByNameAndState('A objective in state draft', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective veröffentlichen');

cy.contains('Objective veröffentlichen');
cy.contains('Soll dieses Objective veröffentlicht werden?');
cy.getByTestId('confirm-yes').click();
cy.contains('Objective veröffentlichen');
cy.contains('Soll dieses Objective veröffentlicht werden?');
cy.getByTestId('confirm-yes').click();

op.getObjectiveByNameAndState('A objective in state draft', 'ongoing').should('exist');
});
op.getObjectiveByNameAndState('A objective in state draft', 'ongoing').should('exist');
});

it(`Complete Objective with Successful`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
it(`Complete Objective with Successful`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();

ofp.fillObjectiveTitle('We want to complete this successful');
ofp.submitObjective();
ofp.fillObjectiveTitle('We want to complete this successful');
ofp.submitObjective();

op.getObjectiveByNameAndState('We want to complete this successful', 'ongoing')
.findByTestId('three-dot-menu')
.click();
op.selectFromThreeDotMenu('Objective abschliessen');
op.getObjectiveByNameAndState('We want to complete this successful', 'ongoing')
.findByTestId('three-dot-menu')
.click();
op.selectFromThreeDotMenu('Objective abschliessen');

cy.contains('Bewertung');
cy.contains('Objective erreicht');
cy.contains('Objective nicht erreicht');
cy.contains('Kommentar (optional)');
cy.contains('Objective abschliessen');
cy.contains('Abbrechen');
cy.contains('Bewertung');
cy.contains('Objective erreicht');
cy.contains('Objective nicht erreicht');
cy.contains('Kommentar (optional)');
cy.contains('Objective abschliessen');
cy.contains('Abbrechen');

cy.getByTestId('successful').click();
cy.getByTestId('submit').click();
cy.getByTestId('successful').click();
cy.getByTestId('submit').click();

op.getObjectiveByNameAndState('We want to complete this successful', 'successful');
});
op.getObjectiveByNameAndState('We want to complete this successful', 'successful');
});

it(`Complete Objective with Not-Successful`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
it(`Complete Objective with Not-Successful`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();

ofp.fillObjectiveTitle('A not successful objective');
ofp.submitObjective();
ofp.fillObjectiveTitle('A not successful objective');
ofp.submitObjective();

op.getObjectiveByNameAndState('A not successful objective', 'ongoing').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective abschliessen');
op.getObjectiveByNameAndState('A not successful objective', 'ongoing').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective abschliessen');

cy.contains('Bewertung');
cy.contains('Objective erreicht');
cy.contains('Objective nicht erreicht');
cy.contains('Kommentar (optional)');
cy.contains('Objective abschliessen');
cy.contains('Abbrechen');
cy.contains('Bewertung');
cy.contains('Objective erreicht');
cy.contains('Objective nicht erreicht');
cy.contains('Kommentar (optional)');
cy.contains('Objective abschliessen');
cy.contains('Abbrechen');

cy.getByTestId('not-successful').click();
cy.getByTestId('submit').click();
cy.getByTestId('not-successful').click();
cy.getByTestId('submit').click();

op.getObjectiveByNameAndState('A not successful objective', 'not-successful');
});
op.getObjectiveByNameAndState('A not successful objective', 'not-successful');
});

it(`Reopen Successful Objective`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
it(`Reopen Successful Objective`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();

ofp.fillObjectiveTitle('This objective will be reopened after');
ofp.submitObjective();
ofp.fillObjectiveTitle('This objective will be reopened after');
ofp.submitObjective();

op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing')
.findByTestId('three-dot-menu')
.click();
op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing')
.findByTestId('three-dot-menu')
.click();

op.selectFromThreeDotMenu('Objective abschliessen');
op.selectFromThreeDotMenu('Objective abschliessen');

cy.getByTestId('successful').click();
cy.getByTestId('submit').click();
cy.getByTestId('successful').click();
cy.getByTestId('submit').click();

cy.wait(500);
cy.wait(500);

op.getObjectiveByNameAndState('This objective will be reopened after', 'successful')
.findByTestId('three-dot-menu')
.click();
op.getObjectiveByNameAndState('This objective will be reopened after', 'successful')
.findByTestId('three-dot-menu')
.click();

op.selectFromThreeDotMenu('Objective wiedereröffnen');
op.selectFromThreeDotMenu('Objective wiedereröffnen');

op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing').should('exist');
});
op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing').should('exist');
});

it('Ongoing objective back to draft state', () => {
onlyOn('chrome');
const ofp: CyObjectiveFormPage = op.addObjective();
it('Ongoing objective back to draft state', () => {
onlyOn('chrome');
const ofp: CyObjectiveFormPage = op.addObjective();

ofp.fillObjectiveTitle('This objective will be returned to draft state');
ofp.submitObjective();
ofp.fillObjectiveTitle('This objective will be returned to draft state');
ofp.submitObjective();

op.getObjectiveByNameAndState('This objective will be returned to draft state', 'ongoing')
.findByTestId('three-dot-menu')
.click();
op.selectFromThreeDotMenu('Objective als Draft speichern');
op.getObjectiveByNameAndState('This objective will be returned to draft state', 'ongoing')
.findByTestId('three-dot-menu')
.click();
op.selectFromThreeDotMenu('Objective als Draft speichern');

cy.contains('Objective als Draft speichern');
cy.contains('Soll dieses Objective als Draft gespeichert werden?');
cy.getByTestId('confirm-yes').click();
cy.contains('Objective als Draft speichern');
cy.contains('Soll dieses Objective als Draft gespeichert werden?');
cy.getByTestId('confirm-yes').click();

op.getObjectiveByNameAndState('This objective will be returned to draft state', 'draft').should('exist');
});
op.getObjectiveByNameAndState('This objective will be returned to draft state', 'draft').should('exist');
});

it(`Search for Objective`, () => {
let ofp: CyObjectiveFormPage = op.addObjective();
it(`Search for Objective`, () => {
let ofp: CyObjectiveFormPage = op.addObjective();

ofp.fillObjectiveTitle('Search after this objective');
ofp.submitObjective();
ofp.fillObjectiveTitle('Search after this objective');
ofp.submitObjective();

ofp = op.addObjective();
ofp.fillObjectiveTitle('We dont want to search for this');
ofp.submitObjective();
ofp = op.addObjective();
ofp.fillObjectiveTitle('We dont want to search for this');
ofp.submitObjective();

cy.contains('Search after this objective');
cy.contains('We dont want to search for this');
cy.contains('Search after this objective');
cy.contains('We dont want to search for this');

cy.scrollTo(0, 0);
cy.wait(500);
cy.scrollTo(0, 0);
cy.wait(500);

cy.getByTestId('objectiveSearch').first().click();
cy.getByTestId('objectiveSearch').first().type('Search after').wait(350);
cy.getByTestId('objectiveSearch').first().click();
cy.getByTestId('objectiveSearch').first().type('Search after').wait(350);

cy.contains('Search after this objective');
cy.contains('We dont want to search for this').should('not.exist');
cy.contains('Search after this objective');
cy.contains('We dont want to search for this').should('not.exist');

cy.getByTestId('objectiveSearch').first().clear().type('this').wait(350);
cy.getByTestId('objectiveSearch').first().clear().type('this').wait(350);

cy.contains('Search after this objective');
cy.contains('We dont want to search for this');
cy.contains('Search after this objective');
cy.contains('We dont want to search for this');

cy.getByTestId('objectiveSearch').first().clear().type('dont want to').wait(350);
cy.getByTestId('objectiveSearch').first().clear().type('dont want to').wait(350);

cy.contains('We dont want to search for this');
cy.contains('Search after this objective').should('not.exist');
cy.contains('We dont want to search for this');
cy.contains('Search after this objective').should('not.exist');

cy.getByTestId('objectiveSearch').first().clear().type('there is no objective').wait(350);
cy.getByTestId('objectiveSearch').first().clear().type('there is no objective').wait(350);

cy.contains('We dont want to search for this').should('not.exist');
cy.contains('Search after this objective').should('not.exist');
});
cy.contains('We dont want to search for this').should('not.exist');
cy.contains('Search after this objective').should('not.exist');
});

it(`Create Objective in other quarter`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
ofp.fillObjectiveTitle('Objective in quarter 3');
ofp.selectQuarter('3');
ofp.submitObjective();
it(`Create Objective in other quarter`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
ofp.fillObjectiveTitle('Objective in quarter 3');
ofp.selectQuarter('3');
ofp.submitObjective();

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

op.visitNextQuarter();
op.visitNextQuarter();

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

it(`Edit Objective and move to other quarter`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
ofp.fillObjectiveTitle('Move to another quarter on edit');
ofp.submitObjective();
it(`Edit Objective and move to other quarter`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
ofp.fillObjectiveTitle('Move to another quarter on edit');
ofp.submitObjective();

op.getObjectiveByNameAndState('Move to another quarter on edit', 'ongoing')
.findByTestId('three-dot-menu')
.click();
op.getObjectiveByNameAndState('Move to another quarter on edit', 'ongoing')
.findByTestId('three-dot-menu')
.click();

op.selectFromThreeDotMenu('Objective bearbeiten');
op.selectFromThreeDotMenu('Objective bearbeiten');

ofp.selectQuarter('3');
ofp.submitObjective();
ofp.selectQuarter('3');
ofp.submitObjective();

cy.contains('Move to another quarter on edit').should('not.exist');
cy.contains('Move to another quarter on edit').should('not.exist');

op.visitNextQuarter();
cy.contains('Move to another quarter on edit');
});
op.visitNextQuarter();
cy.contains('Move to another quarter on edit');
});
});

Expand Down
4 changes: 3 additions & 1 deletion frontend/cypress/support/OverviewPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export default class CyOverviewPage {

selectFromThreeDotMenu(optionName: string) {
cy.contains(optionName).should('exist');
cy.get('.objective-three-dot-menu').contains(optionName).should('have.class', 'objective-menu-option').click();
const chainable = cy.get('.objective-three-dot-menu').contains(optionName).scrollIntoView();
chainable.should('have.class', 'objective-menu-option');
chainable.click();
}
}
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"watch:prod": "ng build --watch",
"test": "jest --silent",
"cypress:open": "cypress open",
"cypress:run": "cypress run --browser chrome --headed",
"cypress:run": "cypress run --browser chrome",
"cypress:open-test": "concurrently \"npm start\" \"cypress open\"",
"cypress:run-test": "npm run build && concurrently \"npm run serve:dist\" \"cypress run\"",
"format": "prettier --write \"./**/*.{js,ts,json,css,scss,html,md,yaml}\"",
Expand Down

0 comments on commit 86b30e1

Please sign in to comment.