Skip to content

Commit

Permalink
chore(EMS-3789): dry cypress commands - task link clicks (#3000)
Browse files Browse the repository at this point in the history
* chore(EMS-3789): dry cypress commands - task links - check your answers

* chore(EMS-3789): dry cypress commands - task links - declarations/submit

* chore(EMS-3789): dry cypress commands - task links
  • Loading branch information
ttbarnes authored Aug 23, 2024
1 parent 1db7568 commit 3434e25
Show file tree
Hide file tree
Showing 117 changed files with 196 additions and 659 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import partials from '../../../partials';

const { taskList } = partials.insurancePartials;

const task = taskList.submitApplication.tasks.checkAnswers;

/**
* completeAndSubmitCheckYourAnswers
* Complete and submit all "Application - Check your answers" forms:
Expand All @@ -13,7 +7,7 @@ const task = taskList.submitApplication.tasks.checkAnswers;
* 4) Export contract
*/
const completeAndSubmitCheckYourAnswers = () => {
task.link().click();
cy.clickTaskCheckAnswers();

cy.completeAndSubmitMultipleCheckYourAnswers({ count: 4 });
};
Expand Down
7 changes: 1 addition & 6 deletions e2e-tests/commands/insurance/complete-declarations.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import partials from '../../partials';
import { FIELD_VALUES } from '../../constants';

const { taskList } = partials.insurancePartials;

const task = taskList.submitApplication.tasks.declarationsAndSubmit;

/**
* completeDeclarations
* Runs through the full declarations journey
* @param {Object} Object with flags on how to complete specific declaration forms.
* - exportingWithCodeOfConduct: Should submit "yes" in the "exporting with code of conduct" form. Defaults to "yes".
*/
const completeDeclarations = ({ hasAntiBriberyCodeOfConduct = true, exportingWithCodeOfConduct = true }) => {
task.link().click();
cy.clickTaskDeclarationsAndSubmit();

cy.completeAndSubmitDeclarationConfidentiality();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import partials from '../../../partials';

const { taskList } = partials.insurancePartials;

/**
* completeAndDeclarationsForms
* completes declarations forms up to the specified form to stop at
Expand All @@ -15,7 +11,7 @@ const completeAndSubmitDeclarationsForms = ({ formToStopAt, referenceNumber }) =
cy.completeAndSubmitCheckYourAnswers();

// go to the page we want to test.
taskList.submitApplication.tasks.declarationsAndSubmit.link().click();
cy.clickTaskDeclarationsAndSubmit();

const steps = [
{ name: 'confidentiality', action: () => cy.completeAndSubmitDeclarationConfidentiality() },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import partials from '../../partials';
import { startNowLink } from '../../pages/shared';

const { taskList } = partials.insurancePartials;

const task = taskList.prepareApplication.tasks.exportContract;

/**
* startInsuranceExportContractSection
* Start the "export contract" section of an application.
Expand All @@ -14,7 +9,7 @@ const task = taskList.prepareApplication.tasks.exportContract;
*/
const startInsuranceExportContractSection = ({ viaTaskList = true }) => {
if (viaTaskList) {
task.link().click();
cy.clickTaskExportContract();
}

startNowLink().click();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import partials from '../../partials';
import { startNowLink } from '../../pages/shared';

const { taskList } = partials.insurancePartials;

const task = taskList.prepareApplication.tasks.policy;

/**
* startInsurancePolicySection
* Start the "insurance policy" section of an application.
Expand All @@ -14,7 +9,7 @@ const task = taskList.prepareApplication.tasks.policy;
*/
const startInsurancePolicySection = ({ viaTaskList = true }) => {
if (viaTaskList) {
task.link().click();
cy.clickTaskPolicy();
}

startNowLink().click();
Expand Down
7 changes: 1 addition & 6 deletions e2e-tests/commands/insurance/start-your-business-section.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import partials from '../../partials';
import { startNowLink } from '../../pages/shared';

const { taskList } = partials.insurancePartials;

const task = taskList.prepareApplication.tasks.business;

/**
* startYourBusinessSection
* Start the "your business" section of an application.
Expand All @@ -14,7 +9,7 @@ const task = taskList.prepareApplication.tasks.business;
*/
const startYourBusinessSection = ({ viaTaskList = true }) => {
if (viaTaskList) {
task.link().click();
cy.clickTaskBusiness();
}

startNowLink().click();
Expand Down
7 changes: 1 addition & 6 deletions e2e-tests/commands/insurance/start-your-buyer-section.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import partials from '../../partials';
import { startNowLink } from '../../pages/shared';

const { taskList } = partials.insurancePartials;

const task = taskList.prepareApplication.tasks.buyer;

/**
* startInsuranceYourBuyerSection
* Start the "your buyer" section of an application.
Expand All @@ -14,7 +9,7 @@ const task = taskList.prepareApplication.tasks.buyer;
*/
const startInsuranceYourBuyerSection = ({ viaTaskList = true }) => {
if (viaTaskList) {
task.link().click();
cy.clickTaskBuyer();
}

startNowLink().click();
Expand Down
7 changes: 7 additions & 0 deletions e2e-tests/commands/shared-commands/click-events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@ Cypress.Commands.add('clickYesRadioInput', require('./click-yes-radio-input'));
Cypress.Commands.add('clickProvideAlternativeCurrencyLink', require('./click-provide-alternative-currency-link'));
Cypress.Commands.add('clickAlternativeCurrencyRadioOption', require('./click-alternative-currency-radio-option'));

Cypress.Commands.add('clickTaskBusiness', require('./tasks/click-task-business'));
Cypress.Commands.add('clickTaskBuyer', require('./tasks/click-task-buyer'));
Cypress.Commands.add('clickTaskPolicy', require('./tasks/click-task-policy'));
Cypress.Commands.add('clickTaskExportContract', require('./tasks/click-task-export-contract'));
Cypress.Commands.add('clickTaskCheckAnswers', require('./tasks/click-task-check-answers'));
Cypress.Commands.add('clickTaskDeclarationsAndSubmit', require('./tasks/click-task-declarations-and-submit'));

Cypress.Commands.add('rejectAnalyticsCookies', analytics.rejectAnalyticsCookies);
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import taskList from '../../../../partials/insurance/taskList';

/**
* clickTaskBusiness
* Click the "Business" task link
*/
const clickTaskBusiness = () => {
const task = taskList.prepareApplication.tasks.business;

task.link().click();
};

export default clickTaskBusiness;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import taskList from '../../../../partials/insurance/taskList';

/**
* clickTaskBuyer
* Click the "Buyer" task link
*/
const clickTaskBuyer = () => {
const task = taskList.prepareApplication.tasks.buyer;

task.link().click();
};

export default clickTaskBuyer;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import taskList from '../../../../partials/insurance/taskList';

/**
* clickTaskCheckAnswers
* Click the "Check answers" task link
*/
const clickTaskCheckAnswers = () => {
const task = taskList.submitApplication.tasks.checkAnswers;

task.link().click();
};

export default clickTaskCheckAnswers;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import taskList from '../../../../partials/insurance/taskList';

/**
* clickTaskDeclarationsAndSubmit
* Click the "Declarations and submit" task link
*/
const clickTaskDeclarationsAndSubmit = () => {
const task = taskList.submitApplication.tasks.declarationsAndSubmit;

task.link().click();
};

export default clickTaskDeclarationsAndSubmit;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import taskList from '../../../../partials/insurance/taskList';

/**
* clickTaskExportContract
* Click the "Export contract" task link
*/
const clickTaskExportContract = () => {
const task = taskList.prepareApplication.tasks.exportContract;

task.link().click();
};

export default clickTaskExportContract;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import taskList from '../../../../partials/insurance/taskList';

/**
* clickTaskPolicy
* Click the "Policy" task link
*/
const clickTaskPolicy = () => {
const task = taskList.prepareApplication.tasks.policy;

task.link().click();
};

export default clickTaskPolicy;
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { status, summaryList } from '../../../../../../../../pages/shared';
import partials from '../../../../../../../../partials';
import { DEFAULT } from '../../../../../../../../content-strings';
import FIELD_IDS from '../../../../../../../../constants/field-ids/insurance/export-contract';
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance';
Expand All @@ -14,10 +13,6 @@ const {
ABOUT_GOODS_OR_SERVICES: { FINAL_DESTINATION: FIELD_ID },
} = FIELD_IDS;

const { taskList } = partials.insurancePartials;

const task = taskList.submitApplication.tasks.checkAnswers;

const getFieldVariables = (referenceNumber) => ({
route: ABOUT_GOODS_OR_SERVICES_CHECK_AND_CHANGE,
checkYourAnswersRoute: EXPORT_CONTRACT,
Expand All @@ -42,7 +37,7 @@ context(

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

task.link().click();
cy.clickTaskCheckAnswers();

// To get past previous "Check your answers" pages
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { field, status, summaryList } from '../../../../../../../../pages/shared';
import partials from '../../../../../../../../partials';
import FIELD_IDS from '../../../../../../../../constants/field-ids/insurance/export-contract';
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance';
import application from '../../../../../../../../fixtures/application';
Expand All @@ -15,10 +14,6 @@ const {
ABOUT_GOODS_OR_SERVICES: { DESCRIPTION, FINAL_DESTINATION },
} = FIELD_IDS;

const { taskList } = partials.insurancePartials;

const task = taskList.submitApplication.tasks.checkAnswers;

const getFieldVariables = (fieldId, referenceNumber) => ({
changeLink: summaryList.field(fieldId).changeLink,
checkYourAnswersRoute: EXPORT_CONTRACT,
Expand Down Expand Up @@ -46,7 +41,7 @@ context('Insurance - Change your answers - Export contract - Summary list - Abou
finalDestinationKnown: true,
});

task.link().click();
cy.clickTaskCheckAnswers();

// To get past previous "Check your answers" pages
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { summaryList } from '../../../../../../../../pages/shared';
import partials from '../../../../../../../../partials';
import FIELD_IDS from '../../../../../../../../constants/field-ids/insurance/export-contract';
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance';
import application from '../../../../../../../../fixtures/application';
Expand All @@ -16,10 +15,6 @@ const {
AGENT_CHARGES: { FIXED_SUM_AMOUNT, PAYABLE_COUNTRY_CODE },
} = FIELD_IDS;

const { taskList } = partials.insurancePartials;

const task = taskList.submitApplication.tasks.checkAnswers;

const fieldId = FIXED_SUM_AMOUNT;

const baseUrl = Cypress.config('baseUrl');
Expand All @@ -41,7 +36,7 @@ context(
agentChargeMethodFixedSum: true,
});

task.link().click();
cy.clickTaskCheckAnswers();

// To get past previous "Check your answers" pages
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { status, summaryList } from '../../../../../../../../pages/shared';
import partials from '../../../../../../../../partials';
import FIELD_IDS from '../../../../../../../../constants/field-ids/insurance/export-contract';
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance';
import formatCurrency from '../../../../../../../../helpers/format-currency';
Expand All @@ -15,10 +14,6 @@ const {
AGENT_CHARGES: { FIXED_SUM_AMOUNT },
} = FIELD_IDS;

const { taskList } = partials.insurancePartials;

const task = taskList.submitApplication.tasks.checkAnswers;

const fieldId = FIXED_SUM_AMOUNT;

const baseUrl = Cypress.config('baseUrl');
Expand All @@ -38,7 +33,7 @@ context(`Insurance - Change your answers - Export contract - Summary list - Agen
agentChargeMethodFixedSum: true,
});

task.link().click();
cy.clickTaskCheckAnswers();

// To get past previous "Check your answers" pages
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { status, summaryList } from '../../../../../../../../pages/shared';
import partials from '../../../../../../../../partials';
import FIELD_IDS from '../../../../../../../../constants/field-ids/insurance/export-contract';
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance';
import checkSummaryList from '../../../../../../../../commands/insurance/check-export-contract-summary-list';
Expand All @@ -14,10 +13,6 @@ const {
AGENT_CHARGES: { FIXED_SUM_AMOUNT, PERCENTAGE_CHARGE, PAYABLE_COUNTRY_CODE },
} = FIELD_IDS;

const { taskList } = partials.insurancePartials;

const task = taskList.submitApplication.tasks.checkAnswers;

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

context('Insurance - Change your answers - Export contract - Summary list - Agent charges - Fixed sum to percentage', () => {
Expand All @@ -35,7 +30,7 @@ context('Insurance - Change your answers - Export contract - Summary list - Agen
agentChargeMethodFixedSum: true,
});

task.link().click();
cy.clickTaskCheckAnswers();

// To get past previous "Check your answers" pages
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { status, summaryList } from '../../../../../../../../pages/shared';
import partials from '../../../../../../../../partials';
import FIELD_IDS from '../../../../../../../../constants/field-ids/insurance/export-contract';
import { INSURANCE_ROUTES } from '../../../../../../../../constants/routes/insurance';
import { XAD } from '../../../../../../../../fixtures/countries';
Expand All @@ -14,10 +13,6 @@ const {
AGENT_CHARGES: { PAYABLE_COUNTRY_CODE },
} = FIELD_IDS;

const { taskList } = partials.insurancePartials;

const task = taskList.submitApplication.tasks.checkAnswers;

const NEW_COUNTRY_INPUT = XAD.NAME;

const fieldId = PAYABLE_COUNTRY_CODE;
Expand All @@ -39,7 +34,7 @@ context(`Insurance - Change your answers - Export contract - Summary list - Agen
agentChargeMethodFixedSum: true,
});

task.link().click();
cy.clickTaskCheckAnswers();

// To get past previous "Check your answers" pages
cy.completeAndSubmitMultipleCheckYourAnswers({ count: 3 });
Expand Down
Loading

0 comments on commit 3434e25

Please sign in to comment.