-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(EMS-3385): no PDF - policy - nullify data when changing policy ty…
…pe (#2500) * fix(EMS-3385): no pdf - policy - nullify data when changing type of policy * fix(EMS-3385): no pdf - policy - nullify data when changing type of policy * fix(EMS-3385): no pdf - policy - nullify data when changing type of policy * fix(EMS-3385): add missing documentation * fix(EMS-3385): no pdf - policy - nullify data when changing type of policy * fix(EMS-3385): improve unit test * fix(EMS-3385): linting issues
- Loading branch information
Showing
34 changed files
with
802 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
e2e-tests/commands/insurance/change-policy-type-to-single-and-submit-contract-policy-form.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { summaryList } from '../../pages/shared'; | ||
import { typeOfPolicyPage } from '../../pages/insurance/policy'; | ||
import { POLICY as FIELD_IDS } from '../../constants/field-ids/insurance/policy'; | ||
|
||
const { | ||
TYPE_OF_POLICY: { POLICY_TYPE }, | ||
} = FIELD_IDS; | ||
|
||
/** | ||
* changePolicyTypeToSingleAndSubmitContractPolicyForm | ||
* Change policy type to single and submit the "single contract policy" form. | ||
*/ | ||
const changePolicyTypeToSingleAndSubmitContractPolicyForm = () => { | ||
summaryList.field(POLICY_TYPE).changeLink().click(); | ||
|
||
typeOfPolicyPage[POLICY_TYPE].single.label().click(); | ||
cy.clickSubmitButton(); | ||
|
||
cy.completeAndSubmitSingleContractPolicyForm({}); | ||
}; | ||
|
||
export default changePolicyTypeToSingleAndSubmitContractPolicyForm; |
42 changes: 42 additions & 0 deletions
42
e2e-tests/commands/shared-commands/assertions/assert-currency-form-fields-are-empty.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { radios } from '../../../pages/shared'; | ||
import { INSURANCE_FIELD_IDS } from '../../../constants/field-ids/insurance'; | ||
import { checkAutocompleteInput } from '../../../shared-test-assertions/autocomplete-assertions'; | ||
import { | ||
EUR, | ||
GBP, | ||
JPY, | ||
USD, | ||
} from '../../../fixtures/currencies'; | ||
|
||
const { | ||
CURRENCY: { CURRENCY_CODE, ALTERNATIVE_CURRENCY_CODE }, | ||
} = INSURANCE_FIELD_IDS; | ||
|
||
/** | ||
* assertCurrencyFormFieldsAreEmpty | ||
* Assert that all "currency" form fields are empty: | ||
* - 4x default options. | ||
* - "alternative currency" option | ||
* - "alternative currency" conditional autocomplete input. | ||
*/ | ||
const assertCurrencyFormFieldsAreEmpty = () => { | ||
const fieldId = CURRENCY_CODE; | ||
|
||
const { option: option1 } = radios(fieldId, EUR.isoCode); | ||
const { option: option2 } = radios(fieldId, GBP.isoCode); | ||
const { option: option3 } = radios(fieldId, USD.isoCode); | ||
const { option: option4 } = radios(fieldId, JPY.isoCode); | ||
const { option: option5 } = radios(ALTERNATIVE_CURRENCY_CODE); | ||
|
||
cy.assertRadioOptionIsNotChecked(option1.input()); | ||
cy.assertRadioOptionIsNotChecked(option2.input()); | ||
cy.assertRadioOptionIsNotChecked(option3.input()); | ||
cy.assertRadioOptionIsNotChecked(option4.input()); | ||
cy.assertRadioOptionIsNotChecked(option5.input()); | ||
|
||
cy.clickAlternativeCurrencyRadioOption(); | ||
|
||
checkAutocompleteInput.checkEmptyResults(); | ||
}; | ||
|
||
export default assertCurrencyFormFieldsAreEmpty; |
20 changes: 20 additions & 0 deletions
20
...commands/shared-commands/assertions/assert-empty-contract-completion-date-field-values.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { field } from '../../../pages/shared'; | ||
import FIELD_IDS from '../../../constants/field-ids/insurance/policy'; | ||
|
||
const { | ||
CONTRACT_POLICY: { | ||
SINGLE: { CONTRACT_COMPLETION_DATE }, | ||
}, | ||
} = FIELD_IDS; | ||
|
||
/** | ||
* assertEmptyContractCompletionDateFieldValues | ||
* Assert all CONTRACT_COMPLETION_DATE field values are empty. | ||
*/ | ||
const assertEmptyContractCompletionDateFieldValues = () => { | ||
field(CONTRACT_COMPLETION_DATE).dayInput().should('have.value', ''); | ||
field(CONTRACT_COMPLETION_DATE).monthInput().should('have.value', ''); | ||
field(CONTRACT_COMPLETION_DATE).yearInput().should('have.value', ''); | ||
}; | ||
|
||
export default assertEmptyContractCompletionDateFieldValues; |
18 changes: 18 additions & 0 deletions
18
...sts/commands/shared-commands/assertions/assert-empty-requested-start-date-field-values.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { field } from '../../../pages/shared'; | ||
import FIELD_IDS from '../../../constants/field-ids/insurance/policy'; | ||
|
||
const { | ||
CONTRACT_POLICY: { REQUESTED_START_DATE }, | ||
} = FIELD_IDS; | ||
|
||
/** | ||
* assertEmptyRequestedStartDateFieldValues | ||
* Assert all REQUESTED_START_DATE field values are empty. | ||
*/ | ||
const assertEmptyRequestedStartDateFieldValues = () => { | ||
field(REQUESTED_START_DATE).dayInput().should('have.value', ''); | ||
field(REQUESTED_START_DATE).monthInput().should('have.value', ''); | ||
field(REQUESTED_START_DATE).yearInput().should('have.value', ''); | ||
}; | ||
|
||
export default assertEmptyRequestedStartDateFieldValues; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...iple-policy/change-your-answers-change-policy-type-multiple-to-single-to-multiple.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { field, summaryList } from '../../../../../../../pages/shared'; | ||
import { FIELD_VALUES } from '../../../../../../../constants'; | ||
import FIELD_IDS from '../../../../../../../constants/field-ids/insurance/policy'; | ||
import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; | ||
|
||
const { | ||
POLICY_TYPE: { MULTIPLE }, | ||
} = FIELD_VALUES; | ||
|
||
const { | ||
ROOT, | ||
POLICY: { CHECK_YOUR_ANSWERS, MULTIPLE_CONTRACT_POLICY, MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE }, | ||
} = INSURANCE_ROUTES; | ||
|
||
const { | ||
TYPE_OF_POLICY: { POLICY_TYPE }, | ||
CONTRACT_POLICY: { | ||
MULTIPLE: { TOTAL_MONTHS_OF_COVER }, | ||
}, | ||
EXPORT_VALUE: { | ||
MULTIPLE: { TOTAL_SALES_TO_BUYER, MAXIMUM_BUYER_WILL_OWE }, | ||
}, | ||
} = FIELD_IDS; | ||
|
||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
context('Insurance - Policy - Change your answers - Policy type - multiple to single, then back to multiple', () => { | ||
let referenceNumber; | ||
let checkYourAnswersUrl; | ||
let exportValueUrl; | ||
|
||
before(() => { | ||
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { | ||
referenceNumber = refNumber; | ||
|
||
cy.completePolicySection({ policyType: MULTIPLE }); | ||
|
||
const applicationRouteUrl = `${ROOT}/${referenceNumber}`; | ||
|
||
checkYourAnswersUrl = `${baseUrl}${applicationRouteUrl}${CHECK_YOUR_ANSWERS}`; | ||
exportValueUrl = `${baseUrl}${applicationRouteUrl}${MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE}`; | ||
|
||
cy.assertUrl(checkYourAnswersUrl); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.saveSession(); | ||
|
||
cy.navigateToUrl(checkYourAnswersUrl); | ||
|
||
cy.changePolicyTypeToSingleAndSubmitContractPolicyForm(); | ||
cy.completeAndSubmitTotalContractValueForm({}); | ||
|
||
summaryList.field(POLICY_TYPE).changeLink().click(); | ||
|
||
cy.completeAndSubmitPolicyTypeForm({ policyType: MULTIPLE }); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteApplication(referenceNumber); | ||
}); | ||
|
||
it(`should have empty field values when going back to ${MULTIPLE_CONTRACT_POLICY} and ${MULTIPLE_CONTRACT_POLICY_EXPORT_VALUE}`, () => { | ||
cy.assertEmptyRequestedStartDateFieldValues(); | ||
|
||
field(TOTAL_MONTHS_OF_COVER).input().should('have.value', ''); | ||
|
||
cy.assertCurrencyFormFieldsAreEmpty(); | ||
|
||
cy.navigateToUrl(exportValueUrl); | ||
|
||
field(TOTAL_SALES_TO_BUYER).input().should('have.value', ''); | ||
field(MAXIMUM_BUYER_WILL_OWE).input().should('have.value', ''); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...single-policy/change-your-answers-change-policy-type-single-to-multiple-to-single.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { field, summaryList } from '../../../../../../../pages/shared'; | ||
import { FIELD_VALUES } from '../../../../../../../constants'; | ||
import { INSURANCE_ROUTES } from '../../../../../../../constants/routes/insurance'; | ||
import FIELD_IDS from '../../../../../../../constants/field-ids/insurance/policy'; | ||
|
||
const { | ||
POLICY_TYPE: { SINGLE }, | ||
} = FIELD_VALUES; | ||
|
||
const { | ||
ROOT, | ||
POLICY: { CHECK_YOUR_ANSWERS, SINGLE_CONTRACT_POLICY, SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE }, | ||
} = INSURANCE_ROUTES; | ||
|
||
const { | ||
TYPE_OF_POLICY: { POLICY_TYPE }, | ||
CONTRACT_POLICY: { | ||
SINGLE: { TOTAL_CONTRACT_VALUE }, | ||
}, | ||
} = FIELD_IDS; | ||
|
||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
context('Insurance - Policy - Change your answers - Policy type - single to multiple, then back to single', () => { | ||
let referenceNumber; | ||
let checkYourAnswersUrl; | ||
let totalContractValueUrl; | ||
|
||
before(() => { | ||
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { | ||
referenceNumber = refNumber; | ||
|
||
cy.completePolicySection({}); | ||
|
||
const applicationRouteUrl = `${ROOT}/${referenceNumber}`; | ||
|
||
checkYourAnswersUrl = `${baseUrl}${applicationRouteUrl}${CHECK_YOUR_ANSWERS}`; | ||
totalContractValueUrl = `${baseUrl}${applicationRouteUrl}${SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE}`; | ||
|
||
cy.assertUrl(checkYourAnswersUrl); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.saveSession(); | ||
|
||
cy.navigateToUrl(checkYourAnswersUrl); | ||
|
||
cy.changePolicyTypeToMultipleAndSubmitContractPolicyForm(); | ||
cy.completeAndSubmitExportValueForm(); | ||
|
||
summaryList.field(POLICY_TYPE).changeLink().click(); | ||
|
||
cy.completeAndSubmitPolicyTypeForm({ policyType: SINGLE }); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteApplication(referenceNumber); | ||
}); | ||
|
||
it(`should have empty field values when going back to ${SINGLE_CONTRACT_POLICY} and ${SINGLE_CONTRACT_POLICY_TOTAL_CONTRACT_VALUE}`, () => { | ||
cy.assertEmptyRequestedStartDateFieldValues(); | ||
cy.assertEmptyContractCompletionDateFieldValues(); | ||
|
||
cy.assertCurrencyFormFieldsAreEmpty(); | ||
|
||
cy.navigateToUrl(totalContractValueUrl); | ||
|
||
field(TOTAL_CONTRACT_VALUE).input().should('have.value', ''); | ||
}); | ||
}); |
Oops, something went wrong.