Skip to content

Commit

Permalink
Merge branch 'main-iterations' into feat/EMS-3878
Browse files Browse the repository at this point in the history
  • Loading branch information
ttbarnes committed Sep 27, 2024
2 parents e619f11 + cd6398b commit f94bc90
Show file tree
Hide file tree
Showing 31 changed files with 529 additions and 117 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ jobs:
'export-contract/agent-details/**/*.spec.js',
'export-contract/agent-service/**/*.spec.js',
'export-contract/agent-charges/**/*.spec.js',
'export-contract/how-much-the-agent-is-charging/**/*.spec.js',
# TODO: EMS-3828 - renable
# 'export-contract/currency-of-agent-charges/*.spec.js',
'export-contract/change-your-answers/about-goods-or-services/*.spec.js',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* completeAndSubmitHowMuchTheAgentIsChargingForm
* Complete and submit the "How much the agent is charging" form
* @param {String} fixedSumAmount: Fixed sum amount
*/
const completeAndSubmitHowMuchTheAgentIsChargingForm = ({ fixedSumAmount }) => {
cy.completeHowMuchTheAgentIsChargingForm({ fixedSumAmount });

cy.clickSubmitButton();
};

export default completeAndSubmitHowMuchTheAgentIsChargingForm;
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const completeExportContractSection = ({
if (agentChargeMethodFixedSum) {
cy.completeAndSubmitAlternativeCurrencyForm({ alternativeCurrency });

cy.completeAndSubmitHowMuchIsTheAgentChargingForm({
cy.completeAndSubmitHowMuchTheAgentIsChargingForm({
fixedSumAmount: agentChargeFixedSumAmount,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ const {
} = FIELD_IDS;

/**
* completeAndSubmitHowMuchIsTheAgentChargingForm
* Complete and submit the "How much is the agent charging" form
* completeHowMuchTheAgentIsChargingForm
* Complete the "How much the agent is charging" form
* @param {String} fixedSumAmount: Fixed sum amount
*/
const completeAndSubmitHowMuchIsTheAgentChargingForm = ({ fixedSumAmount = application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_AMOUNT] }) => {
const completeHowMuchTheAgentIsChargingForm = ({ fixedSumAmount = application.EXPORT_CONTRACT.AGENT_CHARGES[FIXED_SUM_AMOUNT] }) => {
cy.keyboardInput(field(FIXED_SUM_AMOUNT).input(), fixedSumAmount);

cy.clickSubmitButton();
};

export default completeAndSubmitHowMuchIsTheAgentChargingForm;
export default completeHowMuchTheAgentIsChargingForm;
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const completeAndSubmitExportContractForms = ({
steps = [
...steps,
{ name: 'currencyOfAgentCharges', action: () => cy.completeAndSubmitAlternativeCurrencyForm({}) },
{ name: 'howMuchAgentIsCharging', action: () => cy.completeAndSubmitHowMuchIsTheAgentChargingForm({ fixedSumAmount }) },
{ name: 'howMuchAgentIsCharging', action: () => cy.completeAndSubmitHowMuchTheAgentIsChargingForm({ fixedSumAmount }) },
];
}

Expand Down
10 changes: 5 additions & 5 deletions e2e-tests/constants/routes/insurance/export-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const AGENT_DETAILS_ROOT = `${ROOT}/agent-details`;
const AGENT_SERVICE_ROOT = `${ROOT}/agent-service`;
const AGENT_CHARGES_ROOT = `${ROOT}/agent-charges`;
const AGENT_CHARGES_CURRENCY_ROOT = `${ROOT}/currency-of-agents-charge`;
const HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT = `${ROOT}/how-much-is-the-agent-charging`;
const HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT = `${ROOT}/how-much-the-agent-is-charging`;

export const EXPORT_CONTRACT = {
ROOT,
Expand Down Expand Up @@ -53,9 +53,9 @@ export const EXPORT_CONTRACT = {
AGENT_CHARGES_CURRENCY: AGENT_CHARGES_CURRENCY_ROOT,
AGENT_CHARGES_CURRENCY_CHANGE: `${AGENT_CHARGES_CURRENCY_ROOT}/change`,
AGENT_CHARGES_CURRENCY_CHECK_AND_CHANGE: `${AGENT_CHARGES_CURRENCY_ROOT}/check-and-change`,
HOW_MUCH_IS_THE_AGENT_CHARGING_SAVE_AND_BACK: `${HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT}/save-and-go-back`,
HOW_MUCH_IS_THE_AGENT_CHARGING: HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT,
HOW_MUCH_IS_THE_AGENT_CHARGING_CHANGE: `${HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT}/change`,
HOW_MUCH_IS_THE_AGENT_CHARGING_CHECK_AND_CHANGE: `${HOW_MUCH_IS_THE_AGENT_CHARGING_ROOT}/check-and-change`,
HOW_MUCH_THE_AGENT_IS_CHARGING_SAVE_AND_BACK: `${HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT}/save-and-go-back`,
HOW_MUCH_THE_AGENT_IS_CHARGING: HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT,
HOW_MUCH_THE_AGENT_IS_CHARGING_CHANGE: `${HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT}/change`,
HOW_MUCH_THE_AGENT_IS_CHARGING_CHECK_AND_CHANGE: `${HOW_MUCH_THE_AGENT_IS_CHARGING_ROOT}/check-and-change`,
CHECK_YOUR_ANSWERS: `${ROOT}/check-your-answers`,
};
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const AGENT_CHARGES_CURRENCY = {
PAGE_TITLE: 'What currency is the agent charging you in?',
};

const HOW_MUCH_IS_THE_AGENT_CHARGING = {
const HOW_MUCH_THE_AGENT_IS_CHARGING = {
...SHARED,
PAGE_TITLE: 'How much is the agent charging in',
};
Expand All @@ -88,6 +88,6 @@ module.exports = {
AGENT_SERVICE,
AGENT_CHARGES,
AGENT_CHARGES_CURRENCY,
HOW_MUCH_IS_THE_AGENT_CHARGING,
HOW_MUCH_THE_AGENT_IS_CHARGING,
CHECK_YOUR_ANSWERS,
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.AGENT_CHARGES_CURRENCY;

const {
ROOT,
EXPORT_CONTRACT: { AGENT_CHARGES, AGENT_CHARGES_CURRENCY, HOW_MUCH_IS_THE_AGENT_CHARGING },
EXPORT_CONTRACT: { AGENT_CHARGES, AGENT_CHARGES_CURRENCY, HOW_MUCH_THE_AGENT_IS_CHARGING },
} = INSURANCE_ROUTES;

const {
Expand Down Expand Up @@ -39,7 +39,7 @@ context(
cy.completeAndSubmitExportContractForms({ formToStopAt: 'agentCharges', isUsingAgent: true, agentIsCharging: true, fixedSumMethod: true });

url = `${baseUrl}${ROOT}/${referenceNumber}${AGENT_CHARGES_CURRENCY}`;
howMuchAgentIsChargingUrl = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`;
howMuchAgentIsChargingUrl = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`;
});
});

Expand Down Expand Up @@ -90,7 +90,7 @@ context(
});

describe('form submission', () => {
it(`should redirect to ${HOW_MUCH_IS_THE_AGENT_CHARGING}`, () => {
it(`should redirect to ${HOW_MUCH_THE_AGENT_IS_CHARGING}`, () => {
cy.completeAndSubmitAlternativeCurrencyForm({});

cy.assertUrl(howMuchAgentIsChargingUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { EXPORT_CONTRACT_FIELDS as FIELD_STRINGS } from '../../../../../../conte
import FIELD_IDS from '../../../../../../constants/field-ids/insurance/export-contract';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import { GBP, SYMBOLS } from '../../../../../../fixtures/currencies';
import application from '../../../../../../fixtures/application';

const CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_IS_THE_AGENT_CHARGING;
const CONTENT_STRINGS = PAGES.INSURANCE.EXPORT_CONTRACT.HOW_MUCH_THE_AGENT_IS_CHARGING;

const {
ROOT,
EXPORT_CONTRACT: { AGENT_CHARGES_CURRENCY, HOW_MUCH_IS_THE_AGENT_CHARGING, CHECK_YOUR_ANSWERS },
EXPORT_CONTRACT: { AGENT_CHARGES_CURRENCY, HOW_MUCH_THE_AGENT_IS_CHARGING, CHECK_YOUR_ANSWERS },
} = INSURANCE_ROUTES;

const {
Expand All @@ -19,7 +20,7 @@ const {
const baseUrl = Cypress.config('baseUrl');

context(
"Insurance - Export contract - How much is the agent charging page - As an exporter, I want to state what my agent's charges are, So that UKEF, the legal team and the British Embassy are aware of expenses incurred in my export contract bid",
"Insurance - Export contract - How much the agent is charging page - As an exporter, I want to state what my agent's charges are, So that UKEF, the legal team and the British Embassy are aware of expenses incurred in my export contract bid",
() => {
let referenceNumber;
let url;
Expand All @@ -32,7 +33,7 @@ context(
// go to the page we want to test.
cy.completeAndSubmitExportContractForms({ formToStopAt: 'currencyOfAgentCharges', isUsingAgent: true, agentIsCharging: true, fixedSumMethod: true });

url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`;
url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`;
checkYourAnswersUrl = `${baseUrl}${ROOT}/${referenceNumber}${CHECK_YOUR_ANSWERS}`;
});
});
Expand All @@ -48,7 +49,7 @@ context(
it('renders core page elements', () => {
cy.corePageChecks({
pageTitle: `${CONTENT_STRINGS.PAGE_TITLE} ${GBP.name}?`,
currentHref: `${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`,
currentHref: `${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`,
backLink: `${ROOT}/${referenceNumber}${AGENT_CHARGES_CURRENCY}`,
});
});
Expand Down Expand Up @@ -81,10 +82,20 @@ context(
it(`should redirect to ${CHECK_YOUR_ANSWERS}`, () => {
cy.navigateToUrl(url);

cy.completeAndSubmitHowMuchIsTheAgentChargingForm({});
cy.completeAndSubmitHowMuchTheAgentIsChargingForm({});

cy.assertUrl(checkYourAnswersUrl);
});

describe('when going back to the page', () => {
beforeEach(() => {
cy.navigateToUrl(url);
});

it('should have the submitted value', () => {
cy.checkValue(fieldSelector(FIELD_ID), application.EXPORT_CONTRACT.AGENT_CHARGES[FIELD_ID]);
});
});
});
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import { field } from '../../../../../../pages/shared';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import FIELD_IDS from '../../../../../../constants/field-ids/insurance/export-contract';

const {
ROOT,
EXPORT_CONTRACT: { HOW_MUCH_THE_AGENT_IS_CHARGING },
} = INSURANCE_ROUTES;

const {
AGENT_CHARGES: { FIXED_SUM_AMOUNT: FIELD_ID },
} = FIELD_IDS;

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

context('Insurance - Export contract - How much the agent is charging - Save and go back', () => {
let referenceNumber;
let url;

before(() => {
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

// go to the page we want to test.
cy.completeAndSubmitExportContractForms({
formToStopAt: 'currencyOfAgentCharges',
isUsingAgent: true,
agentIsCharging: true,
fixedSumMethod: true,
});

url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`;

cy.assertUrl(url);
});
});

beforeEach(() => {
cy.saveSession();
});

after(() => {
cy.deleteApplication(referenceNumber);
});

describe('when submitting an empty form via `save and go back` button', () => {
beforeEach(() => {
cy.navigateToUrl(url);

cy.completeHowMuchTheAgentIsChargingForm({});

cy.clickSaveAndBackButton();
});

it('should redirect to `all sections`', () => {
cy.assertAllSectionsUrl(referenceNumber);
});

it('should retain the status of task `export contract` as ` in progress`', () => {
cy.navigateToUrl(url);

cy.completeHowMuchTheAgentIsChargingForm({});

cy.clickSaveAndBackButton();

// TODO: EMS-3828 - renable
// cy.checkTaskExportContractStatusIsInProgress();
});
});

describe(`when submitting ${FIELD_ID} as a pure number`, () => {
const fixedSumAmount = '1000';

beforeEach(() => {
cy.navigateToUrl(url);

cy.completeHowMuchTheAgentIsChargingForm({ fixedSumAmount });

cy.clickSaveAndBackButton();
});

it('should redirect to `all sections`', () => {
cy.assertAllSectionsUrl(referenceNumber);
});

it('should update the `export contract` task status to `completed`', () => {
cy.navigateToAllSectionsUrl(referenceNumber);

cy.checkTaskExportContractStatusIsComplete();
});

describe('when going back to the page', () => {
beforeEach(() => {
cy.navigateToUrl(url);
});

it('should have the submitted value', () => {
cy.checkValue(field(FIELD_ID), fixedSumAmount);
});
});
});

describe(`when submitting ${FIELD_ID} with a comma`, () => {
const fixedSumAmount = '1,000';
const amount = '1000';

beforeEach(() => {
cy.navigateToUrl(url);

cy.completeHowMuchTheAgentIsChargingForm({ fixedSumAmount });

cy.clickSaveAndBackButton();
});

it('should redirect to `all sections`', () => {
cy.assertAllSectionsUrl(referenceNumber);
});

it('should update the `export contract` task status to `completed`', () => {
cy.navigateToAllSectionsUrl(referenceNumber);

cy.checkTaskExportContractStatusIsComplete();
});

describe('when going back to the page', () => {
beforeEach(() => {
cy.navigateToUrl(url);
});

it('should have the submitted value without the comma', () => {
cy.checkValue(field(FIELD_ID), amount);
});
});
});

describe(`when submitting ${FIELD_ID} as a decimal number`, () => {
const fixedSumAmount = '100.54';

beforeEach(() => {
cy.navigateToUrl(url);

cy.completeHowMuchTheAgentIsChargingForm({ fixedSumAmount });

cy.clickSaveAndBackButton();
});

it('should redirect to `all sections`', () => {
cy.assertAllSectionsUrl(referenceNumber);
});

it('should update the `export contract` task status to `completed`', () => {
cy.navigateToAllSectionsUrl(referenceNumber);

cy.checkTaskExportContractStatusIsComplete();
});

describe('when going back to the page', () => {
beforeEach(() => {
cy.navigateToUrl(url);
});

it('should have the submitted value', () => {
cy.checkValue(field(FIELD_ID), fixedSumAmount);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insuranc

const {
ROOT,
EXPORT_CONTRACT: { HOW_MUCH_IS_THE_AGENT_CHARGING },
EXPORT_CONTRACT: { HOW_MUCH_THE_AGENT_IS_CHARGING },
} = INSURANCE_ROUTES;

const {
Expand All @@ -29,15 +29,15 @@ const assertions = {

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

context('Insurance - Export contract - How much is the agent charging page - form validation', () => {
context('Insurance - Export contract - How much the agent is charging page - form validation', () => {
let referenceNumber;
let url;

before(() => {
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_IS_THE_AGENT_CHARGING}`;
url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_MUCH_THE_AGENT_IS_CHARGING}`;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ Cypress.Commands.add('completeAndSubmitAgentServiceForm', require('../../../../.
Cypress.Commands.add('completeAgentChargesForm', require('../../../../../commands/insurance/complete-agent-charges-form'));
Cypress.Commands.add('completeAndSubmitAgentChargesForm', require('../../../../../commands/insurance/complete-and-submit-agent-charges-form'));

Cypress.Commands.add('completeHowMuchTheAgentIsChargingForm', require('../../../../../commands/insurance/complete-how-much-the-agent-is-charging-form'));

Cypress.Commands.add(
'completeAndSubmitHowMuchIsTheAgentChargingForm',
require('../../../../../commands/insurance/complete-and-submit-how-much-is-the-agent-charging-form'),
'completeAndSubmitHowMuchTheAgentIsChargingForm',
require('../../../../../commands/insurance/complete-and-submit-how-much-the-agent-is-charging-form'),
);

Cypress.Commands.add(
Expand Down
Loading

0 comments on commit f94bc90

Please sign in to comment.