diff --git a/src/test/ui/config/axe-exclusions.config.ts b/src/test/ui/config/axe-exclusions.config.ts index f253c8bff..da33079e1 100644 --- a/src/test/ui/config/axe-exclusions.config.ts +++ b/src/test/ui/config/axe-exclusions.config.ts @@ -6,4 +6,5 @@ export const axe_exclusions = [ '#confirmTenancyDate-2', //page: tenancyStartDateKnown, element: 'No', element_type: radioOption, reason_for_exclusion: 'aria-expanded' attribute is expected for this radio button '#tenancyTypeConfirm-2', //page: tenancyOccupationContractLicenseAgreement, element: 'No', element_type: radioOption, reason_for_exclusion: 'aria-expanded' attribute is expected for this radio button '#contactByEmailOrPost', //page: contactPreferenceEmailOrPost, element: 'Yes', element_type: radioOption, reason_for_exclusion: 'aria-expanded' attribute is expected for this radio button + '#rentArrears-2', //page: rentArrears, element: 'Yes', element_type: radioOption, reason_for_exclusion: 'aria-expanded' attribute is expected for this radio button ]; diff --git a/src/test/ui/config/urlToFileMapping.config.ts b/src/test/ui/config/urlToFileMapping.config.ts index b3feacc4e..e41e2fa15 100644 --- a/src/test/ui/config/urlToFileMapping.config.ts +++ b/src/test/ui/config/urlToFileMapping.config.ts @@ -13,7 +13,7 @@ export default { 'confirmation-of-notice-given': 'confirmationOfNoticeGiven', 'non-rent-arrears-dispute': 'nonRentArrearsDispute', 'confirmation-of-notice-date-when-provided': 'noticeDateWhenProvided', - 'rent-arrears-dispute': 'rentArrearsDispute', + 'rent-arrears-dispute': 'rentArrears', 'payment-interstitial': 'paymentInterstitial', 'repayments-made': 'repaymentsMade', 'landlord-registered': 'landlordRegistered', diff --git a/src/test/ui/data/api-data/submitCase.api.data.ts b/src/test/ui/data/api-data/submitCase.api.data.ts index ff54ec6e5..3aca17afd 100644 --- a/src/test/ui/data/api-data/submitCase.api.data.ts +++ b/src/test/ui/data/api-data/submitCase.api.data.ts @@ -1,5 +1,3 @@ -import { v4 as uuidv4 } from 'uuid'; - export const submitCaseApiData = { submitCaseEventName: 'resumePossessionClaim', //Introductory and Demoted tenancy with Tenancy Licence date known for Rent arrears only @@ -97,6 +95,16 @@ export const submitCaseApiData = { settlementAttempted: 'NO', noticeServed: process.env.NOTICE_SERVED, notice_NoticePostedDate: '2025-11-10', + rentDetails_CurrentRent: '100000', + rentDetails_Frequency: 'MONTHLY', + rentDetails_CalculatedDailyCharge: '3285', + rentSectionPaymentFrequency: 'MONTHLY', + rentDetails_FormattedCalculatedDailyCharge: '£32.85', + rentDetails_PerDayCorrect: 'YES', + showRentArrearsPage: 'Yes', + rentArrears_Total: '200000', + rentArrears_ThirdPartyPayments: 'NO', + arrearsJudgmentWanted: 'NO', notice_NoticeDocuments: [], notice_NoticeServiceMethod: 'FIRST_CLASS_POST', claimantNamePossessiveForm: null, @@ -199,8 +207,7 @@ export const submitCaseApiData = { }, }; }, - //Assured tenancy with Tenancy Licence date unknown for Non-Rent arrears only - get submitCasePayloadAssuredTenancy() { + get submitCasePayloadRentNonRent() { return { legislativeCountry: 'England', claimantType: { @@ -232,7 +239,7 @@ export const submitCaseApiData = { orgNameFound: 'Yes', claimantName: 'Possession Claims Solicitor Org', isClaimantNameCorrect: 'YES', - claimantContactEmail: 'pcs-solicitor1@test.com', + claimantContactEmail: 'pcs-solicitor-automation@test.com', isCorrectClaimantContactEmail: 'YES', orgAddressFound: 'Yes', organisationAddress: { @@ -246,23 +253,65 @@ export const submitCaseApiData = { isCorrectClaimantContactAddress: 'YES', claimantProvidePhoneNumber: 'NO', defendant1: { - nameKnown: 'NO', - addressKnown: 'NO', + nameKnown: 'YES', + firstName: 'Test', + lastName: 'John', + addressKnown: 'YES', + addressSameAsPossession: 'NO', + correspondenceAddress: { + AddressLine1: '10 Second Avenue', + AddressLine2: '', + AddressLine3: '', + PostTown: 'London', + County: '', + Country: '', + PostCode: 'W3 7RX', + }, }, - addAnotherDefendant: 'NO', - tenancy_TypeOfTenancyLicence: process.env.TENANCY_TYPE, - tenancy_TenancyLicenceDate: null, - tenancy_TenancyLicenceDocuments: [], - claimDueToRentArrears: 'No', + addAnotherDefendant: 'YES', + additionalDefendants: [ + { + value: { + nameKnown: 'YES', + firstName: 'Jeremiah', + lastName: 'Fisher', + addressKnown: 'YES', + addressSameAsPossession: 'YES', + }, + id: null, + }, + { + value: { + nameKnown: 'YES', + firstName: 'Conrad', + lastName: 'Fisher', + addressKnown: 'YES', + addressSameAsPossession: 'YES', + }, + id: null, + }, + ], + tenancy_TypeOfTenancyLicence: 'INTRODUCTORY_TENANCY', + tenancy_TenancyLicenceDate: '2026-02-10', preActionProtocolCompleted: 'NO', mediationAttempted: 'NO', settlementAttempted: 'NO', - noticeServed: process.env.NOTICE_SERVED, - showRentSectionPage: 'No', - noRentArrears_ShowGroundReasonPage: 'Yes', - noRentArrears_MandatoryGrounds: [], - noRentArrears_DiscretionaryGrounds: ['ALTERNATIVE_ACCOMMODATION_GROUND9'], - assuredNoArrearsReasons_SuitableAlternativeAccomodation: 'accommodation details test', + noticeServed: 'No', + rentDetails_CurrentRent: '100000', + rentDetails_Frequency: 'MONTHLY', + rentDetails_CalculatedDailyCharge: '3285', + rentSectionPaymentFrequency: 'MONTHLY', + rentDetails_FormattedCalculatedDailyCharge: '£32.85', + rentDetails_PerDayCorrect: 'YES', + tenancy_TenancyLicenceDocuments: [], + showIntroductoryDemotedOtherGroundReasonPage: 'Yes', + introGrounds_HasIntroductoryDemotedOtherGroundsForPossession: 'YES', + introGrounds_IntroductoryDemotedOrOtherGrounds: ['ANTI_SOCIAL', 'RENT_ARREARS'], + antiSocialBehaviourGround: 'Antisocial', + showRentArrearsPage: 'Yes', + rentArrears_Total: '200000', + rentArrears_ThirdPartyPayments: 'NO', + arrearsJudgmentWanted: 'NO', claimantNamePossessiveForm: 'Possession Claims Solicitor Org’s', claimantCircumstancesSelect: 'NO', hasDefendantCircumstancesInfo: 'NO', @@ -277,12 +326,18 @@ export const submitCaseApiData = { hasUnderlesseeOrMortgagee: 'NO', wantToUploadDocuments: 'NO', applicationWithClaim: 'NO', - languageUsed: 'ENGLISH_AND_WELSH', + languageUsed: 'ENGLISH', completionNextStep: 'SUBMIT_AND_PAY_NOW', + statementOfTruth: { + completedBy: 'CLAIMANT', + fullNameClaimant: 'fg', + positionClaimant: 'fg', + agreementClaimant: ['BELIEVE_TRUE'], + }, }; }, - //Secure and Flexible Tenancy with Tenancy Licence date unknown for Non-Rent arrears only - get submitCasePayloadSecureFlexibleTenancy() { + //Assured tenancy with Tenancy Licence date unknown for Non-Rent arrears only + get submitCasePayloadAssuredTenancy() { return { legislativeCountry: 'England', claimantType: { @@ -335,47 +390,36 @@ export const submitCaseApiData = { tenancy_TypeOfTenancyLicence: process.env.TENANCY_TYPE, tenancy_TenancyLicenceDate: null, tenancy_TenancyLicenceDocuments: [], - secureOrFlexibleDiscretionaryGrounds: ['DOMESTIC_VIOLENCE'], - secureOrFlexibleMandatoryGrounds: [], - secureOrFlexibleMandatoryGroundsAlt: [], - secureOrFlexibleDiscretionaryGroundsAlt: [], - domesticViolenceGround: 'Domestic violence test', - showBreachOfTenancyTextarea: null, - showReasonsForGroundsPage: 'Yes', - preActionProtocolCompleted: 'YES', + claimDueToRentArrears: 'No', + preActionProtocolCompleted: 'NO', mediationAttempted: 'NO', settlementAttempted: 'NO', noticeServed: process.env.NOTICE_SERVED, + showRentSectionPage: 'No', + noRentArrears_ShowGroundReasonPage: 'Yes', + noRentArrears_MandatoryGrounds: [], + noRentArrears_DiscretionaryGrounds: ['ALTERNATIVE_ACCOMMODATION_GROUND9'], + assuredNoArrearsReasons_SuitableAlternativeAccomodation: 'accommodation details test', claimantNamePossessiveForm: 'Possession Claims Solicitor Org’s', claimantCircumstancesSelect: 'NO', hasDefendantCircumstancesInfo: 'NO', suspensionOfRTB_ShowHousingActsPage: 'No', demotionOfTenancy_ShowHousingActsPage: 'No', suspensionToBuyDemotionOfTenancyPages: 'No', - claimingCostsWanted: 'NO', - hasUnderlesseeOrMortgagee: 'NO', - wantToUploadDocuments: 'NO', - applicationWithClaim: 'NO', - notice_NoticeServiceMethod: 'EMAIL', - notice_NoticeEmailExplanation: null, - notice_NoticeEmailSentDateTime: null, - notice_NoticeDocuments: [], alternativesToPossession: [], + claimingCostsWanted: 'NO', additionalReasonsForPossession: { hasReasons: 'NO', }, + hasUnderlesseeOrMortgagee: 'NO', + wantToUploadDocuments: 'NO', + applicationWithClaim: 'NO', languageUsed: 'ENGLISH_AND_WELSH', completionNextStep: 'SUBMIT_AND_PAY_NOW', - statementOfTruth: { - completedBy: 'CLAIMANT', - fullNameClaimant: 'fg', - positionClaimant: 'fg', - agreementClaimant: ['BELIEVE_TRUE'], - }, }; }, - //Other tenancy with Tenancy Licence date unknown for Non-Rent arrears only - get submitCasePayloadOtherTenancy() { + //Secure and Flexible Tenancy with Tenancy Licence date unknown for Non-Rent arrears only + get submitCasePayloadSecureFlexibleTenancy() { return { legislativeCountry: 'England', claimantType: { @@ -407,7 +451,7 @@ export const submitCaseApiData = { orgNameFound: 'Yes', claimantName: 'Possession Claims Solicitor Org', isClaimantNameCorrect: 'YES', - claimantContactEmail: 'pcs-solicitor-automation@test.com', + claimantContactEmail: 'pcs-solicitor1@test.com', isCorrectClaimantContactEmail: 'YES', orgAddressFound: 'Yes', organisationAddress: { @@ -425,15 +469,17 @@ export const submitCaseApiData = { addressKnown: 'NO', }, addAnotherDefendant: 'NO', - tenancy_TypeOfTenancyLicence: 'OTHER', - tenancy_DetailsOfOtherTypeOfTenancyLicence: 'Other tenancy - short term', + tenancy_TypeOfTenancyLicence: process.env.TENANCY_TYPE, tenancy_TenancyLicenceDate: null, tenancy_TenancyLicenceDocuments: [], - showIntroductoryDemotedOtherGroundReasonPage: 'Yes', - introGrounds_HasIntroductoryDemotedOtherGroundsForPossession: 'YES', - introGrounds_IntroductoryDemotedOrOtherGrounds: ['ANTI_SOCIAL'], - antiSocialBehaviourGround: 'Antisocial behaviour', - preActionProtocolCompleted: 'NO', + secureOrFlexibleDiscretionaryGrounds: ['DOMESTIC_VIOLENCE'], + secureOrFlexibleMandatoryGrounds: [], + secureOrFlexibleMandatoryGroundsAlt: [], + secureOrFlexibleDiscretionaryGroundsAlt: [], + domesticViolenceGround: 'Domestic violence test', + showBreachOfTenancyTextarea: null, + showReasonsForGroundsPage: 'Yes', + preActionProtocolCompleted: 'YES', mediationAttempted: 'NO', settlementAttempted: 'NO', noticeServed: process.env.NOTICE_SERVED, @@ -443,15 +489,19 @@ export const submitCaseApiData = { suspensionOfRTB_ShowHousingActsPage: 'No', demotionOfTenancy_ShowHousingActsPage: 'No', suspensionToBuyDemotionOfTenancyPages: 'No', - alternativesToPossession: [], claimingCostsWanted: 'NO', + hasUnderlesseeOrMortgagee: 'NO', + wantToUploadDocuments: 'NO', + applicationWithClaim: 'NO', + notice_NoticeServiceMethod: 'EMAIL', + notice_NoticeEmailExplanation: null, + notice_NoticeEmailSentDateTime: null, + notice_NoticeDocuments: [], + alternativesToPossession: [], additionalReasonsForPossession: { hasReasons: 'NO', }, - hasUnderlesseeOrMortgagee: 'NO', - wantToUploadDocuments: 'NO', - applicationWithClaim: 'YES', - languageUsed: 'ENGLISH', + languageUsed: 'ENGLISH_AND_WELSH', completionNextStep: 'SUBMIT_AND_PAY_NOW', statementOfTruth: { completedBy: 'CLAIMANT', @@ -461,7 +511,8 @@ export const submitCaseApiData = { }, }; }, - get submitCasePayloadRentNonRent() { + //Other tenancy with Tenancy Licence date unknown for Non-Rent arrears only + get submitCasePayloadOtherTenancy() { return { legislativeCountry: 'England', claimantType: { @@ -507,77 +558,25 @@ export const submitCaseApiData = { isCorrectClaimantContactAddress: 'YES', claimantProvidePhoneNumber: 'NO', defendant1: { - nameKnown: 'YES', - firstName: 'Test', - lastName: 'John', - addressKnown: 'YES', - addressSameAsPossession: 'NO', - correspondenceAddress: { - AddressLine1: '10 Second Avenue', - AddressLine2: '', - AddressLine3: '', - PostTown: 'London', - County: '', - Country: '', - PostCode: 'W3 7RX', - }, + nameKnown: 'NO', + addressKnown: 'NO', }, - addAnotherDefendant: 'YES', - additionalDefendants: [ - { - value: { - nameKnown: 'YES', - firstName: 'Jeremiah', - lastName: 'Fisher', - addressKnown: 'YES', - addressSameAsPossession: 'YES', - }, - id: null, - }, - { - value: { - nameKnown: 'YES', - firstName: 'Conrad', - lastName: 'Fisher', - addressKnown: 'YES', - addressSameAsPossession: 'YES', - }, - id: null, - }, - ], - tenancy_TypeOfTenancyLicence: 'INTRODUCTORY_TENANCY', + addAnotherDefendant: 'NO', + tenancy_TypeOfTenancyLicence: 'OTHER', + tenancy_DetailsOfOtherTypeOfTenancyLicence: 'Other tenancy - short term', tenancy_TenancyLicenceDate: null, - preActionProtocolCompleted: 'NO', - mediationAttempted: 'NO', - settlementAttempted: 'NO', - noticeServed: 'No', - rentDetails_CurrentRent: '100000', - rentDetails_Frequency: 'MONTHLY', - rentDetails_CalculatedDailyCharge: '3285', - rentSectionPaymentFrequency: 'MONTHLY', - rentDetails_FormattedCalculatedDailyCharge: '£32.85', - rentDetails_PerDayCorrect: 'YES', tenancy_TenancyLicenceDocuments: [], showIntroductoryDemotedOtherGroundReasonPage: 'Yes', introGrounds_HasIntroductoryDemotedOtherGroundsForPossession: 'YES', - introGrounds_IntroductoryDemotedOrOtherGrounds: ['ANTI_SOCIAL', 'RENT_ARREARS'], - antiSocialBehaviourGround: 'Antisocial', - showRentArrearsPage: 'Yes', - rentArrears_Total: '200000', - rentArrears_ThirdPartyPayments: 'NO', - arrearsJudgmentWanted: 'NO', + introGrounds_IntroductoryDemotedOrOtherGrounds: ['ANTI_SOCIAL'], + antiSocialBehaviourGround: 'Antisocial behaviour', + preActionProtocolCompleted: 'NO', + mediationAttempted: 'NO', + settlementAttempted: 'NO', + noticeServed: process.env.NOTICE_SERVED, claimantNamePossessiveForm: 'Possession Claims Solicitor Org’s', claimantCircumstancesSelect: 'NO', hasDefendantCircumstancesInfo: 'NO', - rentArrears_StatementDocuments: [ - { - value: { - document_url: `http://dm-store-aat.service.core-compute-aat.internal/documents/${uuidv4()}`, - document_binary_url: `http://dm-store-aat.service.core-compute-aat.internal/documents/${uuidv4()}/binary`, - document_filename: `Rent Arrears ${Date.now()}.docx`, - }, - }, - ], suspensionOfRTB_ShowHousingActsPage: 'No', demotionOfTenancy_ShowHousingActsPage: 'No', suspensionToBuyDemotionOfTenancyPages: 'No', @@ -588,7 +587,7 @@ export const submitCaseApiData = { }, hasUnderlesseeOrMortgagee: 'NO', wantToUploadDocuments: 'NO', - applicationWithClaim: 'NO', + applicationWithClaim: 'YES', languageUsed: 'ENGLISH', completionNextStep: 'SUBMIT_AND_PAY_NOW', statementOfTruth: { diff --git a/src/test/ui/data/page-data/index.ts b/src/test/ui/data/page-data/index.ts index 123623583..302740929 100644 --- a/src/test/ui/data/page-data/index.ts +++ b/src/test/ui/data/page-data/index.ts @@ -14,7 +14,7 @@ export * from './confirmationOfNoticeGiven.page.data'; export * from './noticeDateWhenProvided.page.data'; export * from './noticeDateWhenNotProvided.page.data'; export * from './contactPreferenceEmailOrPost.page.data'; -export * from './rentArrearsDispute.page.data'; +export * from './rentArrears.page.data'; export * from './nonRentArrearsDispute.page.data'; export * from './counterClaim.page.data'; export * from './repaymentsMade.page.data'; diff --git a/src/test/ui/data/page-data/rentArrears.page.data.ts b/src/test/ui/data/page-data/rentArrears.page.data.ts new file mode 100644 index 000000000..c9d55e49b --- /dev/null +++ b/src/test/ui/data/page-data/rentArrears.page.data.ts @@ -0,0 +1,25 @@ +export const rentArrears = { + mainHeader: `Rent arrears`, + saveAndContinueButton: `Save and continue`, + rentAmountTextInput: `1000.00`, + incorrectFormatTextInput: `1000`, + negativeTextInput: `-100.00`, + billionTextInput: `1000000001.00`, + doYouOweThisQuestion: `Do you owe this amount in rent arrears?`, + howMuchDoYouBelieveHiddenTextLabel: `How much do you believe you owe in rent arrears?`, + rentArrearsAreMoneyParagraph: `Rent arrears are money you owe in rent payments.`, + theRentStatementParagraph: `The rent statement will have been included in the pack you received in the post letting you know a claim had been made against you, and is also available to view from ‘View the claim’ on your case overview.`, + yesRadioOption: `Yes`, + noRadioOption: `No`, + imNotSureRadioOption: `I’m not sure`, + saveForLaterButton: `Save for later`, + backLink: `Back`, + thereIsAProblemErrorMessageHeader: `There is a problem`, + errorValidationHeader: `There is a problem`, + enterHowMuchYouBelieveErrorMessage: `Enter the amount you believe you owe in rent arrears`, + selectIfYouOweErrorMessage: `Select if you owe this amount in rent arrears`, + theAmountYouBelieveErrorMessage: `The amount you believe you owe in rent arrears must be £0.00 or above`, + lessThanBillionErrorMessage: `The amount you believe you owe in rent arrears must be less than £1 billion`, + doYouOweThisAmountErrorMessage: `Do you owe this amount in rent arrears?`, + enterAmountInCorrectFormatErrorMessage: `Enter how much you believe you owe in rent arrears, in the correct format (e.g. if you owe £148, please write £148.00)`, +}; diff --git a/src/test/ui/data/page-data/rentArrearsDispute.page.data.ts b/src/test/ui/data/page-data/rentArrearsDispute.page.data.ts deleted file mode 100644 index 1ce132dcf..000000000 --- a/src/test/ui/data/page-data/rentArrearsDispute.page.data.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const rentArrearsDispute = { - mainHeader: `Rent Arrears Dispute(Placeholder)`, - continueButton: `Continue`, -}; diff --git a/src/test/ui/e2eTest/respondToAClaim.spec.ts b/src/test/ui/e2eTest/respondToAClaim.spec.ts index f3a5adfe9..c5ba6f6e9 100644 --- a/src/test/ui/e2eTest/respondToAClaim.spec.ts +++ b/src/test/ui/e2eTest/respondToAClaim.spec.ts @@ -14,7 +14,7 @@ import { defendantNameConfirmation, freeLegalAdvice, nonRentArrearsDispute, - rentArrearsDispute, + rentArrears, repaymentsAgreed, repaymentsMade, startNow, @@ -33,7 +33,7 @@ test.beforeEach(async ({ page }, testInfo) => { } else { process.env.NOTICE_SERVED = 'YES'; } - + // Assign the tenancy type & grounds in the payload const tenancyKey = ['Introductory', 'Demoted', 'Assured', 'Secure', 'Flexible'].find(type => testInfo.title.includes(type) ); @@ -62,6 +62,23 @@ test.beforeEach(async ({ page }, testInfo) => { break; } + // Check notice date provided for back link navigation + if (testInfo.title.includes('NoticeDateProvided - No')) { + process.env.NOTICE_DATE_PROVIDED = 'NO'; + } else if (testInfo.title.includes('NoticeDateProvided - Yes')) { + process.env.NOTICE_DATE_PROVIDED = 'YES'; + } + + //Check if No or Im not sure is selected on NoticeDetails page - for back link navigation + if (testInfo.title.includes('NoticeDetails - No') || testInfo.title.includes('NoticeDetails - Im not sure')) { + process.env.NOTICE_DETAILS_NO_NOTSURE = 'YES'; + } + + // Tenancy start date logic for noDefendantTest + if (testInfo.title.includes('NoticeServed - No')) { + process.env.TENANCY_START_DATE_KNOWN = testInfo.title.includes('noDefendants') ? 'NO' : 'YES'; + } + if (testInfo.title.includes('@noDefendants')) { process.env.CLAIMANT_NAME_OVERRIDDEN = 'YES'; process.env.CORRESPONDENCE_ADDRESS = 'UNKNOWN'; @@ -78,6 +95,7 @@ test.beforeEach(async ({ page }, testInfo) => { await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload }); await performAction('submitCaseAPI', { data: submitCaseApiData.submitCasePayloadOtherTenancy }); } else if (testInfo.title.includes('@rentAndNonRent')) { + process.env.CORRESPONDENCE_ADDRESS = 'KNOWN'; await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload }); await performAction('submitCaseAPI', { data: submitCaseApiData.submitCasePayloadRentNonRent }); } else { @@ -367,8 +385,9 @@ test.describe('Respond to a claim - e2e Journey @nightly', async () => { option: confirmationOfNoticeGiven.yesRadioOption, }); await performAction('enterNoticeDateUnknown'); - await performValidation('mainHeader', rentArrearsDispute.mainHeader); - await performAction('clickButton', rentArrearsDispute.continueButton); + await performAction('rentArrears', { + option: rentArrears.yesRadioOption, + }); // placeholder page, so need to be replaced with custom action when actual page is implemented await performValidation('mainHeader', counterClaim.mainHeader); await performAction('clickButton', counterClaim.saveAndContinueButton); @@ -416,8 +435,10 @@ test.describe('Respond to a claim - e2e Journey @nightly', async () => { month: '2', year: '2020', }); - await performValidation('mainHeader', rentArrearsDispute.mainHeader); - await performAction('clickButton', rentArrearsDispute.continueButton); + await performAction('rentArrears', { + option: rentArrears.noRadioOption, + rentAmount: rentArrears.rentAmountTextInput, + }); }); test('RentArrears - Demoted - NoticeServed - Yes NoticeDateProvided - No - NoticeDetails - No - RentArrearsDispute @regression', async () => { @@ -455,8 +476,9 @@ test.describe('Respond to a claim - e2e Journey @nightly', async () => { await performAction('selectNoticeDetails', { option: confirmationOfNoticeGiven.noRadioOption, }); - await performValidation('mainHeader', rentArrearsDispute.mainHeader); - await performAction('clickButton', rentArrearsDispute.continueButton); + await performAction('rentArrears', { + option: rentArrears.imNotSureRadioOption, + }); // placeholder page, so need to be replaced with custom action when actual page is implemented await performValidation('mainHeader', counterClaim.mainHeader); await performAction('clickButton', counterClaim.saveAndContinueButton); @@ -467,7 +489,7 @@ test.describe('Respond to a claim - e2e Journey @nightly', async () => { await performValidation('mainHeader', repaymentsAgreed.mainHeader); }); - test('England - Demoted - RentArrears - NoticeServed - No NoticeDateProvided - No - RentArrearsDispute @regression', async () => { + test('England - RentArrears - NonRentArrears - NoticeServed - No - RentArrearsDispute @rentNonRent @regression', async () => { await performAction('selectLegalAdvice', freeLegalAdvice.yesRadioOption); await performAction('confirmDefendantDetails', { question: defendantNameConfirmation.mainHeader, @@ -499,8 +521,11 @@ test.describe('Respond to a claim - e2e Journey @nightly', async () => { month: '12', year: '2025', }); - await performValidation('mainHeader', rentArrearsDispute.mainHeader); - await performAction('clickButton', rentArrearsDispute.continueButton); + await performAction('rentArrears', { + option: rentArrears.yesRadioOption, + }); + await performValidation('mainHeader', nonRentArrearsDispute.mainHeader); + await performAction('clickButton', nonRentArrearsDispute.continueButton); // placeholder page, so need to be replaced with custom action when actual page is implemented await performValidation('mainHeader', counterClaim.mainHeader); await performAction('clickButton', counterClaim.saveAndContinueButton); diff --git a/src/test/ui/functional/rentArrears.pft.ts b/src/test/ui/functional/rentArrears.pft.ts new file mode 100644 index 000000000..14179708d --- /dev/null +++ b/src/test/ui/functional/rentArrears.pft.ts @@ -0,0 +1,75 @@ +import { + confirmationOfNoticeGiven, + dashboard, + noticeDateWhenNotProvided, + noticeDateWhenProvided, + rentArrears, + tenancyDateDetails, + tenancyDateUnknown, +} from '../data/page-data'; +import { performAction, performValidation } from '../utils/controller'; + +export async function rentArrearsErrorValidation(): Promise { + // mandatory radio button selection + await performAction('clickButton', rentArrears.saveAndContinueButton); + await performValidation('errorMessage', { + header: rentArrears.thereIsAProblemErrorMessageHeader, + message: rentArrears.selectIfYouOweErrorMessage, + }); + await performAction('clickRadioButton', rentArrears.noRadioOption); + //mandatory input field validation for 'No' radio button selection + await performAction('clickButton', rentArrears.saveAndContinueButton); + await performValidation('errorMessage', { + header: rentArrears.thereIsAProblemErrorMessageHeader, + message: rentArrears.enterHowMuchYouBelieveErrorMessage, + }); + //amount exceeding max allowed value + await performAction('inputText', rentArrears.howMuchDoYouBelieveHiddenTextLabel, rentArrears.billionTextInput); + await performAction('clickButton', rentArrears.saveAndContinueButton); + await performValidation('errorMessage', { + header: rentArrears.thereIsAProblemErrorMessageHeader, + message: rentArrears.lessThanBillionErrorMessage, + }); + //negative value entered + await performAction('inputText', rentArrears.howMuchDoYouBelieveHiddenTextLabel, rentArrears.negativeTextInput); + await performAction('clickButton', rentArrears.saveAndContinueButton); + await performValidation('errorMessage', { + header: rentArrears.thereIsAProblemErrorMessageHeader, + message: rentArrears.theAmountYouBelieveErrorMessage, + }); + //incorrect format + await performAction( + 'inputText', + rentArrears.howMuchDoYouBelieveHiddenTextLabel, + rentArrears.incorrectFormatTextInput + ); + await performAction('clickButton', rentArrears.saveAndContinueButton); + await performValidation('errorMessage', { + header: rentArrears.thereIsAProblemErrorMessageHeader, + message: rentArrears.enterAmountInCorrectFormatErrorMessage, + }); +} + +export async function rentArrearsNavigationTests(): Promise { + if (process.env.NOTICE_DATE_PROVIDED === 'NO') { + await performValidation('pageNavigation', rentArrears.backLink, noticeDateWhenNotProvided.mainHeader); + } + + if (process.env.NOTICE_DETAILS_NO_NOTSURE === 'YES') { + await performValidation('pageNavigation', rentArrears.backLink, confirmationOfNoticeGiven.mainHeader); + } + + if (process.env.NOTICE_DATE_PROVIDED === 'YES') { + await performValidation('pageNavigation', rentArrears.backLink, noticeDateWhenProvided.mainHeader); + } + + if (process.env.TENANCY_START_DATE_KNOWN === 'NO') { + await performValidation('pageNavigation', rentArrears.backLink, tenancyDateUnknown.mainHeader); + } + + if (process.env.TENANCY_START_DATE_KNOWN === 'YES') { + await performValidation('pageNavigation', rentArrears.backLink, tenancyDateDetails.mainHeader); + } + await performAction('clickRadioButton', rentArrears.yesRadioOption); + await performValidation('pageNavigation', rentArrears.saveForLaterButton, dashboard.mainHeader); +} diff --git a/src/test/ui/functional/tenancyDateDetails.pft.ts b/src/test/ui/functional/tenancyDateDetails.pft.ts index 5a93cdcef..e0885d341 100644 --- a/src/test/ui/functional/tenancyDateDetails.pft.ts +++ b/src/test/ui/functional/tenancyDateDetails.pft.ts @@ -1,4 +1,4 @@ -import { dashboard, tenancyDateDetails, tenancyDetails } from '../data/page-data'; +import { dashboard, tenancyDateDetails, tenancyTypeDetails } from '../data/page-data'; import { performAction, performActions, performValidation } from '../utils/controller'; export async function tenancyDateDetailsErrorValidation(): Promise { @@ -50,7 +50,7 @@ export async function tenancyDateDetailsErrorValidation(): Promise { } export async function tenancyDateDetailsNavigationTests(): Promise { - await performValidation('pageNavigation', tenancyDateDetails.backLink, tenancyDetails.mainHeader); + await performValidation('pageNavigation', tenancyDateDetails.backLink, tenancyTypeDetails.mainHeader); await performAction('clickRadioButton', tenancyDateDetails.yesRadioOption); await performValidation('pageNavigation', tenancyDateDetails.saveForLaterButton, dashboard.mainHeader); } diff --git a/src/test/ui/utils/actions/custom-actions/respondToClaim.action.ts b/src/test/ui/utils/actions/custom-actions/respondToClaim.action.ts index 804c6e058..90933043b 100644 --- a/src/test/ui/utils/actions/custom-actions/respondToClaim.action.ts +++ b/src/test/ui/utils/actions/custom-actions/respondToClaim.action.ts @@ -17,12 +17,13 @@ import { noticeDateWhenNotProvided, noticeDateWhenProvided, paymentInterstitial, + rentArrears, repaymentsMade, tenancyDateDetails, tenancyDateUnknown, tenancyTypeDetails, } from '../../../data/page-data'; -import { formatTextToLowercaseSeparatedBySpace } from '../../common/string.utils'; +import { formatCurrency, formatTextToLowercaseSeparatedBySpace } from '../../common/string.utils'; import { performAction, performActions, performValidation } from '../../controller'; import { IAction, actionData, actionRecord } from '../../interfaces'; export let claimantsName: string; @@ -48,6 +49,7 @@ export class RespondToClaimAction implements IAction { ['disputeClaimInterstitial', () => this.disputeClaimInterstitial(fieldName as actionData)], ['selectLandlordRegistered', () => this.selectLandlordRegistered(fieldName as actionData)], ['enterTenancyStartDetailsUnKnown', () => this.enterTenancyStartDetailsUnKnown(fieldName as actionRecord)], + ['rentArrears', () => this.rentArrears(fieldName as actionRecord)], ['tenancyOrContractTypeDetails', () => this.tenancyOrContractTypeDetails(fieldName as actionRecord)], ['selectLandlordLicensed', () => this.selectLandlordLicensed(fieldName as actionRecord)], ]); @@ -276,6 +278,30 @@ export class RespondToClaimAction implements IAction { await performAction('clickButton', tenancyDateUnknown.saveAndContinueButton); } + private async rentArrears(rentArrearsInfo: actionRecord): Promise { + await performValidation('text', { + elementType: 'subHeader', + text: `Amount you owe in rent arrears given by ${submitCaseApiData.submitCasePayload.claimantName}:`, + }); + await performValidation('text', { + elementType: 'paragraph', + text: `When making their claim, ${submitCaseApiData.submitCasePayload.claimantName} had to provide a copy of the rent statement for your property, showing the total rent arrears you owe.`, + }); + const rentArrearsAmount = formatCurrency(`${submitCaseApiData.submitCasePayload.rentArrears_Total}`); + await performValidation('text', { + elementType: 'paragraph', + text: `${rentArrearsAmount}`, + }); + await performAction('clickRadioButton', { + question: rentArrears.doYouOweThisQuestion, + option: rentArrearsInfo.option, + }); + if (rentArrearsInfo.option === 'No') { + await performAction('inputText', rentArrears.howMuchDoYouBelieveHiddenTextLabel, rentArrearsInfo.rentAmount); + } + await performAction('clickButton', rentArrears.saveAndContinueButton); + } + private async tenancyOrContractTypeDetails(tenancyTypeDetailsInfo: actionRecord) { const tenancyType = formatTextToLowercaseSeparatedBySpace(tenancyTypeDetailsInfo.tenancyType as string); const article = /^[aeiou]/i.test(tenancyType) ? 'an' : 'a'; diff --git a/src/test/ui/utils/common/string.utils.ts b/src/test/ui/utils/common/string.utils.ts index 82061ac85..c8ebd081b 100644 --- a/src/test/ui/utils/common/string.utils.ts +++ b/src/test/ui/utils/common/string.utils.ts @@ -6,6 +6,14 @@ export function exactTextWithOptionalWhitespaceRegex(text: string): RegExp { return new RegExp(`^\\s*${escapeForRegex(text)}\\s*$`); } +export function formatCurrency(value: number | string): string { + const num = Number(value); + if (isNaN(num)) { + throw new Error(`Invalid currency value: ${value}`); + } + return `£${(Number(value) / 100).toFixed(2)}`; +} + export function formatTextToLowercaseSeparatedBySpace(value: string): string { return value.toLowerCase().replace(/_/g, ' ').trim(); } diff --git a/src/test/ui/utils/registry/action.registry.ts b/src/test/ui/utils/registry/action.registry.ts index f19fd2ce3..0ab8dc25d 100644 --- a/src/test/ui/utils/registry/action.registry.ts +++ b/src/test/ui/utils/registry/action.registry.ts @@ -62,6 +62,7 @@ export class ActionRegistry { ['tenancyOrContractTypeDetails', new RespondToClaimAction()], ['selectLandlordLicensed', new RespondToClaimAction()], ['selectContactPreferenceEmailOrPost', new RespondToClaimAction()], + ['rentArrears', new RespondToClaimAction()], ]); static getAction(actionName: string): IAction {