Skip to content

Commit

Permalink
chore(tests): fix/update checkValue / textarea related e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ttbarnes committed Oct 10, 2024
1 parent f541f3e commit d495621
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ context('Insurance - Change your answers - Policy - Pre-credit period - Change f

cy.assertNoRadioOptionIsChecked();

cy.checkValue(field(CREDIT_PERIOD_WITH_BUYER).textarea(), '');
cy.checkTextareaValue({
fieldId: CREDIT_PERIOD_WITH_BUYER,
expectedValue: '',
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { autoCompleteField } from '../../../../../../pages/shared';
import { aboutGoodsOrServicesPage } from '../../../../../../pages/insurance/export-contract';
import FIELD_IDS from '../../../../../../constants/field-ids/insurance/export-contract';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import application from '../../../../../../fixtures/application';
Expand Down Expand Up @@ -67,7 +66,10 @@ context(
it('should have the submitted values', () => {
cy.navigateToUrl(url);

cy.checkValue(aboutGoodsOrServicesPage[DESCRIPTION].textarea(), application.EXPORT_CONTRACT[DESCRIPTION]);
cy.checkTextareaValue({
fieldId: DESCRIPTION,
expectedValue: application.EXPORT_CONTRACT[DESCRIPTION],
});

cy.assertNoRadioOptionIsChecked();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ context(
it('should have the submitted values', () => {
cy.navigateToUrl(url);

cy.checkValue(aboutGoodsOrServicesPage[DESCRIPTION].textarea(), application.EXPORT_CONTRACT[DESCRIPTION]);
cy.checkTextareaValue({
fieldId: DESCRIPTION,
expectedValue: application.EXPORT_CONTRACT[DESCRIPTION],
});

cy.assertYesRadioOptionIsChecked();

Expand Down Expand Up @@ -203,7 +206,10 @@ context(
it('should retain the submitted value when going back to the page', () => {
cy.clickBackLink();

cy.checkValue(descriptionField.textarea(), submittedValue);
cy.checkTextareaValue({
fieldId: DESCRIPTION,
expectedValue: submittedValue,
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ context('Insurance - Export contract - About goods or services page - form valid
includeFinalDestination: true,
});

cy.checkValue(descriptionField.textarea(), descriptionOverMaximum);
cy.checkTextareaValue({
fieldId: DESCRIPTION,
expectedValue: descriptionOverMaximum,
});

cy.assertYesRadioOptionIsChecked();

Expand All @@ -141,7 +144,10 @@ context('Insurance - Export contract - About goods or services page - form valid
description: descriptionOverMaximum,
});

cy.checkValue(descriptionField.textarea(), descriptionOverMaximum);
cy.checkTextareaValue({
fieldId: DESCRIPTION,
expectedValue: descriptionOverMaximum,
});

cy.assertNoRadioOptionIsChecked();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { summaryList, field } from '../../../../../../../pages/shared';
import { summaryList } from '../../../../../../../pages/shared';
import { FIELD_VALUES } from '../../../../../../../constants';
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance/policy';
import { INSURANCE_ROUTES, INSURANCE_ROOT } from '../../../../../../../constants/routes/insurance';
Expand Down Expand Up @@ -104,7 +104,10 @@ context('Insurance - Policy - Change your answers - Pre-credit period - As an ex

cy.assertNoRadioOptionIsChecked();

cy.checkValue(field(CREDIT_PERIOD_WITH_BUYER).textarea(), '');
cy.checkTextareaValue({
fieldId: CREDIT_PERIOD_WITH_BUYER,
expectedValue: '',
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ context(`Insurance - Policy - Pre-credit period page - ${story}`, () => {

const expectedValue = mockApplication.POLICY[CREDIT_PERIOD_WITH_BUYER];

cy.checkValue(fieldSelector(CREDIT_PERIOD_WITH_BUYER).textarea(), expectedValue);
cy.checkTextareaValue({
fieldId: CREDIT_PERIOD_WITH_BUYER,
expectedValue,
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { field as fieldSelector } from '../../../../../../pages/shared';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../constants/field-ids/insurance/policy';
import { POLICY_FIELDS as FIELDS } from '../../../../../../content-strings/fields/insurance/policy';
Expand All @@ -15,8 +14,6 @@ const {
[CREDIT_PERIOD_WITH_BUYER]: { MAXIMUM },
} = FIELDS;

const descriptionField = fieldSelector(CREDIT_PERIOD_WITH_BUYER);

const baseUrl = Cypress.config('baseUrl');

context('Insurance - Policy - Pre-credit period page - Save and go back', () => {
Expand Down Expand Up @@ -109,7 +106,11 @@ context('Insurance - Policy - Pre-credit period page - Save and go back', () =>
cy.clickSubmitButtonMultipleTimes({ count: 4 });

cy.assertYesRadioOptionIsChecked();
cy.checkValue(descriptionField.textarea(), '');

cy.checkTextareaValue({
fieldId: CREDIT_PERIOD_WITH_BUYER,
expectedValue: '',
});
});
});

Expand All @@ -135,7 +136,11 @@ context('Insurance - Policy - Pre-credit period page - Save and go back', () =>
cy.clickSubmitButtonMultipleTimes({ count: 4 });

cy.assertYesRadioOptionIsChecked();
cy.checkValue(descriptionField.textarea(), mockApplication.POLICY[CREDIT_PERIOD_WITH_BUYER]);

cy.checkTextareaValue({
fieldId: CREDIT_PERIOD_WITH_BUYER,
expectedValue: mockApplication.POLICY[CREDIT_PERIOD_WITH_BUYER],
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ context(
it('should have the submitted values', () => {
cy.navigateToUrl(natureOfBusinessUrl);

cy.checkValue(fieldSelector(GOODS_OR_SERVICES).textarea(), application.EXPORTER_BUSINESS[GOODS_OR_SERVICES]);
cy.checkTextareaValue({
fieldId: GOODS_OR_SERVICES,
expectedValue: application.EXPORTER_BUSINESS[GOODS_OR_SERVICES],
});

cy.checkValue(fieldSelector(YEARS_EXPORTING).input(), application.EXPORTER_BUSINESS[YEARS_EXPORTING]);
cy.checkValue(fieldSelector(EMPLOYEES_UK).input(), application.EXPORTER_BUSINESS[EMPLOYEES_UK]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ context('Insurance - Your business - Nature of your business page - Save and bac
// go through 2 business forms.
cy.clickSubmitButtonMultipleTimes({ count: 2 });

cy.checkValue(field(GOODS_OR_SERVICES).textarea(), application.EXPORTER_BUSINESS[GOODS_OR_SERVICES]);
cy.checkTextareaValue({
fieldId: GOODS_OR_SERVICES,
expectedValue: application.EXPORTER_BUSINESS[GOODS_OR_SERVICES],
});

cy.checkValue(field(YEARS_EXPORTING).input(), '');
cy.checkValue(field(EMPLOYEES_UK).input(), '');
});
Expand Down Expand Up @@ -107,7 +111,11 @@ context('Insurance - Your business - Nature of your business page - Save and bac
// company details submit
cy.clickSubmitButton();

cy.checkValue(field(GOODS_OR_SERVICES).textarea(), application.EXPORTER_BUSINESS[GOODS_OR_SERVICES]);
cy.checkTextareaValue({
fieldId: GOODS_OR_SERVICES,
expectedValue: application.EXPORTER_BUSINESS[GOODS_OR_SERVICES],
});

cy.checkValue(field(YEARS_EXPORTING).input(), application.EXPORTER_BUSINESS[YEARS_EXPORTING]);
cy.checkValue(field(EMPLOYEES_UK).input(), application.EXPORTER_BUSINESS[EMPLOYEES_UK]);
});
Expand Down

0 comments on commit d495621

Please sign in to comment.