Skip to content

Commit

Permalink
Merge branch 'main-iterations' into feat/EMS-3829
Browse files Browse the repository at this point in the history
  • Loading branch information
ttbarnes committed Sep 18, 2024
2 parents 14aeae1 + e059ccc commit 849333f
Show file tree
Hide file tree
Showing 61 changed files with 2,744 additions and 2,737 deletions.
11 changes: 10 additions & 1 deletion e2e-tests/commands/insurance/check-policy-summary-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const {
CONTRACT_POLICY: {
REQUESTED_START_DATE,
POLICY_CURRENCY_CODE,
SINGLE: { CONTRACT_COMPLETION_DATE, TOTAL_CONTRACT_VALUE },
SINGLE: { CONTRACT_COMPLETION_DATE, REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE },
MULTIPLE: { TOTAL_MONTHS_OF_COVER },
},
EXPORT_VALUE: {
Expand Down Expand Up @@ -124,6 +124,15 @@ const checkPolicySummaryList = {

const expectedValue = formatCurrency(application.POLICY[fieldId], currencyCode);

cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText);
},
[REQUESTED_CREDIT_LIMIT]: (currencyCode) => {
const fieldId = REQUESTED_CREDIT_LIMIT;

const { expectedKey, expectedChangeLinkText } = getSummaryListField(fieldId, CONTRACT_POLICY.SINGLE);

const expectedValue = formatCurrency(application.POLICY[fieldId], currencyCode);

cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText);
},
},
Expand Down
10 changes: 4 additions & 6 deletions e2e-tests/commands/insurance/complete-export-value-form.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { INSURANCE_FIELD_IDS } from '../../constants/field-ids/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../constants/field-ids/insurance/policy';
import { multipleContractPolicyExportValuePage } from '../../pages/insurance/policy';
import { field } from '../../pages/shared';
import application from '../../fixtures/application';

const {
POLICY: {
EXPORT_VALUE: {
MULTIPLE: { TOTAL_SALES_TO_BUYER, MAXIMUM_BUYER_WILL_OWE },
},
EXPORT_VALUE: {
MULTIPLE: { TOTAL_SALES_TO_BUYER, MAXIMUM_BUYER_WILL_OWE },
},
} = INSURANCE_FIELD_IDS;
} = POLICY_FIELD_IDS;

/**
* completeExportValueForm
Expand Down
8 changes: 3 additions & 5 deletions e2e-tests/commands/insurance/complete-name-on-policy-form.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { INSURANCE_FIELD_IDS } from '../../constants/field-ids/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../constants/field-ids/insurance/policy';
import { field } from '../../pages/shared';
import application from '../../fixtures/application';

const {
POLICY: {
NAME_ON_POLICY: { POSITION, SAME_NAME, OTHER_NAME },
},
} = INSURANCE_FIELD_IDS;
NAME_ON_POLICY: { POSITION, SAME_NAME, OTHER_NAME },
} = POLICY_FIELD_IDS;

const { POLICY_CONTACT } = application;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { INSURANCE_FIELD_IDS } from '../../constants/field-ids/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../constants/field-ids/insurance/policy';
import { field } from '../../pages/shared';
import application from '../../fixtures/application';

const {
POLICY: {
CONTRACT_POLICY: {
SINGLE: { REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE },
},
CONTRACT_POLICY: {
SINGLE: { REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE },
},
} = INSURANCE_FIELD_IDS;
} = POLICY_FIELD_IDS;

/**
* completeTotalContractValueForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import checkSummaryList from '../../insurance/check-policy-summary-list';
const {
TYPE_OF_POLICY: { POLICY_TYPE },
CONTRACT_POLICY: {
SINGLE: { CONTRACT_COMPLETION_DATE, TOTAL_CONTRACT_VALUE },
SINGLE: { CONTRACT_COMPLETION_DATE, REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE },
},
} = POLICY_FIELD_IDS;

Expand All @@ -20,6 +20,7 @@ const assertGenericSinglePolicySummaryListRows = () => {

checkSummaryList.singleContractPolicy[CONTRACT_COMPLETION_DATE]();
checkSummaryList.singleContractPolicy[TOTAL_CONTRACT_VALUE]();
checkSummaryList.singleContractPolicy[REQUESTED_CREDIT_LIMIT]();
};

export default assertGenericSinglePolicySummaryListRows;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FIELD_VALUES } from '../../../../../../../../constants';
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance';
import { INSURANCE_FIELD_IDS } from '../../../../../../../../constants/field-ids/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../../../constants/field-ids/insurance/policy';
import { summaryList } from '../../../../../../../../pages/shared';
import { typeOfPolicyPage } from '../../../../../../../../pages/insurance/policy';
import { createTimestampFromNumbers, formatDate } from '../../../../../../../../helpers/date';
Expand All @@ -14,13 +14,11 @@ const {
} = INSURANCE_ROUTES;

const {
POLICY: {
TYPE_OF_POLICY: { POLICY_TYPE },
CONTRACT_POLICY: {
SINGLE: { CONTRACT_COMPLETION_DATE, TOTAL_CONTRACT_VALUE },
},
TYPE_OF_POLICY: { POLICY_TYPE },
CONTRACT_POLICY: {
SINGLE: { CONTRACT_COMPLETION_DATE, TOTAL_CONTRACT_VALUE },
},
} = INSURANCE_FIELD_IDS;
} = POLICY_FIELD_IDS;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const {
POLICY: {
CONTRACT_POLICY: {
REQUESTED_START_DATE,
SINGLE: { CONTRACT_COMPLETION_DATE, TOTAL_CONTRACT_VALUE },
SINGLE: { CONTRACT_COMPLETION_DATE, REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE },
},
},
} = INSURANCE_FIELD_IDS;
Expand Down Expand Up @@ -196,7 +196,50 @@ context('Insurance - Change your answers - Policy - Single contract policy - Sum

summaryList.field(fieldId).changeLink().click();

fieldVariables.newValueInput = application.POLICY[fieldId] - 500;
cy.changeAnswerField(fieldVariables, field(fieldId).input());
});

it(`should redirect to ${TYPE_OF_POLICY}`, () => {
cy.assertChangeAnswersPageUrl({ referenceNumber, route: TYPE_OF_POLICY, fieldId });
});

it('should render the new answer', () => {
fieldVariables.newValue = formatCurrency(fieldVariables.newValueInput);
cy.checkChangeAnswerRendered({ fieldVariables });
});
});
});

describe(REQUESTED_CREDIT_LIMIT, () => {
const fieldId = REQUESTED_CREDIT_LIMIT;

const fieldVariables = {
route: SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE_CHECK_AND_CHANGE,
newValueInput: application.POLICY[fieldId] - 100,
fieldId,
referenceNumber,
summaryList,
changeLink: summaryList.field(fieldId).changeLink,
};

describe('when clicking the `change` link', () => {
beforeEach(() => {
cy.navigateToUrl(url);

cy.checkChangeLinkUrl(fieldVariables, referenceNumber);
});

it(`should redirect to ${SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE_CHECK_AND_CHANGE}`, () => {
cy.assertChangeAnswersPageUrl({ referenceNumber, route: fieldVariables.route, fieldId });
});
});

describe('form submission with a new answer', () => {
beforeEach(() => {
cy.navigateToUrl(url);

summaryList.field(fieldId).changeLink().click();

cy.changeAnswerField(fieldVariables, field(fieldId).input());
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FIELD_VALUES } from '../../../../../../../../constants';
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance';
import { INSURANCE_FIELD_IDS } from '../../../../../../../../constants/field-ids/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../../../constants/field-ids/insurance/policy';
import { summaryList } from '../../../../../../../../pages/shared';
import formatCurrency from '../../../../../../../../helpers/format-currency';
import application from '../../../../../../../../fixtures/application';
Expand All @@ -12,16 +12,14 @@ const {
} = INSURANCE_ROUTES;

const {
POLICY: {
TYPE_OF_POLICY: { POLICY_TYPE },
CONTRACT_POLICY: {
MULTIPLE: { TOTAL_MONTHS_OF_COVER },
},
EXPORT_VALUE: {
MULTIPLE: { TOTAL_SALES_TO_BUYER, MAXIMUM_BUYER_WILL_OWE },
},
TYPE_OF_POLICY: { POLICY_TYPE },
CONTRACT_POLICY: {
MULTIPLE: { TOTAL_MONTHS_OF_COVER },
},
} = INSURANCE_FIELD_IDS;
EXPORT_VALUE: {
MULTIPLE: { TOTAL_SALES_TO_BUYER, MAXIMUM_BUYER_WILL_OWE },
},
} = POLICY_FIELD_IDS;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { status, summaryList } from '../../../../../../../pages/shared';
import { field, status, summaryList } from '../../../../../../../pages/shared';
import { INSURANCE_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance';
import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance';
import { YOUR_BUYER_FIELDS as FIELDS } from '../../../../../../../content-strings/fields/insurance/your-buyer';
import application from '../../../../../../../fixtures/application';
import formatCurrency from '../../../../../../../helpers/format-currency';
import { EUR_CURRENCY_CODE, NON_STANDARD_CURRENCY_CODE, SYMBOLS } from '../../../../../../../fixtures/currencies';
import { EUR_CURRENCY_CODE, NON_STANDARD_CURRENCY_CODE, NON_STANDARD_CURRENCY_NAME, SYMBOLS } from '../../../../../../../fixtures/currencies';

const {
CURRENCY: { CURRENCY_CODE },
Expand All @@ -21,7 +22,7 @@ const baseUrl = Cypress.config('baseUrl');
context('Insurance - Check your answers - Your buyer - Alternative currency - As an exporter, I want to change my answers to an alternative currency', () => {
let referenceNumber;
let url;
const fieldId = CURRENCY_CODE;
const currencyFieldId = CURRENCY_CODE;

before(() => {
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
Expand Down Expand Up @@ -61,25 +62,25 @@ context('Insurance - Check your answers - Your buyer - Alternative currency - As
it(`should redirect to ${CURRENCY_OF_LATE_PAYMENTS_CHECK_AND_CHANGE}`, () => {
cy.navigateToUrl(url);

summaryList.field(fieldId).changeLink().click();
summaryList.field(currencyFieldId).changeLink().click();

cy.assertChangeAnswersPageUrl({ referenceNumber, route: CURRENCY_OF_LATE_PAYMENTS_CHECK_AND_CHANGE, fieldId });
cy.assertChangeAnswersPageUrl({ referenceNumber, route: CURRENCY_OF_LATE_PAYMENTS_CHECK_AND_CHANGE, fieldId: currencyFieldId });
});
});

describe('form submission with a new answer', () => {
beforeEach(() => {
cy.navigateToUrl(url);

summaryList.field(fieldId).changeLink().click();
summaryList.field(currencyFieldId).changeLink().click();

cy.completeAndSubmitAlternativeCurrencyForm({ isoCode: EUR_CURRENCY_CODE, clickAlternativeCurrencyLink: false });

cy.clickSubmitButton();
});

it(`should redirect to ${YOUR_BUYER}`, () => {
cy.assertChangeAnswersPageUrl({ referenceNumber, route: YOUR_BUYER, fieldId });
cy.assertChangeAnswersPageUrl({ referenceNumber, route: YOUR_BUYER, fieldId: currencyFieldId });
});

it(`should render the new answer for ${CURRENCY_CODE} including ${SYMBOLS.EUR}`, () => {
Expand Down Expand Up @@ -111,25 +112,25 @@ context('Insurance - Check your answers - Your buyer - Alternative currency - As
it(`should redirect to ${CURRENCY_OF_LATE_PAYMENTS_CHECK_AND_CHANGE}`, () => {
cy.navigateToUrl(url);

summaryList.field(fieldId).changeLink().click();
summaryList.field(currencyFieldId).changeLink().click();

cy.assertChangeAnswersPageUrl({ referenceNumber, route: CURRENCY_OF_LATE_PAYMENTS_CHECK_AND_CHANGE, fieldId });
cy.assertChangeAnswersPageUrl({ referenceNumber, route: CURRENCY_OF_LATE_PAYMENTS_CHECK_AND_CHANGE, fieldId: currencyFieldId });
});
});

describe('form submission with a new answer', () => {
beforeEach(() => {
cy.navigateToUrl(url);

summaryList.field(fieldId).changeLink().click();
summaryList.field(currencyFieldId).changeLink().click();

cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency: true, clickAlternativeCurrencyLink: false });

cy.clickSubmitButton();
});

it(`should redirect to ${YOUR_BUYER}`, () => {
cy.assertChangeAnswersPageUrl({ referenceNumber, route: YOUR_BUYER, fieldId });
cy.assertChangeAnswersPageUrl({ referenceNumber, route: YOUR_BUYER, fieldId: currencyFieldId });
});

it(`should render the new answer for ${CURRENCY_CODE}`, () => {
Expand All @@ -152,6 +153,30 @@ context('Insurance - Check your answers - Your buyer - Alternative currency - As
cy.checkText(row.value(), expected);
});

it(`should render the ${TOTAL_AMOUNT_OVERDUE} answer with the alternative currency on the outstanding or overdue payments page`, () => {
const fieldId = TOTAL_AMOUNT_OVERDUE;

summaryList.field(fieldId).changeLink().click();

cy.assertCopyWithCurrencyName({
expectedCopy: FIELDS[fieldId].LABEL,
currencyName: NON_STANDARD_CURRENCY_NAME,
selector: field(fieldId).label(),
});
});

it(`should render the ${TOTAL_OUTSTANDING_PAYMENTS} answer with the alternative currency on the outstanding or overdue payments page`, () => {
const fieldId = TOTAL_OUTSTANDING_PAYMENTS;

summaryList.field(fieldId).changeLink().click();

cy.assertCopyWithCurrencyName({
expectedCopy: FIELDS[fieldId].LABEL,
currencyName: NON_STANDARD_CURRENCY_NAME,
selector: field(fieldId).label(),
});
});

it('should retain a `completed` status tag', () => {
cy.checkTaskStatusCompleted(status);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { summaryList } from '../../../../../../../pages/shared';
import { FIELD_VALUES } from '../../../../../../../constants';
import { INSURANCE_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance';
import { POLICY as POLICY_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance/policy';
import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance';
import checkSummaryList from '../../../../../../../commands/insurance/check-policy-summary-list';

Expand All @@ -10,13 +10,11 @@ const {
} = INSURANCE_ROUTES;

const {
POLICY: {
TYPE_OF_POLICY: { POLICY_TYPE },
CONTRACT_POLICY: {
SINGLE: { CONTRACT_COMPLETION_DATE, TOTAL_CONTRACT_VALUE },
},
TYPE_OF_POLICY: { POLICY_TYPE },
CONTRACT_POLICY: {
SINGLE: { CONTRACT_COMPLETION_DATE, REQUESTED_CREDIT_LIMIT, TOTAL_CONTRACT_VALUE },
},
} = INSURANCE_FIELD_IDS;
} = POLICY_FIELD_IDS;

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

Expand Down Expand Up @@ -103,6 +101,10 @@ context('Insurance - Policy - Change your answers - Policy type - multiple to si
it(TOTAL_CONTRACT_VALUE, () => {
checkSummaryList.singleContractPolicy[TOTAL_CONTRACT_VALUE]();
});

it(REQUESTED_CREDIT_LIMIT, () => {
checkSummaryList.singleContractPolicy[REQUESTED_CREDIT_LIMIT]();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
const {
TYPE_OF_POLICY: { POLICY_TYPE },
CONTRACT_POLICY: {
SINGLE: { TOTAL_CONTRACT_VALUE },
SINGLE: { TOTAL_CONTRACT_VALUE, REQUESTED_CREDIT_LIMIT },
},
} = FIELD_IDS;

Expand Down Expand Up @@ -67,5 +67,6 @@ context('Insurance - Policy - Change your answers - Policy type - single to mult
cy.navigateToUrl(totalContractValueUrl);

field(TOTAL_CONTRACT_VALUE).input().should('have.value', '');
field(REQUESTED_CREDIT_LIMIT).input().should('have.value', '');
});
});
Loading

0 comments on commit 849333f

Please sign in to comment.