Skip to content

Commit

Permalink
introduce base form compoennt
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 8, 2024
1 parent 0f27fa4 commit b131f9c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 42 deletions.
22 changes: 8 additions & 14 deletions frontend/cypress/e2e/objective-backlog.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ describe('OKR Objective Backlog e2e tests', () => {
op.getObjectiveByNameAndState('Move to another quarter on edit', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective bearbeiten');

CyObjectiveFormPage.with()
.fillObjectiveTitle('This goes now to backlog')
.selectQuarter('Backlog')
.submitObjective();
CyObjectiveFormPage.with().fillObjectiveTitle('This goes now to backlog').selectQuarter('Backlog').submit();

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

Expand All @@ -42,7 +39,7 @@ describe('OKR Objective Backlog e2e tests', () => {
});

it(`Edit ongoing Objective can not choose backlog in quarter select`, () => {
op.addObjective().fillObjectiveTitle('We can not move this to backlog').submitObjective();
op.addObjective().fillObjectiveTitle('We can not move this to backlog').submit();

op.getObjectiveByNameAndState('We can not move this to backlog', 'ongoing').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective bearbeiten');
Expand Down Expand Up @@ -81,7 +78,7 @@ describe('OKR Objective Backlog e2e tests', () => {
op.getObjectiveByNameAndState('This is possible for edit', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective bearbeiten');

CyObjectiveFormPage.with().fillObjectiveTitle('My new title').submitObjective();
CyObjectiveFormPage.with().fillObjectiveTitle('My new title').submit();

op.getObjectiveByNameAndState('My new title', 'draft');
});
Expand All @@ -93,7 +90,7 @@ describe('OKR Objective Backlog e2e tests', () => {
op.getObjectiveByNameAndState('This goes to other quarter later', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective bearbeiten');

CyObjectiveFormPage.with().selectQuarter('GJ ForTests').submitObjective();
CyObjectiveFormPage.with().selectQuarter('GJ ForTests').submit();

op.visitGJForTests();
op.getObjectiveByNameAndState('This goes to other quarter later', 'draft');
Expand All @@ -106,7 +103,7 @@ describe('OKR Objective Backlog e2e tests', () => {
op.getObjectiveByNameAndState('Ready for duplicate in backlog', 'draft').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective duplizieren');

CyObjectiveFormPage.with().fillObjectiveTitle('This is a new duplication in backlog').submitObjective();
CyObjectiveFormPage.with().fillObjectiveTitle('This is a new duplication in backlog').submit();

op.getObjectiveByNameAndState('Ready for duplicate in backlog', 'draft');
op.getObjectiveByNameAndState('This is a new duplication in backlog', 'draft');
Expand All @@ -120,10 +117,7 @@ describe('OKR Objective Backlog e2e tests', () => {
.click();
op.selectFromThreeDotMenu('Objective duplizieren');

CyObjectiveFormPage.with()
.fillObjectiveTitle('New duplication from backlog')
.selectQuarter('GJ ForTests')
.submitObjective();
CyObjectiveFormPage.with().fillObjectiveTitle('New duplication from backlog').selectQuarter('GJ ForTests').submit();

op.getObjectiveByNameAndState('Ready for duplicate to another quarter', 'draft').should('exist');
// op.getObjectivesByNameAndState('New duplication from backlog', 'draft').should("have.length", 0)
Expand All @@ -132,14 +126,14 @@ describe('OKR Objective Backlog e2e tests', () => {
});

it(`Can duplicate ongoing Objective to backlog`, () => {
op.addObjective().fillObjectiveTitle('Possible to duplicate into backlog').submitObjective();
op.addObjective().fillObjectiveTitle('Possible to duplicate into backlog').submit();

op.getObjectiveByNameAndState('Possible to duplicate into backlog', 'ongoing')
.findByTestId('three-dot-menu')
.click();
op.selectFromThreeDotMenu('Objective duplizieren');

CyObjectiveFormPage.with().selectQuarter('Backlog').submitObjective();
CyObjectiveFormPage.with().selectQuarter('Backlog').submit();

op.visitBacklogQuarter();
cy.contains('Possible to duplicate into backlog');
Expand Down
18 changes: 9 additions & 9 deletions frontend/cypress/e2e/objective.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('OKR Objective e2e tests', () => {
const ofp: CyObjectiveFormPage = op.addObjective();

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

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

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

op.getObjectiveByNameAndState('A not successful objective', 'ongoing').findByTestId('three-dot-menu').click();
op.selectFromThreeDotMenu('Objective abschliessen');
Expand All @@ -77,7 +77,7 @@ describe('OKR Objective e2e tests', () => {
const ofp: CyObjectiveFormPage = op.addObjective();

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

op.getObjectiveByNameAndState('This objective will be reopened after', 'ongoing')
.findByTestId('three-dot-menu')
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('OKR Objective e2e tests', () => {
const ofp: CyObjectiveFormPage = op.addObjective();

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

op.getObjectiveByNameAndState('This objective will be returned to draft state', 'ongoing')
.findByTestId('three-dot-menu')
Expand All @@ -126,11 +126,11 @@ describe('OKR Objective e2e tests', () => {
let ofp: CyObjectiveFormPage = op.addObjective();

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

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

cy.contains('Search after this objective');
cy.contains('We dont want to search for this');
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('OKR Objective e2e tests', () => {
const ofp: CyObjectiveFormPage = op.addObjective();
ofp.fillObjectiveTitle('Objective in quarter 3');
ofp.selectQuarter('3');
ofp.submitObjective();
ofp.submit();

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

Expand All @@ -176,7 +176,7 @@ describe('OKR Objective e2e tests', () => {
it(`Edit Objective and move to other quarter`, () => {
const ofp: CyObjectiveFormPage = op.addObjective();
ofp.fillObjectiveTitle('Move to another quarter on edit');
ofp.submitObjective();
ofp.submit();

op.getObjectiveByNameAndState('Move to another quarter on edit', 'ongoing')
.findByTestId('three-dot-menu')
Expand All @@ -185,7 +185,7 @@ describe('OKR Objective e2e tests', () => {
op.selectFromThreeDotMenu('Objective bearbeiten');

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

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

Expand Down
24 changes: 24 additions & 0 deletions frontend/cypress/support/baseFormPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export default abstract class BaseFormPage {
constructor() {
this.init();
}

abstract init(): void;

submit() {
cy.getByTestId('safe').click();
}

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

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

static createInstance<T extends BaseFormPage>(): T {
throw new Error('Method not implemented.'); // Placeholder for enforcing implementation
}
}
21 changes: 2 additions & 19 deletions frontend/cypress/support/objectiveFormPage.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { quarter } from '../../src/app/shared/testData';

export default class CyObjectiveFormPage {
constructor() {
this.init();
}
import BaseFormPage from './baseFormPage';

export default class CyObjectiveFormPage extends BaseFormPage {
init() {
cy.get('app-objective-form').should('exist');
}
Expand Down Expand Up @@ -33,23 +29,10 @@ export default class CyObjectiveFormPage {
return this;
}

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);
}

static with() {
return new CyObjectiveFormPage();
}
Expand Down

0 comments on commit b131f9c

Please sign in to comment.