Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(EMS-4063): declarations - modern slavery - textarea edge cases #3440

Merged
merged 5 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
DECLARATIONS: {
CONFIDENTIALITY,
ANTI_BRIBERY: { ROOT: ANTI_BRIBERY_ROOT, CODE_OF_CONDUCT, EXPORTING_WITH_CODE_OF_CONDUCT },
MODERN_SLAVERY,
CONFIRMATION_AND_ACKNOWLEDGEMENTS,
},
} = INSURANCE_ROUTES;
Expand Down Expand Up @@ -33,39 +34,47 @@ context('Insurance - Declaration - cannot skip to any Declarations page without
cy.deleteApplication();
});

it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - Confidentiality page directly`, () => {
it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - ${CONFIDENTIALITY} page directly`, () => {
const url = `${insuranceRoute}/${referenceNumber}${CONFIDENTIALITY}`;

cy.navigateToUrl(url);

cy.assertUrl(completeOtherSectionsUrl);
});

it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - Anti-bribery page directly`, () => {
it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - ${ANTI_BRIBERY_ROOT} page directly`, () => {
const url = `${insuranceRoute}/${referenceNumber}${ANTI_BRIBERY_ROOT}`;

cy.navigateToUrl(url);

cy.assertUrl(completeOtherSectionsUrl);
});

it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - Anti-bribery - Code of conduct page directly`, () => {
it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - ${CODE_OF_CONDUCT} page directly`, () => {
const url = `${insuranceRoute}/${referenceNumber}${CODE_OF_CONDUCT}`;

cy.navigateToUrl(url);

cy.assertUrl(completeOtherSectionsUrl);
});

it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - Anti-bribery - Exporting with code of conduct page directly`, () => {
it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - ${EXPORTING_WITH_CODE_OF_CONDUCT} page directly`, () => {
const url = `${insuranceRoute}/${referenceNumber}${EXPORTING_WITH_CODE_OF_CONDUCT}`;

cy.navigateToUrl(url);

cy.assertUrl(completeOtherSectionsUrl);
});

it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - Confirmation and acknowledgements page directly`, () => {
it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - ${MODERN_SLAVERY} page directly`, () => {
const url = `${insuranceRoute}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);

cy.assertUrl(completeOtherSectionsUrl);
});

it(`should redirect to ${COMPLETE_OTHER_SECTIONS} when navigating to the Declarations - ${CONFIRMATION_AND_ACKNOWLEDGEMENTS} page directly`, () => {
const url = `${insuranceRoute}/${referenceNumber}${CONFIRMATION_AND_ACKNOWLEDGEMENTS}`;

cy.navigateToUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ context('Insurance - Declarations - Modern slavery page - expandable `definition
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'exportingWithCodeOfConduct', referenceNumber });
cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);
cy.assertUrl(url);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ context('Insurance - Declarations - Modern slavery page - radios - No to yes', (
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ context('Insurance - Declarations - Modern slavery page - radios - Yes to no', (
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ context(
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

cy.completeAndSubmitDeclarationsForms({ formToStopAt: 'exportingWithCodeOfConduct', referenceNumber });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ context('Insurance - Declarations - Modern slavery page - validation - submittin
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ context('Insurance - Declarations - Modern slavery page - validation - submittin
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ context(`Insurance - Declarations - Modern slavery page - validation - ${fieldId
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ context(`Insurance - Declarations - Modern slavery page - validation - ${fieldId
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ context(`Insurance - Declarations - Modern slavery page - validation - ${fieldId
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { INSURANCE_ROUTES } from '../../../../../constants/routes/insurance';
import { DECLARATIONS as DECLARATIONS_FIELD_IDS } from '../../../../../constants/field-ids/insurance/declarations';

const {
ROOT,
DECLARATIONS: { MODERN_SLAVERY },
} = INSURANCE_ROUTES;

const {
MODERN_SLAVERY: {
CONDITIONAL_REASONS: { CANNOT_ADHERE_TO_ALL_REQUIREMENTS, OFFENSES_OR_INVESTIGATIONS, AWARE_OF_EXISTING_SLAVERY },
},
} = DECLARATIONS_FIELD_IDS;

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

const numberString = '1';

context('Insurance - Declarations - Textarea fields - Textarea fields should be able to submit after entering a pure number', () => {
let referenceNumber;
let modernSlaveryUrl;

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

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

modernSlaveryUrl = `${baseUrl}${ROOT}/${referenceNumber}${MODERN_SLAVERY}`;
});
});

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

describe(CANNOT_ADHERE_TO_ALL_REQUIREMENTS, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(modernSlaveryUrl);

cy.completeModernSlaveryForm({
willAdhereToAllRequirements: false,
});

cy.completeAndSubmitModernSlaveryFormConditionalFields({
cannotAdhereToAllRequirements: numberString,
offensesOrInvestigations: null,
awareOfExistingSlavery: null,
});

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkTextareaValue({
fieldId: CANNOT_ADHERE_TO_ALL_REQUIREMENTS,
expectedValue: numberString,
});
});
});
});

describe(OFFENSES_OR_INVESTIGATIONS, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(modernSlaveryUrl);

cy.completeModernSlaveryForm({
hasNoOffensesOrInvestigations: false,
});

cy.completeAndSubmitModernSlaveryFormConditionalFields({
cannotAdhereToAllRequirements: null,
offensesOrInvestigations: numberString,
awareOfExistingSlavery: null,
});

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkTextareaValue({
fieldId: OFFENSES_OR_INVESTIGATIONS,
expectedValue: numberString,
});
});
});
});

describe(AWARE_OF_EXISTING_SLAVERY, () => {
describe('when submitting the textarea field with a pure number and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(modernSlaveryUrl);

cy.completeModernSlaveryForm({
isNotAwareOfExistingSlavery: false,
});

cy.completeAndSubmitModernSlaveryFormConditionalFields({
cannotAdhereToAllRequirements: null,
offensesOrInvestigations: null,
awareOfExistingSlavery: numberString,
});

cy.clickBackLink();
});

it('should render the pure number exactly as it was submitted', () => {
cy.checkTextareaValue({
fieldId: AWARE_OF_EXISTING_SLAVERY,
expectedValue: numberString,
});
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { INSURANCE_ROUTES } from '../../../../../constants/routes/insurance';
import { DECLARATIONS as DECLARATIONS_FIELD_IDS } from '../../../../../constants/field-ids/insurance/declarations';
import { MULTI_LINE_STRING, EXPECTED_MULTI_LINE_STRING } from '../../../../../constants';

const {
ROOT,
DECLARATIONS: { MODERN_SLAVERY },
} = INSURANCE_ROUTES;

const {
MODERN_SLAVERY: {
CONDITIONAL_REASONS: { CANNOT_ADHERE_TO_ALL_REQUIREMENTS, OFFENSES_OR_INVESTIGATIONS, AWARE_OF_EXISTING_SLAVERY },
},
} = DECLARATIONS_FIELD_IDS;

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

context('Insurance - Textarea fields - `Declarations` textarea fields should render new lines without character codes after submission', () => {
let referenceNumber;
let modernSlaveryUrl;

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

cy.completePrepareApplicationSinglePolicyType({ referenceNumber });

modernSlaveryUrl = `${baseUrl}${ROOT}/${referenceNumber}${MODERN_SLAVERY}`;
});
});

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

describe(CANNOT_ADHERE_TO_ALL_REQUIREMENTS, () => {
describe('when submitting the textarea field with new lines va the `enter` key and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(modernSlaveryUrl);

cy.completeModernSlaveryForm({
willAdhereToAllRequirements: false,
});

cy.completeAndSubmitModernSlaveryFormConditionalFields({
cannotAdhereToAllRequirements: MULTI_LINE_STRING,
offensesOrInvestigations: null,
awareOfExistingSlavery: null,
});

cy.clickBackLink();
});

it('should render new line characters exactly as they were submitted', () => {
cy.checkTextareaValue({
fieldId: CANNOT_ADHERE_TO_ALL_REQUIREMENTS,
expectedValue: EXPECTED_MULTI_LINE_STRING,
});
});
});
});

describe(OFFENSES_OR_INVESTIGATIONS, () => {
describe('when submitting the textarea field with new lines va the `enter` key and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(modernSlaveryUrl);

cy.completeModernSlaveryForm({
hasNoOffensesOrInvestigations: false,
});

cy.completeAndSubmitModernSlaveryFormConditionalFields({
cannotAdhereToAllRequirements: null,
offensesOrInvestigations: MULTI_LINE_STRING,
awareOfExistingSlavery: null,
});

cy.clickBackLink();
});

it('should render new line characters exactly as they were submitted', () => {
cy.checkTextareaValue({
fieldId: OFFENSES_OR_INVESTIGATIONS,
expectedValue: EXPECTED_MULTI_LINE_STRING,
});
});
});
});

describe(AWARE_OF_EXISTING_SLAVERY, () => {
describe('when submitting the textarea field with new lines va the `enter` key and going back to the page', () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(modernSlaveryUrl);

cy.completeModernSlaveryForm({
isNotAwareOfExistingSlavery: false,
});

cy.completeAndSubmitModernSlaveryFormConditionalFields({
cannotAdhereToAllRequirements: null,
offensesOrInvestigations: null,
awareOfExistingSlavery: MULTI_LINE_STRING,
});

cy.clickBackLink();
});

it('should render new line characters exactly as they were submitted', () => {
cy.checkTextareaValue({
fieldId: AWARE_OF_EXISTING_SLAVERY,
expectedValue: EXPECTED_MULTI_LINE_STRING,
});
});
});
});
});
Loading
Loading