Skip to content

Commit

Permalink
chore: deminimis tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast committed Sep 29, 2023
1 parent 8d946c6 commit 06f5fcb
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 4 deletions.
28 changes: 24 additions & 4 deletions frontend/benefit/applicant/browser-tests/page-model/WizardStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class WizardStep extends ApplicantPageComponent {
protected nextButton = this.component.findByRole('button', {
name: this.translations.applications.actions.continue,
});

protected previousButton = this.component.findByRole('button', {
name: this.translations.applications.actions.back,
});

protected saveAndCloseButton = this.component.findByRole('button', {
name: this.translations.applications.actions.saveAndContinueLater,
});
Expand All @@ -28,16 +33,31 @@ class WizardStep extends ApplicantPageComponent {
name: this.translations.applications.actions.deleteApplication,
});

public clickSubmit() {
public clickSubmit(): Promise<void> {
return t.click(this.nextButton);
}
public clickSaveAndClose() {

public expectSaveAndClose(): Promise<void> {
return t.expect(this.nextButton).notOk();
}

public expectSubmitDisabled(): Promise<void> {
return t.expect(this.nextButton.hasAttribute('disabled')).ok();
}

public clickPrevious(): Promise<void> {
return t.click(this.previousButton);
}

public clickSaveAndClose(): Promise<void> {
return t.click(this.saveAndCloseButton);
}
public async clickDeleteApplication() {

public async clickDeleteApplication(): Promise<void> {
return t.click(this.deleteButton);
}
public confirmDeleteApplication() {

public confirmDeleteApplication(): Promise<void> {
return t.click(this.dialogConfirmDeleteButton);
}
}
Expand Down
65 changes: 65 additions & 0 deletions frontend/benefit/applicant/browser-tests/page-model/step1.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { t } from 'testcafe';

import WizardStep from './WizardStep';

class Step1 extends WizardStep {
Expand All @@ -19,6 +21,27 @@ class Step1 extends WizardStep {
),
});

private deminimisAmount = this.component.findByRole('textbox', {
name: this.regexp(
this.translations.applications.sections.company.fields.deMinimisAidAmount
.label
),
});

private deminimisGranter = this.component.findByRole('textbox', {
name: this.regexp(
this.translations.applications.sections.company.fields.deMinimisAidGranter
.label
),
});

private deminimisGrantedAt = this.component.findByRole('textbox', {
name: this.regexp(
this.translations.applications.sections.company.fields
.deMinimisAidGrantedAt.label
),
});

private lastName = this.component.findByRole('textbox', {
name: this.regexp(
this.translations.applications.sections.company.fields
Expand Down Expand Up @@ -64,6 +87,18 @@ class Step1 extends WizardStep {
.no,
});

private deMinimisAidTrue = this.within(
this.component.getByRole('group', {
name: this.regexp(
this.translations.applications.sections.company.fields.deMinimisAid
.label
),
})
).findByRole('radio', {
name: this.translations.applications.sections.company.fields.deMinimisAid
.yes,
});

hasImmediateManagerCheckbox = this.component.findByRole('checkbox', {
name: this.regexp(
this.translations.applications.sections.employee.fields
Expand Down Expand Up @@ -106,6 +141,32 @@ class Step1 extends WizardStep {
return this.fillInput(this.email, email);
}

public async fillDeminimisAid(
granter?: string,
amount?: string,
grantedAt?: string
): Promise<void> {
if (granter) await this.fillInput(this.deminimisGranter, granter);
if (amount) await this.fillInput(this.deminimisAmount, amount);
if (grantedAt) await this.fillInput(this.deminimisGrantedAt, grantedAt);
return this.clickDeminimisSave();
}

private deminimisSave = this.component.findByRole('button', {
name: this.translations.applications.sections.company.deMinimisAidsAdd,
});

private deminimisRemove = (index: number): SelectorPromise =>
this.component.findByTestId(`deminimis-remove-${index}`);

public clickDeminimisSave(): Promise<void> {
return t.click(this.deminimisSave);
}

public clickDeminimisRemove(index: number): Promise<void> {
return t.click(this.deminimisRemove(index));
}

public selectNoBusinessActivities(): Promise<void> {
return this.clickSelectRadioButton(this.businessActivitiesFalse);
}
Expand All @@ -114,6 +175,10 @@ class Step1 extends WizardStep {
return this.clickSelectRadioButton(this.deMinimisAidFalse);
}

public selectYesDeMinimis(): Promise<void> {
return this.clickSelectRadioButton(this.deMinimisAidTrue);
}

public selectNocoOperationNegotiations(): Promise<void> {
return this.clickSelectRadioButton(this.coOperationNegotiationsFalse);
}
Expand Down
7 changes: 7 additions & 0 deletions frontend/benefit/applicant/browser-tests/utils/url.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { getUrl } from '@frontend/shared/browser-tests/utils/url.utils';
import { ClientFunction } from 'testcafe';

export const getFrontendUrl = (path = ''): string =>
getUrl(process.env.APPLICANT_URL ?? 'https://localhost:3000', path);

const goBack = ClientFunction(() => window.history.back());

export const clickBrowserBackButton = async (): Promise<void> => {
await goBack();
};

0 comments on commit 06f5fcb

Please sign in to comment.