Skip to content

Commit

Permalink
fix(EMS-3945): policy - total contract value - credit limit hint
Browse files Browse the repository at this point in the history
  • Loading branch information
ttbarnes committed Oct 17, 2024
1 parent d78ae51 commit 9d438be
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 34 deletions.
5 changes: 4 additions & 1 deletion e2e-tests/content-strings/fields/insurance/policy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export const POLICY_FIELDS = {
},
[CONTRACT_POLICY.SINGLE.REQUESTED_CREDIT_LIMIT]: {
LABEL: 'What credit limit do you require?',
HINT: 'For example, your total contract maybe £250,000 but the amount you want to insure is £100,000.',
HINT: {
INTRO: 'For example, your total contract maybe £250,000 but the amount you want to insure is £100,000.',
OUTRO: 'Enter a whole number. Do not enter decimals.',
},
SUMMARY: {
TITLE: 'Credit limit',
FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { headingCaption, yesRadio, noRadio, autoCompleteField } from '../../../../../../pages/shared';
import { autoCompleteField, field as fieldSelector, headingCaption, yesRadio, noRadio } from '../../../../../../pages/shared';
import { aboutGoodsOrServicesPage } from '../../../../../../pages/insurance/export-contract';
import { PAGES } from '../../../../../../content-strings';
import { EXPORT_CONTRACT_FIELDS as FIELDS } from '../../../../../../content-strings/fields/insurance/export-contract';
Expand Down Expand Up @@ -72,20 +72,20 @@ context(
const fieldId = DESCRIPTION;
const field = aboutGoodsOrServicesPage[fieldId];

const fieldStrings = FIELDS.ABOUT_GOODS_OR_SERVICES[fieldId];
const { HINT, LABEL, MAXIMUM } = FIELDS.ABOUT_GOODS_OR_SERVICES[fieldId];

cy.checkText(field.hint.intro(), fieldStrings.HINT.INTRO);
cy.checkText(fieldSelector(fieldId).hintIntro(), HINT.INTRO);

cy.checkText(field.hint.list.item1(), fieldStrings.HINT.LIST[0]);
cy.checkText(field.hint.list.item2(), fieldStrings.HINT.LIST[1]);
cy.checkText(field.hint.list.item3(), fieldStrings.HINT.LIST[2]);
cy.checkText(field.hint.list.item1(), HINT.LIST[0]);
cy.checkText(field.hint.list.item2(), HINT.LIST[1]);
cy.checkText(field.hint.list.item3(), HINT.LIST[2]);

cy.checkText(field.hint.outro(), fieldStrings.HINT.OUTRO);
cy.checkText(fieldSelector(fieldId).hintOutro(), HINT.OUTRO);

cy.assertTextareaRendering({
fieldId,
expectedLabel: fieldStrings.LABEL,
maximumCharacters: fieldStrings.MAXIMUM,
expectedLabel: LABEL,
maximumCharacters: MAXIMUM,
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { headingCaption } from '../../../../../../pages/shared';
import { field as fieldSelector, headingCaption } from '../../../../../../pages/shared';
import { howWillYouGetPaidPage } from '../../../../../../pages/insurance/export-contract';
import { EXPECTED_MULTI_LINE_STRING, MAXIMUM_CHARACTERS } from '../../../../../../constants';
import { ERROR_MESSAGES, PAGES } from '../../../../../../content-strings';
Expand Down Expand Up @@ -73,13 +73,13 @@ context(
it(`renders ${FIELD_ID} hint and textarea`, () => {
const { HINT } = FIELD_STRINGS.HOW_WILL_YOU_GET_PAID[FIELD_ID];

cy.checkText(field.hint.intro(), HINT.INTRO);
cy.checkText(fieldSelector(FIELD_ID).hintIntro(), HINT.INTRO);

cy.checkText(field.hint.list.item1(), HINT.LIST[0]);
cy.checkText(field.hint.list.item2(), HINT.LIST[1]);
cy.checkText(field.hint.list.item3(), HINT.LIST[2]);

cy.checkText(field.hint.outro(), HINT.OUTRO);
cy.checkText(fieldSelector(FIELD_ID).hintOutro(), HINT.OUTRO);

cy.assertTextareaRendering({
fieldId: FIELD_ID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import partials from '../../../../../../partials';
import { field as fieldSelector, noRadio, noRadioInput, yesRadio } from '../../../../../../pages/shared';
import { lossPayeePage } from '../../../../../../pages/insurance/policy';
import { ERROR_MESSAGES, PAGES } from '../../../../../../content-strings';
import { FIELD_VALUES } from '../../../../../../constants';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
Expand Down Expand Up @@ -79,8 +78,8 @@ context(
},
} = FIELD_STRINGS;

cy.checkText(lossPayeePage.radioHint(FIELD_ID).intro(), INTRO);
cy.checkText(lossPayeePage.radioHint(FIELD_ID).outro(), OUTRO);
cy.checkText(fieldSelector(FIELD_ID).hintIntro(), INTRO);
cy.checkText(fieldSelector(FIELD_ID).hintOutro(), OUTRO);
});

it('renders a `no` radio button', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ context(
const fieldId = REQUESTED_CREDIT_LIMIT;
const field = fieldSelector(fieldId);

cy.checkText(field.hint(), FIELDS.CONTRACT_POLICY.SINGLE[fieldId].HINT);
cy.checkText(field.hintIntro(), FIELDS.CONTRACT_POLICY.SINGLE[fieldId].HINT.INTRO);
cy.checkText(field.hintOutro(), FIELDS.CONTRACT_POLICY.SINGLE[fieldId].HINT.OUTRO);

cy.checkText(field.prefix(), SYMBOLS.GBP);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ const aboutGoodsOrServices = {
[DESCRIPTION]: {
...field(DESCRIPTION),
hint: {
intro: () => cy.get(`[data-cy="${DESCRIPTION}-hint-intro"]`),
list: {
item1: () => cy.get(`[data-cy="${DESCRIPTION}-hint-list-item-1"]`),
item2: () => cy.get(`[data-cy="${DESCRIPTION}-hint-list-item-2"]`),
item3: () => cy.get(`[data-cy="${DESCRIPTION}-hint-list-item-3"]`),
},
outro: () => cy.get(`[data-cy="${DESCRIPTION}-hint-outro"]`),
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ const howWillYouGetPaid = {
...field,
input: field.textarea,
hint: {
intro: () => cy.get(`[data-cy="${PAYMENT_TERMS_DESCRIPTION}-hint-intro"]`),
list: {
item1: () => cy.get(`[data-cy="${PAYMENT_TERMS_DESCRIPTION}-hint-list-item-1"]`),
item2: () => cy.get(`[data-cy="${PAYMENT_TERMS_DESCRIPTION}-hint-list-item-2"]`),
item3: () => cy.get(`[data-cy="${PAYMENT_TERMS_DESCRIPTION}-hint-list-item-3"]`),
},
outro: () => cy.get(`[data-cy="${PAYMENT_TERMS_DESCRIPTION}-hint-outro"]`),
},
},
};
Expand Down
3 changes: 1 addition & 2 deletions e2e-tests/pages/insurance/policy/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import brokerPage from './broker';
import brokerConfirmAddressPage from './brokerConfirmAddress';
import lossPayeePage from './lossPayee';
import multipleContractPolicyExportValuePage from './multipleContractPolicyExportValue';
import typeOfPolicyPage from './typeOfPolicy';

export { brokerPage, brokerConfirmAddressPage, lossPayeePage, multipleContractPolicyExportValuePage, typeOfPolicyPage };
export { brokerPage, brokerConfirmAddressPage, multipleContractPolicyExportValuePage, typeOfPolicyPage };
8 changes: 0 additions & 8 deletions e2e-tests/pages/insurance/policy/lossPayee.js

This file was deleted.

2 changes: 2 additions & 0 deletions e2e-tests/pages/shared/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const field = (id) => ({
legend: () => cy.get(`[data-cy="${id}-legend`),
heading: () => cy.get(`[data-cy="${id}-heading"]`),
hint: () => cy.get(`[data-cy="${id}-hint"]`),
hintIntro: () => cy.get(`[data-cy="${id}-hint-intro"]`),
hintOutro: () => cy.get(`[data-cy="${id}-hint-outro"]`),
input: () => cy.get(`[data-cy="${id}-input"]`),
textarea: () => cy.get(`[data-cy="${id}"]`),
inputOption: () => cy.get(`[data-cy="${id}-input"]`).find('option'),
Expand Down
5 changes: 4 additions & 1 deletion src/api/content-strings/fields/insurance/policy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export const POLICY_FIELDS = {
},
[CONTRACT_POLICY.SINGLE.REQUESTED_CREDIT_LIMIT]: {
LABEL: 'What credit limit do you require?',
HINT: 'For example, your total contract maybe £250,000 but the amount you want to insure is £100,000.',
HINT: {
INTRO: 'For example, your total contract maybe £250,000 but the amount you want to insure is £100,000.',
OUTRO: 'Enter a whole number. Do not enter decimals.',
},
SUMMARY: {
TITLE: 'Credit limit',
FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export const POLICY_FIELDS = {
},
[CONTRACT_POLICY.SINGLE.REQUESTED_CREDIT_LIMIT]: {
LABEL: 'What credit limit do you require?',
HINT: 'For example, your total contract maybe £250,000 but the amount you want to insure is £100,000.',
HINT: {
INTRO: 'For example, your total contract maybe £250,000 but the amount you want to insure is £100,000.',
OUTRO: 'Enter a whole number. Do not enter decimals.',
},
SUMMARY: {
TITLE: 'Credit limit',
FORM_TITLE: POLICY_FORM_TITLES.CONTRACT_POLICY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@
validationError: validationErrors.errorList[FIELDS.TOTAL_CONTRACT_VALUE.ID]
}) }}

{% set hintHtml %}
<p class="govuk-hint" data-cy="{{ FIELDS.REQUESTED_CREDIT_LIMIT.ID }}-hint-intro">{{ FIELDS.REQUESTED_CREDIT_LIMIT.HINT.INTRO }}</p>
<p class="govuk-hint" data-cy="{{ FIELDS.REQUESTED_CREDIT_LIMIT.ID }}-hint-outro">{{ FIELDS.REQUESTED_CREDIT_LIMIT.HINT.OUTRO }}</p>
{% endset %}

{{ monetaryValueInput.render({
fieldId: FIELDS.REQUESTED_CREDIT_LIMIT.ID,
label: FIELDS.REQUESTED_CREDIT_LIMIT.LABEL,
hintText: FIELDS.REQUESTED_CREDIT_LIMIT.HINT,
hintHtml: hintHtml,
currencyPrefixSymbol: CURRENCY_PREFIX_SYMBOL,
submittedValue: submittedValues[FIELDS.REQUESTED_CREDIT_LIMIT.ID] or application.policy[FIELDS.REQUESTED_CREDIT_LIMIT.ID],
validationError: validationErrors.errorList[FIELDS.REQUESTED_CREDIT_LIMIT.ID]
Expand Down

0 comments on commit 9d438be

Please sign in to comment.