Skip to content

Commit

Permalink
fix objective tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 8, 2024
1 parent c9ad28a commit e7cc87f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 14 deletions.
49 changes: 36 additions & 13 deletions frontend/cypress/e2e/objective.cy.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import * as users from '../fixtures/users.json';
import { onlyOn } from '@cypress/skip-test';
import CyOverviewPage from '../support/OverviewPage';
import CyObjectiveFormPage from '../support/objectiveFormPage';

describe('OKR Objective e2e tests', () => {
const op = new CyOverviewPage();

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

it(`Release Objective from Draft to Ongoing`, () => {
op.addObjective();
cy.fillOutObjective('A objective in state draft', 'safe-draft', undefined, '', false);
const ofp = new CyObjectiveFormPage();
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');
Expand All @@ -28,7 +31,9 @@ describe('OKR Objective e2e tests', () => {

it(`Complete Objective with Successful`, () => {
op.addObjective();
cy.fillOutObjective('We want to complete this successful', 'safe', undefined, '', false);
const ofp = new CyObjectiveFormPage();
ofp.fillObjectiveTitle('We want to complete this successful');
ofp.submitObjective();

op.getObjectiveByNameAndState('We want to complete this successful', 'ongoing')
.findByTestId('three-dot-menu')
Expand All @@ -50,7 +55,11 @@ describe('OKR Objective e2e tests', () => {

it(`Complete Objective with Not-Successful`, () => {
op.addObjective();
cy.fillOutObjective('A not successful objective', 'safe', undefined, '', false);

const ofp = new CyObjectiveFormPage();
ofp.fillObjectiveTitle('A not successful objective');
ofp.submitObjective();

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

Expand All @@ -69,7 +78,9 @@ describe('OKR Objective e2e tests', () => {

it(`Reopen Successful Objective`, () => {
op.addObjective();
cy.fillOutObjective('This objective will be reopened after', 'safe', undefined, '', false);
const ofp = new CyObjectiveFormPage();
ofp.fillObjectiveTitle('This objective will be reopened after');
ofp.submitObjective();

op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing')
.findByTestId('three-dot-menu')
Expand All @@ -94,7 +105,9 @@ describe('OKR Objective e2e tests', () => {
it('Ongoing objective back to draft state', () => {
onlyOn('chrome');
op.addObjective();
cy.fillOutObjective('This objective will be returned to draft state', 'safe', undefined, '', false);
const ofp = new CyObjectiveFormPage();
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')
Expand All @@ -110,10 +123,13 @@ describe('OKR Objective e2e tests', () => {

it(`Search for Objective`, () => {
op.addObjective();
cy.fillOutObjective('Search after this objective', 'safe', undefined, '', false);
const ofp = new CyObjectiveFormPage();
ofp.fillObjectiveTitle('Search after this objective');
ofp.submitObjective();

cy.getByTestId('add-objective').first().click();
cy.fillOutObjective('We dont want to search for this', 'safe', undefined, '', false);
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');
Expand Down Expand Up @@ -145,7 +161,10 @@ describe('OKR Objective e2e tests', () => {

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

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

Expand All @@ -156,14 +175,18 @@ describe('OKR Objective e2e tests', () => {

it(`Edit Objective and move to other quarter`, () => {
op.addObjective();
cy.fillOutObjective('Move to another quarter on edit', 'safe', undefined, '', false);
const ofp = new CyObjectiveFormPage();
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.selectFromThreeDotMenu('Objective bearbeiten');

cy.fillOutObjective('Move to another quarter on edit', 'safe', '3', '', false);
ofp.selectQuarter('3');
ofp.submitObjective();

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

Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/support/OverviewPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class CyOverviewPage {
}

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

selectFromThreeDotMenu(optionName: string) {
Expand Down
45 changes: 45 additions & 0 deletions frontend/cypress/support/objectiveFormPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {quarter} from "../../src/app/shared/testData";

export default class CyObjectiveFormPage {


// init() {
// cy.get("app-objective-form").should('exist');
// }

visit() {
cy.visit('/objective-form');
}

fillObjectiveTitle(title: string) {
this.fillInput('title', title);
}

fillObjectiveDescription(description: string) {
this.fillInput('description', description);
}

selectQuarter(quarter: string) {
cy.get('select#quarter').select(quarter);
}

toggleCreateKeyResults() {
cy.getByTestId('keyResult-checkbox').find("[type='checkbox']").check();
}

submitObjective() {
cy.getByTestId('safe').click();
}
submitDraftObjective() {
cy.getByTestId('safe-draft').click();
}

cancelObjective() {
cy.getByTestId('cancel').click();
}

private fillInput(testId:string, value: string) {
cy.getByTestId(testId).clear();
cy.getByTestId(testId).type(value);
}
}

0 comments on commit e7cc87f

Please sign in to comment.