Skip to content

Commit

Permalink
refactor base form component
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Nov 8, 2024
1 parent d8ac49a commit f63ec07
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
8 changes: 7 additions & 1 deletion frontend/cypress/support/baseFormPage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { E } from '@angular/cdk/keycodes';

export default abstract class BaseFormPage {
constructor() {
this.init();
}

abstract init(): void;
init() {
this.getPage().should('exist');
}

submit() {
cy.getByTestId('safe').click();
Expand All @@ -26,6 +30,8 @@ export default abstract class BaseFormPage {
return this;
}

abstract getPage(): Cypress.Chainable<JQuery<HTMLElement>>;

static with<T extends BaseFormPage>(this: new () => T): T {
return new this();
}
Expand Down
25 changes: 25 additions & 0 deletions frontend/cypress/support/confirmComponentPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import BaseFormPage from './baseFormPage';

export default class CyConfirmComponentPage extends BaseFormPage {
checkTitle(title: string) {
this.getPage().contains(title).should('exist');
return this;
}

checkDescription(title: string) {
this.getPage().contains(title).should('exist');
return this;
}

override submit() {
cy.getByTestId('confirm-yes').click();
}

override cancel() {
cy.getByTestId('confirm-no').click();
}

getPage(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.get('app-confirm-dialog');
}
}
8 changes: 4 additions & 4 deletions frontend/cypress/support/keyresultFormPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import BaseFormPage from './baseFormPage';
import { Unit } from '../../src/app/shared/types/enums/Unit';

export default class CyKeyResultFormPage extends BaseFormPage {
init() {
cy.get('app-objective-form').should('exist');
}

fillKeyresultTitle(title: string) {
this.fillInput('titleInput', title);
return this;
Expand All @@ -32,4 +28,8 @@ export default class CyKeyResultFormPage extends BaseFormPage {
saveAndNew() {
cy.getByTestId('saveAndNew').click();
}

getPage(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.get('app-objective-form');
}
}
8 changes: 4 additions & 4 deletions frontend/cypress/support/objectiveFormPage.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import BaseFormPage from './baseFormPage';

export default class CyObjectiveFormPage extends BaseFormPage {
init() {
cy.get('app-objective-form').should('exist');
}

fillObjectiveTitle(title: string) {
this.fillInput('title', title);
return this;
Expand All @@ -28,4 +24,8 @@ export default class CyObjectiveFormPage extends BaseFormPage {
submitDraftObjective() {
cy.getByTestId('safe-draft').click();
}

getPage(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.get('app-objective-form').should('exist');
}
}

0 comments on commit f63ec07

Please sign in to comment.