Skip to content

Commit

Permalink
feat(EMS-3853-54-55): export contract - agent charges - change answers (
Browse files Browse the repository at this point in the history
#3142)

* feat(EMS-3853-54-55): export contract - agent charges - check/change answers

* chore(tests): update default completeAndSubmitAlternativeCurrencyForm param

* feat(EMS-3853-54-55): fix/update e2e tests

* feat(EMS-3853-54-55): update export contract summary list fixedSumAmount url

* chore(tests): fix/update unit test

* chore(tests): fix typo

* feat(EMS-3853-54-55): fix/update e2e tests

* feat(EMS-3853-54-55): improve e2e test coverage

* feat(EMS-3853-54-55): remove unused e2e tests

* chore(tests): remove commented code

* feat(EMS-3853-54-55): fix/update e2e test

* chore(docs): remove empty line
  • Loading branch information
ttbarnes authored Oct 9, 2024
1 parent 1a59d47 commit 3087bed
Show file tree
Hide file tree
Showing 36 changed files with 461 additions and 812 deletions.
39 changes: 24 additions & 15 deletions e2e-tests/commands/insurance/check-export-contract-summary-list.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { summaryList } from '../../pages/shared';
import getSummaryListField from './get-summary-list-field';
import { EXPECTED_SINGLE_LINE_STRING, FIELD_VALUES } from '../../constants';
import FIELD_IDS from '../../constants/field-ids/insurance/export-contract';
import { INSURANCE_FIELD_IDS } from '../../constants/field-ids/insurance';
import { EXPORT_CONTRACT_FIELDS as FIELDS } from '../../content-strings/fields/insurance/export-contract';
import formatCurrency from '../../helpers/format-currency';
import application from '../../fixtures/application';
import COUNTRIES from '../../fixtures/countries';

const {
HOW_WAS_THE_CONTRACT_AWARDED: { AWARD_METHOD },
ABOUT_GOODS_OR_SERVICES: { DESCRIPTION, FINAL_DESTINATION },
HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION },
PRIVATE_MARKET: { ATTEMPTED, DECLINED_DESCRIPTION },
USING_AGENT,
AGENT_DETAILS: { NAME, FULL_ADDRESS, COUNTRY_CODE },
AGENT_SERVICE: { IS_CHARGING, SERVICE_DESCRIPTION },
AGENT_CHARGES: { FIXED_SUM_AMOUNT, FIXED_SUM_CURRENCY_CODE, PERCENTAGE_CHARGE, PAYABLE_COUNTRY_CODE },
} = FIELD_IDS;
CURRENCY: { CURRENCY_CODE },
EXPORT_CONTRACT: {
HOW_WAS_THE_CONTRACT_AWARDED: { AWARD_METHOD },
ABOUT_GOODS_OR_SERVICES: { DESCRIPTION, FINAL_DESTINATION },
HOW_WILL_YOU_GET_PAID: { PAYMENT_TERMS_DESCRIPTION },
PRIVATE_MARKET: { ATTEMPTED, DECLINED_DESCRIPTION },
USING_AGENT,
AGENT_DETAILS: { NAME, FULL_ADDRESS, COUNTRY_CODE },
AGENT_SERVICE: { IS_CHARGING, SERVICE_DESCRIPTION },
AGENT_CHARGES: { FIXED_SUM_AMOUNT, FIXED_SUM_CURRENCY_CODE, PERCENTAGE_CHARGE, PAYABLE_COUNTRY_CODE },
},
} = INSURANCE_FIELD_IDS;

const { OPEN_TENDER } = FIELDS.HOW_WAS_THE_CONTRACT_AWARDED[AWARD_METHOD].OPTIONS;

Expand Down Expand Up @@ -218,16 +221,22 @@ const checkExportContractSummaryList = {
}
},
[FIXED_SUM_CURRENCY_CODE]: ({ shouldRender = false }) => {
const fieldId = FIXED_SUM_CURRENCY_CODE;
/**
* NOTE:
* - The summary list uses the CURRENCY_CODE field ID.
* - The data uses the FIXED_SUM_CURRENCY_CODE field ID.
* The summary has to use the CURRENCY_CODE field ID to match the generic curency form field ID.
*/
const summaryListFieldId = CURRENCY_CODE;

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

const expectedValue = application.EXPORT_CONTRACT.AGENT_CHARGES[fieldId];
const expectedValue = application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_CURRENCY_CODE];

cy.assertSummaryListRow(summaryList, fieldId, expectedKey, expectedValue, expectedChangeLinkText);
cy.assertSummaryListRow(summaryList, summaryListFieldId, expectedKey, expectedValue, expectedChangeLinkText);
} else {
cy.assertSummaryListRowDoesNotExist(summaryList, fieldId);
cy.assertSummaryListRowDoesNotExist(summaryList, summaryListFieldId);
}
},
[FIXED_SUM_AMOUNT]: ({ shouldRender = false, agentChargeFixedSumAmount }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { CURRENCY_CODE } = INSURANCE_FIELD_IDS.CURRENCY;
* @param {String} isoCode: isoCode for radio selection.
* @param {Boolean} alternativeCurrency: If alternative currency should be entered.
*/
const completeAndSubmitAlternativeCurrencyForm = ({ isoCode, alternativeCurrency = true }) => {
const completeAndSubmitAlternativeCurrencyForm = ({ isoCode, alternativeCurrency = false }) => {
if (isoCode) {
radios(CURRENCY_CODE, isoCode).option.label().click();
cy.clickSubmitButton();
Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/fixtures/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const {
PRIVATE_MARKET: { ATTEMPTED, DECLINED_DESCRIPTION },
AGENT_DETAILS: { COUNTRY_CODE: AGENT_COUNTRY_CODE, FULL_ADDRESS: AGENT_FULL_ADDRESS, NAME: AGENT_NAME },
AGENT_SERVICE: { IS_CHARGING, SERVICE_DESCRIPTION },
AGENT_CHARGES: { METHOD, PAYABLE_COUNTRY_CODE, FIXED_SUM_AMOUNT, PERCENTAGE_CHARGE },
AGENT_CHARGES: { METHOD, PAYABLE_COUNTRY_CODE, FIXED_SUM_AMOUNT, FIXED_SUM_CURRENCY_CODE, PERCENTAGE_CHARGE },
},
EXPORTER_BUSINESS: {
ALTERNATIVE_TRADING_ADDRESS: { FULL_ADDRESS: EXPORTER_BUSINESS_FULL_ALT_TRADING_ADDRESS },
Expand Down Expand Up @@ -176,6 +176,7 @@ const application = {
AGENT_CHARGES: {
[PERCENTAGE_CHARGE]: '10',
[FIXED_SUM_AMOUNT]: '1500',
[FIXED_SUM_CURRENCY_CODE]: GBP_CURRENCY_CODE,
[METHOD]: AGENT_SERVICE_CHARGE.METHOD.FIXED_SUM,
[PAYABLE_COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME,
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import application from '../../../../../../../../fixtures/application';
const {
ROOT,
CHECK_YOUR_ANSWERS: { EXPORT_CONTRACT },
EXPORT_CONTRACT: { AGENT_CHARGES_CHECK_AND_CHANGE },
EXPORT_CONTRACT: { HOW_MUCH_THE_AGENT_IS_CHARGING_CHECK_AND_CHANGE },
} = INSURANCE_ROUTES;

const {
Expand Down Expand Up @@ -55,12 +55,12 @@ context(`Insurance - Change your answers - Export contract - Summary list - Agen
});

describe('when clicking the `change` link', () => {
it(`should redirect to ${AGENT_CHARGES_CHECK_AND_CHANGE}`, () => {
it(`should redirect to ${HOW_MUCH_THE_AGENT_IS_CHARGING_CHECK_AND_CHANGE}`, () => {
cy.navigateToUrl(url);

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

cy.assertChangeAnswersPageUrl({ referenceNumber, route: AGENT_CHARGES_CHECK_AND_CHANGE, fieldId });
cy.assertChangeAnswersPageUrl({ referenceNumber, route: HOW_MUCH_THE_AGENT_IS_CHARGING_CHECK_AND_CHANGE, fieldId });
});
});

Expand All @@ -74,10 +74,7 @@ context(`Insurance - Change your answers - Export contract - Summary list - Agen
it(`should redirect to ${EXPORT_CONTRACT}`, () => {
summaryList.field(fieldId).changeLink().click();

cy.completeAndSubmitAgentChargesForm({
fixedSumMethod: true,
fixedSumAmount: newValueInput,
});
cy.completeAndSubmitHowMuchTheAgentIsChargingForm({ fixedSumAmount: newValueInput });

cy.assertChangeAnswersPageUrl({ referenceNumber, route: EXPORT_CONTRACT, fieldId });
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ context(`Insurance - Change your answers - Export contract - Summary list - Agen
referenceNumber,
isUsingAgent: true,
agentIsCharging: true,
agentChargeMethodFixedSum: true,
agentChargeMethodPercentage: true,
});

cy.clickTaskCheckAnswers();
Expand Down
Loading

0 comments on commit 3087bed

Please sign in to comment.