Skip to content

Commit

Permalink
feat(EMS-3769-3770-3771-3772-3782): buyer - split outstanding/overdue…
Browse files Browse the repository at this point in the history
… and failed payments (#3012)

* feat(EMS-3769-7-1-2): split your buyer section with relevant sections

* feat(EMS-3769-7-1-2): fix some failing tests

* feat(EMS-3769-7-1-2): added new check your answers row

* feat(EMS-3769-7-1-2): fixed failing ui tests

* feat(EMS-3769-7-1-2): update failing e2e tests

* feat(EMS-3769-7-1-2): fix failing tests

* feat(EMS-3769-7-1-2): code changes and improvements

* feat(EMS-3769-7-1-2): remove test

* feat(EMS-3769-7-1-2): fix failing tests

* feat(EMS-3769-7-1-2): code and test fixes

---------

Co-authored-by: Zain Kassam <[email protected]>
  • Loading branch information
Zainzzkk and Zain Kassam authored Sep 4, 2024
1 parent 22deb8d commit 00a704b
Show file tree
Hide file tree
Showing 107 changed files with 5,402 additions and 3,303 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -795,13 +795,15 @@ jobs:
matrix:
spec:
[
'your-buyer/alternative-currency/**/*.spec.js',
'your-buyer/buyer-financial-information/**/*.spec.js',
'your-buyer/change-your-answers/**/*.spec.js',
'your-buyer/check-your-answers/**/*.spec.js',
'your-buyer/company-or-organisation/**/*.spec.js',
'your-buyer/connection-with-the-buyer/**/*.spec.js',
'your-buyer/credit-insurance-cover/**/*.spec.js',
'your-buyer/currency-of-late-payments/**/*.spec.js',
'your-buyer/failed-to-pay/**/*.spec.js',
'your-buyer/outstanding-or-overdue-payments/**/*.spec.js',
'your-buyer/root/**/*.spec.js',
'your-buyer/traded-with-buyer/**/*.spec.js',
'your-buyer/trading-history/**/*.spec.js',
Expand Down
11 changes: 11 additions & 0 deletions e2e-tests/commands/insurance/check-your-buyer-summary-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ const checkYourBusinessSummaryList = {
cy.assertSummaryListRowDoesNotExist(summaryList, fieldId);
}
},
[CURRENCY_CODE]: ({ shouldRender = false }) => {
const fieldId = CURRENCY_CODE;

if (shouldRender) {
const { expectedKey, expectedChangeLinkText } = getSummaryListField(fieldId, FIELDS);

cy.assertSummaryListRow(summaryList, fieldId, expectedKey, application.BUYER[CURRENCY_CODE], expectedChangeLinkText);
} else {
cy.assertSummaryListRowDoesNotExist(summaryList, fieldId);
}
},
[TOTAL_AMOUNT_OVERDUE]: ({ shouldRender = false }) => {
const fieldId = TOTAL_AMOUNT_OVERDUE;

Expand Down
16 changes: 5 additions & 11 deletions e2e-tests/commands/insurance/complete-buyer-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* completeBuyerSection
* Complete the "Buyer" section
* @param {Boolean} viaTaskList: Start the "buyer" section from the task list.
* @param {Boolean} alternativeCurrency: Should submit an "alternative currency". Defaults to false.
* @param {Boolean} hasConnectionToBuyer: Should submit "yes" to "have connection to buyer" radio. Defaults to "no".
* @param {Boolean} exporterHasTradedWithBuyer: Submit "yes" to "have traded with buyer before" in the "working with buyer" form.
* @param {Boolean} outstandingPayments: Exporter has outstanding payments with the buyer
Expand All @@ -15,7 +14,6 @@
*/
const completeBuyerSection = ({
viaTaskList = true,
alternativeCurrency = false,
hasConnectionToBuyer = false,
exporterHasTradedWithBuyer = false,
outstandingPayments = false,
Expand All @@ -33,18 +31,14 @@ const completeBuyerSection = ({
cy.completeAndSubmitTradedWithBuyerForm({ exporterHasTradedWithBuyer });

if (exporterHasTradedWithBuyer) {
cy.clickYesRadioInput();
cy.completeAndSubmitTradingHistoryWithBuyerForm({ outstandingPayments: outstandingPayments || fullyPopulatedBuyerTradingHistory });

if (alternativeCurrency) {
cy.clickProvideAlternativeCurrencyLink();

cy.clickAlternativeCurrencyRadioAndSubmitCurrency({});
if (outstandingPayments || fullyPopulatedBuyerTradingHistory) {
cy.completeAndSubmitAlternativeCurrencyForm({ clickAlternativeCurrencyLink: false });
cy.completeAndSubmitOutstandingOrOverduePaymentsForm({ outstandingPayments });
}

cy.completeAndSubmitTradingHistoryWithBuyerForm({
outstandingPayments: outstandingPayments || fullyPopulatedBuyerTradingHistory,
failedToPay: failedToPay || fullyPopulatedBuyerTradingHistory,
});
cy.completeAndSubmitFailedToPayForm({ failedToPay });
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* completeAndSubmitFailedToPayForm
* Complete and submit the "failed to pay" form
* @param {Boolean} failedToPay: Buyer has failed to pay the exporter on the time
*/
const completeAndSubmitFailedToPayForm = ({ failedToPay = false }) => {
cy.completeFailedToPayForm({ failedToPay });

cy.clickSubmitButton();
};

export default completeAndSubmitFailedToPayForm;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { YOUR_BUYER as FIELD_IDS } from '../../../constants/field-ids/insurance/your-buyer';
import application from '../../../fixtures/application';

const { TOTAL_OUTSTANDING_PAYMENTS, TOTAL_AMOUNT_OVERDUE } = FIELD_IDS;

const { BUYER } = application;

/**
* completeAndSubmitOutstandingOrOverduePaymentsForm
* Complete and submit the "outstanding or overdue payments" form
* @param {String} amountOverDue: enter the amount overdue - defaults to BUYER[TOTAL_AMOUNT_OVERDUE]
* @param {String} totalOutstanding: enter the total outstanding - defaults to BUYER[TOTAL_OUTSTANDING_PAYMENTS]
*/
const completeAndSubmitOutstandingOrOverduePaymentsForm = ({
amountOverDue = BUYER[TOTAL_AMOUNT_OVERDUE],
totalOutstanding = BUYER[TOTAL_OUTSTANDING_PAYMENTS],
}) => {
cy.completeOutstandingOrOverduePaymentsForm({
amountOverDue,
totalOutstanding,
});

cy.clickSubmitButton();
};

export default completeAndSubmitOutstandingOrOverduePaymentsForm;
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
import { YOUR_BUYER as FIELD_IDS } from '../../../constants/field-ids/insurance/your-buyer';
import application from '../../../fixtures/application';

const { TOTAL_OUTSTANDING_PAYMENTS, TOTAL_AMOUNT_OVERDUE } = FIELD_IDS;

const { BUYER } = application;

/**
* completeAndSubmitTradingHistoryWithBuyerForm
* Complete and submit the "trading history with buyer" form
* @param {Boolean} outstandingPayments: Exporter has outstanding payments with the buyer
* @param {Boolean} failedToPay: Buyer has failed to pay the exporter on the time
* @param {String} amountOverDue: enter the amount overdue - default to application value
* @param {String} totalOutstanding: enter the total outstanding - default to application value
*/
const completeAndSubmitTradingHistoryWithBuyerForm = ({
outstandingPayments = false,
failedToPay = false,
amountOverDue = BUYER[TOTAL_AMOUNT_OVERDUE],
totalOutstanding = BUYER[TOTAL_OUTSTANDING_PAYMENTS],
}) => {
const completeAndSubmitTradingHistoryWithBuyerForm = ({ outstandingPayments = false }) => {
cy.completeTradingHistoryWithBuyerForm({
outstandingPayments,
failedToPay,
amountOverDue,
totalOutstanding,
});

cy.clickSubmitButton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ const completeAndSubmitYourBuyerForms = ({
if (exporterHasTradedWithBuyer) {
steps.push({
name: 'tradingHistoryWithBuyer',
action: () =>
cy.completeAndSubmitTradingHistoryWithBuyerForm({
outstandingPayments: outstandingPayments || fullyPopulatedBuyerTradingHistory,
failedToPay: failedToPay || fullyPopulatedBuyerTradingHistory,
}),
action: () => cy.completeAndSubmitTradingHistoryWithBuyerForm({ outstandingPayments: outstandingPayments || fullyPopulatedBuyerTradingHistory }),
});

if (outstandingPayments) {
steps.push({ name: 'currencyOfLatePayments', action: () => cy.completeAndSubmitAlternativeCurrencyForm({}) });
steps.push({ name: 'outstandingOrOverduePayments', action: () => cy.completeAndSubmitOutstandingOrOverduePaymentsForm({ outstandingPayments }) });
}

steps.push({ name: 'failedToPay', action: () => cy.completeAndSubmitFailedToPayForm({ failedToPay }) });
}

steps.push({ name: 'buyerFinancialInformation', action: () => cy.completeAndSubmitBuyerFinancialInformationForm({ exporterHasBuyerFinancialAccounts }) });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* completeFailedToPayForm
* Complete the "failed to pay" form
* @param {Boolean} failedToPay: Buyer has failed to pay the exporter on the time - defaults to false
*/
const completeFailedToPayForm = ({ failedToPay = false }) => {
if (failedToPay) {
cy.clickYesRadioInput();
} else {
cy.clickNoRadioInput();
}
};

export default completeFailedToPayForm;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { field } from '../../../pages/shared';
import { YOUR_BUYER as FIELD_IDS } from '../../../constants/field-ids/insurance/your-buyer';
import application from '../../../fixtures/application';

const { TOTAL_OUTSTANDING_PAYMENTS, TOTAL_AMOUNT_OVERDUE } = FIELD_IDS;

const { BUYER } = application;

/**
* completeOutstandingOrOverduePaymentsForm
* Complete the "outstanding or overdue payments" form
* @param {String} amountOverdue: enter the amount overdue - default to BUYER[TOTAL_AMOUNT_OVERDUE]
* @param {String} totalOutstanding: enter the total outstanding - default to BUYER[TOTAL_OUTSTANDING_PAYMENTS]
*/
const completeOutstandingOrOverduePaymentsForm = ({ amountOverdue = BUYER[TOTAL_AMOUNT_OVERDUE], totalOutstanding = BUYER[TOTAL_OUTSTANDING_PAYMENTS] }) => {
cy.keyboardInput(field(TOTAL_AMOUNT_OVERDUE).input(), amountOverdue);
cy.keyboardInput(field(TOTAL_OUTSTANDING_PAYMENTS).input(), totalOutstanding);
};

export default completeOutstandingOrOverduePaymentsForm;
Original file line number Diff line number Diff line change
@@ -1,39 +1,14 @@
import { field } from '../../../pages/shared';
import { YOUR_BUYER as FIELD_IDS } from '../../../constants/field-ids/insurance/your-buyer';
import application from '../../../fixtures/application';

const { TOTAL_OUTSTANDING_PAYMENTS, TOTAL_AMOUNT_OVERDUE } = FIELD_IDS;

const { BUYER } = application;

/**
* completeTradingHistoryWithBuyerForm
* Complete the "trading history with buyer" form
* @param {Boolean} outstandingPayments: Exporter has outstanding payments with the buyer
* @param {Boolean} failedToPay: Buyer has failed to pay the exporter on the time
* @param {String} amountOverDue: enter the amount overdue - default to application value
* @param {String} totalOutstanding: enter the total outstanding - default to application value
*/
const completeTradingHistoryWithBuyerForm = ({
outstandingPayments = false,
failedToPay = false,
amountOverDue = BUYER[TOTAL_AMOUNT_OVERDUE],
totalOutstanding = BUYER[TOTAL_OUTSTANDING_PAYMENTS],
}) => {
const completeTradingHistoryWithBuyerForm = ({ outstandingPayments = false }) => {
if (outstandingPayments) {
cy.clickYesRadioInput();

cy.keyboardInput(field(TOTAL_AMOUNT_OVERDUE).input(), amountOverDue);
cy.keyboardInput(field(TOTAL_OUTSTANDING_PAYMENTS).input(), totalOutstanding);
} else {
cy.clickNoRadioInput();
}

if (failedToPay) {
cy.clickYesRadioInput(1);
} else {
cy.clickNoRadioInput(1);
}
};

export default completeTradingHistoryWithBuyerForm;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { field } from '../../../pages/shared';
import { YOUR_BUYER as FIELD_IDS } from '../../../constants/field-ids/insurance/your-buyer';

const { TOTAL_AMOUNT_OVERDUE, TOTAL_OUTSTANDING_PAYMENTS } = FIELD_IDS;

/**
* assertEmptyOverdueOrOutstandingFieldValues
* Assert all field values in the "overdue or outstanding" form are empty.
*/
const assertEmptyOverdueOrOutstandingFieldValues = () => {
cy.checkValue(field(TOTAL_AMOUNT_OVERDUE), '');
cy.checkValue(field(TOTAL_OUTSTANDING_PAYMENTS), '');
};

export default assertEmptyOverdueOrOutstandingFieldValues;

This file was deleted.

2 changes: 1 addition & 1 deletion e2e-tests/commands/shared-commands/assertions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Cypress.Commands.add('checkRadioInputNoAriaLabel', require('./check-radio-input-

Cypress.Commands.add('assertConnectionWithBuyerFieldValues', require('./assert-connection-with-buyer-field-values'));

Cypress.Commands.add('assertEmptyTradingHistoryFieldValues', require('./assert-empty-trading-history-field-values'));
Cypress.Commands.add('assertEmptyOverdueOrOutstandingFieldValues', require('./assert-empty-overdue-or-outstanding-field-values'));

Cypress.Commands.add('assertDifferentNameOnPolicyFieldValues', require('./assert-different-name-on-policy-field-values'));
Cypress.Commands.add('assertOtherCompanyDetailsFieldValues', require('./assert-other-company-details-field-values'));
Expand Down
19 changes: 15 additions & 4 deletions e2e-tests/constants/routes/insurance/your-buyer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ const COMPANY_OR_ORGANISATION_ROOT = `${YOUR_BUYER_ROOT}/buyer-company-organisat
const CONNECTION_WITH_BUYER_ROOT = `${YOUR_BUYER_ROOT}/connection-with-the-buyer`;
const TRADED_WITH_BUYER_ROOT = `${YOUR_BUYER_ROOT}/prior-trade-history`;
const TRADING_HISTORY_ROOT = `${YOUR_BUYER_ROOT}/trading-history`;
const ALTERNATIVE_CURRENCY_ROOT = `${YOUR_BUYER_ROOT}/alternative-currency`;
const CURRENCY_OF_LATE_PAYMENTS_ROOT = `${YOUR_BUYER_ROOT}/currency-of-late-payments`;
const OUTSTANDING_OR_OVERDUE_PAYMENTS_ROOT = `${YOUR_BUYER_ROOT}/outstanding-or-overdue-payments`;
const FAILED_TO_PAY_ROOT = `${YOUR_BUYER_ROOT}/failed-to-pay-on-time`;
const CREDIT_INSURANCE_COVER_ROOT = `${YOUR_BUYER_ROOT}/credit-insurance-cover`;
const BUYER_FINANCIAL_INFORMATION_ROOT = `${YOUR_BUYER_ROOT}/buyer-financial-information`;
const CHECK_YOUR_ANSWERS = `${YOUR_BUYER_ROOT}/check-your-answers`;
Expand All @@ -24,9 +26,18 @@ export const YOUR_BUYER = {
TRADING_HISTORY_SAVE_AND_BACK: `${TRADING_HISTORY_ROOT}/save-and-back`,
TRADING_HISTORY_CHANGE: `${TRADING_HISTORY_ROOT}/change`,
TRADING_HISTORY_CHECK_AND_CHANGE: `${TRADING_HISTORY_ROOT}/check-and-change`,
ALTERNATIVE_CURRENCY: ALTERNATIVE_CURRENCY_ROOT,
ALTERNATIVE_CURRENCY_CHANGE: `${ALTERNATIVE_CURRENCY_ROOT}/change`,
ALTERNATIVE_CURRENCY_CHECK_AND_CHANGE: `${ALTERNATIVE_CURRENCY_ROOT}/check-and-change`,
CURRENCY_OF_LATE_PAYMENTS: CURRENCY_OF_LATE_PAYMENTS_ROOT,
CURRENCY_OF_LATE_PAYMENTS_CHANGE: `${CURRENCY_OF_LATE_PAYMENTS_ROOT}/change`,
CURRENCY_OF_LATE_PAYMENTS_CHECK_AND_CHANGE: `${CURRENCY_OF_LATE_PAYMENTS_ROOT}/check-and-change`,
CURRENCY_OF_LATE_PAYMENTS_SAVE_AND_BACK: `${CURRENCY_OF_LATE_PAYMENTS_ROOT}/save-and-back`,
OUTSTANDING_OR_OVERDUE_PAYMENTS: OUTSTANDING_OR_OVERDUE_PAYMENTS_ROOT,
OUTSTANDING_OR_OVERDUE_PAYMENTS_SAVE_AND_BACK: `${OUTSTANDING_OR_OVERDUE_PAYMENTS_ROOT}/save-and-back`,
OUTSTANDING_OR_OVERDUE_PAYMENTS_CHANGE: `${OUTSTANDING_OR_OVERDUE_PAYMENTS_ROOT}/change`,
OUTSTANDING_OR_OVERDUE_PAYMENTS_CHECK_AND_CHANGE: `${OUTSTANDING_OR_OVERDUE_PAYMENTS_ROOT}/check-and-change`,
FAILED_TO_PAY: FAILED_TO_PAY_ROOT,
FAILED_TO_PAY_SAVE_AND_BACK: `${FAILED_TO_PAY_ROOT}/save-and-back`,
FAILED_TO_PAY_CHANGE: `${FAILED_TO_PAY_ROOT}/change`,
FAILED_TO_PAY_CHECK_AND_CHANGE: `${FAILED_TO_PAY_ROOT}/check-and-change`,
CREDIT_INSURANCE_COVER: CREDIT_INSURANCE_COVER_ROOT,
CREDIT_INSURANCE_COVER_SAVE_AND_BACK: `${CREDIT_INSURANCE_COVER_ROOT}/save-and-back`,
CREDIT_INSURANCE_COVER_CHANGE: `${CREDIT_INSURANCE_COVER_ROOT}/change`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const YOUR_BUYER_FIELDS = {
},
[OUTSTANDING_PAYMENTS]: {
LABEL: 'Do you currently have any outstanding or overdue payments from the buyer?',
HINT: 'We will request a copy of your trading history once the application has been submitted',
SUMMARY: {
TITLE: 'Outstanding or overdue payments',
FORM_TITLE: TRADING_HISTORY,
Expand All @@ -106,7 +107,11 @@ export const YOUR_BUYER_FIELDS = {
},
},
[CURRENCY_CODE]: {
LEGEND: 'What currency are the outstanding or overdue payments in?',
LEGEND: 'What is the currency the outstanding or overdue payments are in?',
SUMMARY: {
TITLE: 'Outstanding payments currency',
FORM_TITLE: TRADING_HISTORY,
},
},
[HAS_PREVIOUS_CREDIT_INSURANCE_COVER_WITH_BUYER]: {
LABEL: 'Have you in the past held credit insurance cover on the buyer?',
Expand Down
17 changes: 13 additions & 4 deletions e2e-tests/content-strings/pages/insurance/your-buyer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,23 @@ export const TRADED_WITH_BUYER = {

export const TRADING_HISTORY = {
...SHARED,
PAGE_TITLE: 'Tell us about your trading history with the buyer',
PAGE_TITLE: 'Do you currently have any outstanding or overdue payments from the buyer?',
INTRO: 'We will request a copy of your trading history once the application has been submitted.',
PROVIDE_ALTERNATIVE_CURRENCY: 'Use a different currency for any outstanding or overdue payments from the buyer',
};

export const ALTERNATIVE_CURRENCY = {
export const CURRENCY_OF_LATE_PAYMENTS = {
...SHARED,
PAGE_TITLE: 'What currency are the outstanding or overdue payments in?',
PAGE_TITLE: 'What is the currency the outstanding or overdue payments are in?',
};

export const FAILED_PAYMENTS = {
...SHARED,
PAGE_TITLE: 'Has the buyer ever failed to pay you on time?',
};

export const OUTSTANDING_OR_OVERDUE_PAYMENTS = {
...SHARED,
PAGE_TITLE: 'Tell us about the outstanding or overdue payments',
};

export const CREDIT_INSURANCE_COVER = {
Expand Down
Loading

0 comments on commit 00a704b

Please sign in to comment.