From 66991a889b0d18cf9f5f18cff1ab82918e376ab6 Mon Sep 17 00:00:00 2001 From: Timothy Gonella Date: Wed, 1 Apr 2026 12:26:03 +0100 Subject: [PATCH] Updates to normalise the locators for component tests --- .../CommonIntercepts/CommonIntercept.mocks.ts | 27 +- .../AccountEnquiriesAtGlance.cy.ts | 2 +- ...countEnquiriesAtGlanceParentGuardian.cy.ts | 4 +- .../AccountEnquiriesEnforcement.cy.ts | 23 +- .../AccountEnquiriesPaymentTerms.cy.ts | 2 +- .../AccountEnquiryDefendantDetails.cy.ts | 4 +- ...AccountEnquiryFixedPenaltyDetailsTab.cy.ts | 2 +- .../accountEnquiry/AccountEnquiryHeader.cy.ts | 2 +- ...untEnquiryParentOrGuardianDetailsTab.cy.ts | 2 +- .../AccountEnquiryVersionControl.cy.ts | 2 +- ...unt_enquiry_enforcement_status_elements.ts | 45 -- .../AccountEnquiriesAmendPaymentTerms.cy.ts | 2 +- ...ountEnquiriesCannotAmendPaymentTerms.cy.ts | 2 +- .../AccountEnquiriesRequestPaymentCard.cy.ts | 2 +- .../addEnforcementOverride.cy.ts | 2 +- .../add_enforcement_override_elements.ts | 12 - .../SearchAndMatchesCompany.cy.ts | 127 ++--- .../SearchAndMatchesIndividuals.cy.ts | 296 ++++++------ .../SearchAndMatchesMajorCreditors.cy.ts | 115 +++-- .../SearchAndMatchesMinorCreditors.cy.ts | 221 +++++---- .../SearchForAccountFilterByBU.cy.ts | 149 +++--- .../constants/search_account_filter_by_bu.ts | 36 -- .../search_and_matches_company_elements.ts | 50 -- ...search_and_matches_individuals_elements.ts | 66 --- ...ch_and_matches_major_creditors_elements.ts | 90 ---- ...ch_and_matches_minor_creditors_elements.ts | 74 --- .../SearchResultsAccountNumber.cy.ts | 204 ++++---- .../searchResults/SearchResultsCompany.cy.ts | 158 ++++--- .../SearchResultsIndividuals.cy.ts | 446 +++++++++--------- .../SearchResultsMinorCreditors.cy.ts | 291 ++++++------ .../SearchResultsReferenceNumber.cy.ts | 136 +++--- .../search_results_individuals_elements.ts | 66 --- ...search_results_minor_creditors_elements.ts | 54 --- .../addComments/addComments.cy.ts | 195 ++++---- .../constants/add_comments_elements.ts | 20 - .../account.comments.details.locators.ts | 30 +- ...unt.enquiry.defendant-details.locators.ts} | 15 +- ...account.enquiry.fixed-penalty.locators.ts} | 12 +- .../account.enquiry.header.locators.ts} | 14 +- ...quiry.parent-guardian-details.locators.ts} | 11 +- ...account.enquiry.payment-terms.locators.ts} | 12 +- .../account.enquiry.results.locators.ts | 97 +++- ...count.enquiry.version-control.locators.ts} | 10 +- .../account.search.common.locators.ts | 24 + .../account.search.companies.locators.ts | 18 + ...unt.search.filter-by-bu.common.locators.ts | 9 + .../account.search.individuals.locators.ts | 42 ++ ...account.search.major-creditors.locators.ts | 27 ++ ...account.search.minor-creditors.locators.ts | 16 + .../account.search.nav.locators.ts | 6 + 50 files changed, 1579 insertions(+), 1693 deletions(-) delete mode 100644 cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_enforcement_status_elements.ts delete mode 100644 cypress/component/fineAccountEnquiry/amendDefendantEnforcement/constants/add_enforcement_override_elements.ts delete mode 100644 cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_account_filter_by_bu.ts delete mode 100644 cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_company_elements.ts delete mode 100644 cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_individuals_elements.ts delete mode 100644 cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_major_creditors_elements.ts delete mode 100644 cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_minor_creditors_elements.ts delete mode 100644 cypress/component/fineAccountEnquiry/searchResults/constants/search_results_individuals_elements.ts delete mode 100644 cypress/component/fineAccountEnquiry/searchResults/constants/search_results_minor_creditors_elements.ts delete mode 100644 cypress/component/fineAccountEnquiry/viewDefendantAccountSummary/addComments/constants/add_comments_elements.ts rename cypress/{component/fineAccountEnquiry/accountEnquiry/constants/defendant_details_elements.ts => shared/selectors/account-enquiry/account.enquiry.defendant-details.locators.ts} (89%) rename cypress/{component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_fixed_penalty_elements.ts => shared/selectors/account-enquiry/account.enquiry.fixed-penalty.locators.ts} (82%) rename cypress/{component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_header_elements.ts => shared/selectors/account-enquiry/account.enquiry.header.locators.ts} (81%) rename cypress/{component/fineAccountEnquiry/accountEnquiry/constants/defendant_parent_or_guardian_elements.ts => shared/selectors/account-enquiry/account.enquiry.parent-guardian-details.locators.ts} (87%) rename cypress/{component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_payment_terms_elements.ts => shared/selectors/account-enquiry/account.enquiry.payment-terms.locators.ts} (84%) rename cypress/{component/fineAccountEnquiry/accountEnquiry/constants/global_version_control_elements.ts => shared/selectors/account-enquiry/account.enquiry.version-control.locators.ts} (80%) diff --git a/cypress/component/CommonIntercepts/CommonIntercept.mocks.ts b/cypress/component/CommonIntercepts/CommonIntercept.mocks.ts index 465309e1ec..fe39d7c467 100644 --- a/cypress/component/CommonIntercepts/CommonIntercept.mocks.ts +++ b/cypress/component/CommonIntercepts/CommonIntercept.mocks.ts @@ -887,9 +887,8 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Cais am dynnu arian o fudd-daliadau', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, - enforcement_override_result: true, }, { result_id: 'AEOC', @@ -897,7 +896,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Gorchymyn atafaelu enillion - cyfrif dirwy', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -906,7 +905,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Gwarant Mechniaeth - Gyda dyddiad', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -915,7 +914,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Gwarant Mechniaeth - Heb Ddyddiad', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -924,7 +923,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: null, active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -933,7 +932,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Rhybudd o Warant Traddodi', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -942,7 +941,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Gwarant Atafaelu', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -951,7 +950,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: null, active: false, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -960,7 +959,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Gwarant dim mechniaeth', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -969,7 +968,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Rhybudd Cofrestru', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -978,7 +977,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Gwŷs Gorfodi', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -987,7 +986,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Trosglwyddo Gorchymyn Dirwy i Lys yng Nghymru neu Lloegr', active: true, result_type: 'Action', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, { @@ -996,7 +995,7 @@ export const OPAL_FINES_ENF_OVERRIDE_RESULT_REF_DATA_MOCK: IOpalFinesResultsRefD result_title_cy: 'Rhybudd o gamau pellach', active: true, result_type: 'Result', - imposition_creditor: null, + imposition_creditor: '', imposition_allocation_order: null, }, ], diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesAtGlance.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesAtGlance.cy.ts index b06c4ba721..4691eef08a 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesAtGlance.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesAtGlance.cy.ts @@ -1,4 +1,4 @@ -import { ACCOUNT_ENQUIRY_HEADER_ELEMENTS as DOM } from './constants/account_enquiry_header_elements'; +import { ACCOUNT_ENQUIRY_HEADER_ELEMENTS as DOM } from '../../../shared/selectors/account-enquiry/account.enquiry.header.locators'; import { createDefendantHeaderMockWithName, DEFENDANT_HEADER_MOCK } from './mocks/defendant_details_mock'; import { diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesAtGlanceParentGuardian.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesAtGlanceParentGuardian.cy.ts index 45ad3ced28..ed16b74917 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesAtGlanceParentGuardian.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesAtGlanceParentGuardian.cy.ts @@ -1,4 +1,4 @@ -import { ACCOUNT_ENQUIRY_HEADER_ELEMENTS as DOM } from './constants/account_enquiry_header_elements'; +import { ACCOUNT_ENQUIRY_HEADER_ELEMENTS as DOM } from '../../../shared/selectors/account-enquiry/account.enquiry.header.locators'; import { createParentGuardianHeaderMockWithName, DEFENDANT_HEADER_PARENT_GUARDIAN_MOCK, @@ -18,7 +18,7 @@ import { interceptAtAGlance, interceptDefendantHeader } from './intercept/defend import { interceptAuthenticatedUser, interceptUserState } from 'cypress/component/CommonIntercepts/CommonIntercepts'; import { IComponentProperties } from './setup/setupComponent.interface'; import { setupAccountEnquiryComponent } from './setup/SetupComponent'; -import { DEFENDANT_DETAILS } from './constants/defendant_details_elements'; +import { DEFENDANT_DETAILS } from '../../../shared/selectors/account-enquiry/account.enquiry.defendant-details.locators'; import { setLanguagePref } from './Utils/SharedFunctions'; const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesEnforcement.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesEnforcement.cy.ts index 0b7d7c6344..7ca1e2c118 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesEnforcement.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesEnforcement.cy.ts @@ -16,6 +16,17 @@ const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; +const clearEnforcementOverrideResult = ( + enforcementMock: typeof OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_ENFORCEMENT_TAB_REF_DATA_MOCK, +) => { + if (!enforcementMock.enforcement_override) { + throw new Error('Expected enforcement override mock data to be present'); + } + + enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_id = null; + enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_name = null; +}; + describe('Account Enquiry Enforcement Status', () => { beforeEach(() => { interceptAuthenticatedUser(); @@ -226,8 +237,7 @@ describe('Account Enquiry Enforcement Status', () => { let headerMock = structuredClone(createDefendantHeaderMockWithName('Robert', 'Thomson')); headerMock.debtor_type = 'individual'; let enforcementMock = structuredClone(OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_ENFORCEMENT_TAB_REF_DATA_MOCK); - enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_id = null; - enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_name = null; + clearEnforcementOverrideResult(enforcementMock); let newUserState = structuredClone(USER_STATE_MOCK_NO_PERMISSION); newUserState.business_unit_users[0].permissions.push({ permission_id: 7, @@ -1881,8 +1891,7 @@ describe('Account Enquiry Enforcement Status', () => { let headerMock = structuredClone(createDefendantHeaderMockWithName('Robert', 'Thomson')); headerMock.debtor_type = 'individual'; let enforcementMock = structuredClone(OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_ENFORCEMENT_TAB_REF_DATA_MOCK); - enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_id = null; - enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_name = null; + clearEnforcementOverrideResult(enforcementMock); const accountId = headerMock.defendant_account_party_id; interceptAuthenticatedUser(); @@ -2094,8 +2103,7 @@ describe('Account Enquiry Enforcement Status', () => { headerMock.debtor_type = 'Parent/Guardian'; headerMock.parent_guardian_party_id = '1770000001'; let enforcementMock = structuredClone(OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_ENFORCEMENT_TAB_REF_DATA_MOCK); - enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_id = null; - enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_name = null; + clearEnforcementOverrideResult(enforcementMock); const accountId = headerMock.defendant_account_party_id; interceptAuthenticatedUser(); @@ -2319,8 +2327,7 @@ describe('Account Enquiry Enforcement Status', () => { organisation_aliases: [], }; let enforcementMock = structuredClone(OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_ENFORCEMENT_TAB_REF_DATA_MOCK); - enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_id = null; - enforcementMock.enforcement_override.enforcement_override_result.enforcement_override_result_name = null; + clearEnforcementOverrideResult(enforcementMock); const accountId = header.defendant_account_party_id; interceptAuthenticatedUser(); diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesPaymentTerms.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesPaymentTerms.cy.ts index b7a931151c..a3cb419841 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesPaymentTerms.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiriesPaymentTerms.cy.ts @@ -7,7 +7,7 @@ import { } from '../../CommonIntercepts/CommonUserState.mocks'; import { OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_PAYMENT_TERMS_LATEST_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-account-defendant-details-payment-terms-latest.mock'; -import { ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS as PAYMENT_TERMS_TAB } from './constants/account_enquiry_payment_terms_elements'; +import { ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS as PAYMENT_TERMS_TAB } from '../../../shared/selectors/account-enquiry/account.enquiry.payment-terms.locators'; import { interceptDefendantHeader, interceptPaymentTerms } from './intercept/defendantAccountIntercepts'; import { interceptAuthenticatedUser, diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryDefendantDetails.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryDefendantDetails.cy.ts index 8f336c9497..c4c9e9280e 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryDefendantDetails.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryDefendantDetails.cy.ts @@ -1,5 +1,7 @@ import { interceptAuthenticatedUser, interceptUserState } from 'cypress/component/CommonIntercepts/CommonIntercepts'; import { DEFENDANT_HEADER_MOCK } from './mocks/defendant_details_mock'; +import { ACCOUNT_ENQUIRY_HEADER_ELEMENTS as HEADER } from '../../../shared/selectors/account-enquiry/account.enquiry.header.locators'; +import { DEFENDANT_DETAILS } from '../../../shared/selectors/account-enquiry/account.enquiry.defendant-details.locators'; import { USER_STATE_MOCK_NO_PERMISSION, @@ -9,8 +11,6 @@ import { import { interceptDefendantHeader, interceptDefendantDetails } from './intercept/defendantAccountIntercepts'; import { OPAL_FINES_ACCOUNT_DEFENDANT_ACCOUNT_PARTY_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-account-defendant-account-party.mock'; -import { ACCOUNT_ENQUIRY_HEADER_ELEMENTS as HEADER } from './constants/account_enquiry_header_elements'; -import { DEFENDANT_DETAILS } from './constants/defendant_details_elements'; import { IComponentProperties } from './setup/setupComponent.interface'; import { setupAccountEnquiryComponent } from './setup/SetupComponent'; import { setLanguagePref } from './Utils/SharedFunctions'; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryFixedPenaltyDetailsTab.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryFixedPenaltyDetailsTab.cy.ts index f23bee578d..a3f350edfe 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryFixedPenaltyDetailsTab.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryFixedPenaltyDetailsTab.cy.ts @@ -5,7 +5,7 @@ import { USER_STATE_MOCK_PERMISSION_BU77 } from '../../CommonIntercepts/CommonUs import { interceptDefendantHeader, interceptFixedPenaltyDetails } from './intercept/defendantAccountIntercepts'; import { OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_FIXED_PENALTY_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-account-defendant-details-fixed-penalty.mock'; -import { ACCOUNT_ENQUIRY_FIXED_PENALTY_ELEMENTS as FIXED_PENALTY_TAB } from './constants/account_enquiry_fixed_penalty_elements'; +import { ACCOUNT_ENQUIRY_FIXED_PENALTY_ELEMENTS as FIXED_PENALTY_TAB } from '../../../shared/selectors/account-enquiry/account.enquiry.fixed-penalty.locators'; import { setupAccountEnquiryComponent } from './setup/SetupComponent'; import { IComponentProperties } from './setup/setupComponent.interface'; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryHeader.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryHeader.cy.ts index 5bda1fe6eb..0d8fb4d939 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryHeader.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryHeader.cy.ts @@ -5,7 +5,7 @@ import { } from './intercept/defendantAccountIntercepts'; // constants + mocks -import { ACCOUNT_ENQUIRY_HEADER_ELEMENTS as DOM } from './constants/account_enquiry_header_elements'; +import { ACCOUNT_ENQUIRY_HEADER_ELEMENTS as DOM } from '../../../shared/selectors/account-enquiry/account.enquiry.header.locators'; import { DEFENDANT_HEADER_MOCK, DEFENDANT_HEADER_YOUTH_MOCK, diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryParentOrGuardianDetailsTab.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryParentOrGuardianDetailsTab.cy.ts index f46b7b4053..cc14aee628 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryParentOrGuardianDetailsTab.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryParentOrGuardianDetailsTab.cy.ts @@ -14,7 +14,7 @@ import { } from './intercept/defendantAccountIntercepts'; import { OPAL_FINES_ACCOUNT_DEFENDANT_ACCOUNT_PARTY_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-account-defendant-account-party.mock'; import { OPAL_FINES_ACCOUNT_PARENT_GUARDIAN_PARTY_MOCK } from './mocks/parentGuardianDebtor.mock'; -import { DOM_ELEMENTS as DOM } from './constants/defendant_parent_or_guardian_elements'; +import { DOM_ELEMENTS as DOM } from '../../../shared/selectors/account-enquiry/account.enquiry.parent-guardian-details.locators'; import { setupAccountEnquiryComponent } from './setup/SetupComponent'; import { IComponentProperties } from './setup/setupComponent.interface'; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryVersionControl.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryVersionControl.cy.ts index 0c3f73b40d..136807b5c1 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryVersionControl.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/AccountEnquiryVersionControl.cy.ts @@ -1,6 +1,6 @@ import { OPAL_FINES_ACCOUNT_DEFENDANT_AT_A_GLANCE_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-account-defendant-at-a-glance.mock'; import { OPAL_FINES_ACCOUNT_DEFENDANT_ACCOUNT_PARTY_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-account-defendant-account-party.mock'; -import { DOM_ELEMENTS } from './constants/global_version_control_elements'; +import { DOM_ELEMENTS } from '../../../shared/selectors/account-enquiry/account.enquiry.version-control.locators'; import { setupAccountEnquiryComponent } from './setup/SetupComponent'; import { IComponentProperties } from './setup/setupComponent.interface'; import { diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_enforcement_status_elements.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_enforcement_status_elements.ts deleted file mode 100644 index 80fbc9f467..0000000000 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_enforcement_status_elements.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Stable selectors / visible text hooks for the Defendant Details page. - -export const accACCOUNT_ENQUIRY_ENFORCEMENT_STATUS_ELEMENTS = { - headingWithCaption: 'opal-lib-govuk-heading-with-caption', - headingName: 'h1.govuk-heading-l', - pageHeader: 'opal-lib-custom-page-header', - headerLabel: '[opal-lib-custom-account-information-item-label]', - headerValue: '[opal-lib-custom-account-information-item-value]', - - // Buttons - addNoteButton: 'button[id$="addAccountNote"]', - - // Info sections - summaryMetricBar: 'opal-lib-custom-summary-metric-bar', - accountInfo: 'opal-lib-custom-account-information', - parentGuardianTag: '#status', - - // Tabs - tabName: '[subnavitemid="enforcement-tab"] > .moj-sub-navigation__link', - - // Links - enforcementStatusLink: '.govuk-link', - detailsLink: '.govuk-details__summary-text', - - // Table labels - tableTitle: '.govuk-summary-card__title', - collectionOrderStatus: '#enforcementOverviewDetailsCollection_order_statusKey', - daysInDefault: '#enforcementOverviewDetailsDays_in_defaultKey', - enforcementCourt: '#enforcementOverviewDetailsEnforcement_courtKey', - enforcementAction: '#lastEnforcementActionDetailsEnforcement_actionKey', - reason: '#lastEnforcementActionDetailsReasonKey', - lastEnfEnforcer: '#lastEnforcementActionDetailsEnforcerKey', - warrantNumber: '#lastEnforcementActionDetailsWarrant_numberKey', - dateAdded: '#lastEnforcementActionDetailsDate_addedKey', - enforcementOverride: '#enforcementOverrideDetailsEnforcement_overrideKey', - enfOverrideEnforcer: '#enforcementOverrideDetailsEnforcerKey', - localJusticeArea: '#enforcementOverrideDetailsLocal_justice_areaKey', - - //Last enforcement action details section - detailsDaysInDefault: '[id="enforcementActionDetailsDays in defaultKey"]', - detailsReason: '#enforcementActionDetailsReasonKey', - - // Actions column - actionsColumnHeader: '.govuk-grid-column-one-third > .govuk-\\!-margin-bottom-2', -}; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesAmendPaymentTerms.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesAmendPaymentTerms.cy.ts index 80e2967131..9ea3c39e45 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesAmendPaymentTerms.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesAmendPaymentTerms.cy.ts @@ -5,7 +5,7 @@ import { DEFENDANT_HEADER_YOUTH_MOCK, } from '../mocks/defendant_details_mock'; import { OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_PAYMENT_TERMS_LATEST_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-account-defendant-details-payment-terms-latest.mock'; -import { ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS as PAYMENT_TERMS_TAB } from '../constants/account_enquiry_payment_terms_elements'; +import { ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS as PAYMENT_TERMS_TAB } from '../../../../shared/selectors/account-enquiry/account.enquiry.payment-terms.locators'; import { interceptDefendantHeader, interceptPaymentTerms } from '../intercept/defendantAccountIntercepts'; import { interceptAuthenticatedUser, diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesCannotAmendPaymentTerms.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesCannotAmendPaymentTerms.cy.ts index ad89dd8db0..bb41200cde 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesCannotAmendPaymentTerms.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesCannotAmendPaymentTerms.cy.ts @@ -5,7 +5,7 @@ import { } from 'cypress/component/CommonIntercepts/CommonUserState.mocks'; import { OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_PAYMENT_TERMS_LATEST_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-account-defendant-details-payment-terms-latest.mock'; -import { ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS as PAYMENT_TERMS_TAB } from '.././constants/account_enquiry_payment_terms_elements'; +import { ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS as PAYMENT_TERMS_TAB } from '../../../../shared/selectors/account-enquiry/account.enquiry.payment-terms.locators'; import { interceptDefendantHeader, interceptPaymentTerms } from '.././intercept/defendantAccountIntercepts'; import { interceptAuthenticatedUser, diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesRequestPaymentCard.cy.ts b/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesRequestPaymentCard.cy.ts index 121445fabe..4580fa120c 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesRequestPaymentCard.cy.ts +++ b/cypress/component/fineAccountEnquiry/accountEnquiry/paymentTerms/AccountEnquiriesRequestPaymentCard.cy.ts @@ -5,7 +5,7 @@ import { } from 'cypress/component/CommonIntercepts/CommonUserState.mocks'; import { OPAL_FINES_ACCOUNT_DEFENDANT_DETAILS_PAYMENT_TERMS_LATEST_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-account-defendant-details-payment-terms-latest.mock'; -import { ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS as PAYMENT_TERMS_TAB } from '../constants/account_enquiry_payment_terms_elements'; +import { ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS as PAYMENT_TERMS_TAB } from '../../../../shared/selectors/account-enquiry/account.enquiry.payment-terms.locators'; import { interceptDefendantHeader, interceptPaymentTerms } from '../intercept/defendantAccountIntercepts'; import { interceptAuthenticatedUser, diff --git a/cypress/component/fineAccountEnquiry/amendDefendantEnforcement/addEnforcementOverride.cy.ts b/cypress/component/fineAccountEnquiry/amendDefendantEnforcement/addEnforcementOverride.cy.ts index 5c4659f627..ba181f525b 100644 --- a/cypress/component/fineAccountEnquiry/amendDefendantEnforcement/addEnforcementOverride.cy.ts +++ b/cypress/component/fineAccountEnquiry/amendDefendantEnforcement/addEnforcementOverride.cy.ts @@ -1,8 +1,8 @@ import { DOM_ELEMENTS as ENF_OVR } from '../../../shared/selectors/account-enquiry/account.enquiry.enforcement-override-add.locators'; import { ACCOUNT_ENQUIRY_ENFORCEMENT_STATUS_ELEMENTS as ENF } from '../../../shared/selectors/account-enquiry/account.enquiry.enforcement.locators'; +import { DOM_ELEMENTS as VERSION_CONTROL } from '../../../shared/selectors/account-enquiry/account.enquiry.version-control.locators'; import { setupAccountEnquiryComponent } from '../accountEnquiry/setup/SetupComponent'; import { IComponentProperties } from '../accountEnquiry/setup/setupComponent.interface'; -import { DOM_ELEMENTS as VERSION_CONTROL } from '../accountEnquiry/constants/global_version_control_elements'; import { interceptAuthenticatedUser, interceptUserState, diff --git a/cypress/component/fineAccountEnquiry/amendDefendantEnforcement/constants/add_enforcement_override_elements.ts b/cypress/component/fineAccountEnquiry/amendDefendantEnforcement/constants/add_enforcement_override_elements.ts deleted file mode 100644 index f1f51ec529..0000000000 --- a/cypress/component/fineAccountEnquiry/amendDefendantEnforcement/constants/add_enforcement_override_elements.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const DOM_ELEMENTS = { - // Page Elements - title: 'h1.govuk-heading-l', - subtitle: '.govuk-fieldset__legend--m', - enfOverrideDropdown: '[name="fenf_account_enforcement_action-autocomplete"]', - enforcerDropdown: '[name="fenf_account_enforcement_enforcer-autocomplete"]', - localJusticeAreaDropdown: '[name="fenf_account_enforcement_lja-autocomplete"]', - dropdownOptions: '.autocomplete__option', - addOverrideButton: '#submitForm', - cancelLink: '.govuk-link', - errorSummary: '.govuk-error-summary__title', -}; diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesCompany.cy.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesCompany.cy.ts index b45ce152f6..c6c5a03e81 100644 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesCompany.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesCompany.cy.ts @@ -4,7 +4,9 @@ import { FinesSaStore } from '../../../../src/app/flows/fines/fines-sa/stores/fi import { ActivatedRoute, provideRouter } from '@angular/router'; import { of } from 'rxjs'; import { provideHttpClient } from '@angular/common/http'; -import { DOM_ELEMENTS } from './constants/search_and_matches_company_elements'; +import { AccountSearchCommonLocators as CommonLocators } from '../../../shared/selectors/account-search/account.search.common.locators'; +import { AccountSearchCompaniesLocators as CompanyLocators } from '../../../shared/selectors/account-search/account.search.companies.locators'; +import { AccountSearchNavLocators as NavLocators } from '../../../shared/selectors/account-search/account.search.nav.locators'; import { COMPANY_SEARCH_STATE_MOCK } from './mocks/search_and_matches_company_mock'; import { OpalFines } from '@services/fines/opal-fines-service/opal-fines.service'; import { finesSaDefendantAccountsResolver } from 'src/app/flows/fines/fines-sa/routing/resolvers/fines-sa-defendant-accounts/fines-sa-defendant-accounts.resolver'; @@ -72,30 +74,30 @@ describe('Search Account Component - Company', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.companiesTab).click(); - cy.get(DOM_ELEMENTS.app).should('exist'); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search for an account'); - cy.get(DOM_ELEMENTS.tabs).should('exist'); - cy.get(DOM_ELEMENTS.tabsList).should('exist'); - cy.get(DOM_ELEMENTS.individualsTab).should('exist'); - cy.get(DOM_ELEMENTS.companiesTab).should('exist'); - cy.get(DOM_ELEMENTS.minorCreditorsTab).should('exist'); - cy.get(DOM_ELEMENTS.majorCreditorsTab).should('exist'); - cy.get(DOM_ELEMENTS.companiesPanel).should('exist'); - cy.get(DOM_ELEMENTS.companiesHeading).should('contain', 'Companies'); - cy.get(DOM_ELEMENTS.companyNameLabel).should('exist').contains('Company name'); - cy.get(DOM_ELEMENTS.companyNameInput).should('exist'); - cy.get(DOM_ELEMENTS.companyNameExactMatchCheckbox).should('exist').and('not.be.checked'); - cy.get(DOM_ELEMENTS.includeAliasCheckbox).should('exist').and('not.be.checked'); - cy.get(DOM_ELEMENTS.addressLine1Label).should('exist').contains('Address line 1'); - cy.get(DOM_ELEMENTS.addressLine1Input).should('exist'); - cy.get(DOM_ELEMENTS.postcodeLabel).should('exist').and('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.postcodeInput).should('exist'); - cy.get(DOM_ELEMENTS.accountNumberLabel).should('exist').and('contain', 'Account number'); - cy.get(DOM_ELEMENTS.referenceNumberLabel).should('exist').and('contain', 'Reference or case number'); - cy.get(DOM_ELEMENTS.referenceNumberInput).should('exist'); - cy.get(DOM_ELEMENTS.activeAccountsOnlyCheckbox).should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).should('exist').and('contain', 'Search'); + cy.get(NavLocators.companiesTab).click(); + cy.get(CompanyLocators.root).should('exist'); + cy.get(CompanyLocators.pageHeader).should('contain', 'Search for an account'); + cy.get(NavLocators.tabsContainer).should('exist'); + cy.get(NavLocators.tabsList).should('exist'); + cy.get(NavLocators.individualsTab).should('exist'); + cy.get(NavLocators.companiesTab).should('exist'); + cy.get(NavLocators.minorCreditorsTab).should('exist'); + cy.get(NavLocators.majorCreditorsTab).should('exist'); + cy.get(CompanyLocators.companiesPanel).should('exist'); + cy.get(CompanyLocators.companiesHeader).should('contain', 'Companies'); + cy.get(CompanyLocators.companyNameLabel).should('exist').contains('Company name'); + cy.get(CompanyLocators.companyNameInput).should('exist'); + cy.get(CompanyLocators.companyNameExactMatchCheckbox).should('exist').and('not.be.checked'); + cy.get(CompanyLocators.includeAliasesCheckbox).should('exist').and('not.be.checked'); + cy.get(CompanyLocators.addressLine1Label).should('exist').contains('Address line 1'); + cy.get(CompanyLocators.addressLine1Input).should('exist'); + cy.get(CompanyLocators.postCodeLabel).should('exist').and('contain', 'Postcode'); + cy.get(CompanyLocators.postCodeInput).should('exist'); + cy.get(CommonLocators.accountNumberLabel).should('exist').and('contain', 'Account number'); + cy.get(CommonLocators.referenceOrCaseNumberLabel).should('exist').and('contain', 'Reference or case number'); + cy.get(CommonLocators.referenceOrCaseNumberInput).should('exist'); + cy.get(CommonLocators.activeAccountsOnlyCheckbox).should('be.checked'); + cy.get(CommonLocators.searchButton).should('exist').and('contain', 'Search'); }, ); @@ -107,16 +109,16 @@ describe('Search Account Component - Company', () => { companySearchMock.fsa_search_account_companies_search_criteria!.fsa_search_account_companies_company_name = 'Company123!'; - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should( + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should( 'contain', 'Company name must only include letters a to z, numbers 0-9 and certain special characters (hyphens, spaces, apostrophes)', ); - cy.get(DOM_ELEMENTS.companyNameError).should( + cy.get(CompanyLocators.companyNameError).should( 'contain', 'Company name must only include letters a to z, numbers 0-9 and certain special characters (hyphens, spaces, apostrophes)', ); - cy.get(DOM_ELEMENTS.companyNameInput).clear(); + cy.get(CompanyLocators.companyNameInput).clear(); }, ); @@ -128,10 +130,13 @@ describe('Search Account Component - Company', () => { companySearchMock.fsa_search_account_companies_search_criteria!.fsa_search_account_companies_address_line_1 = 'Address123?'; - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Address line 1 must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.addressLine1Error).should('contain', 'Address line 1 must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.addressLine1Input).clear(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Address line 1 must only contain letters or numbers'); + cy.get(CompanyLocators.addressLine1Error).should( + 'contain', + 'Address line 1 must only contain letters or numbers', + ); + cy.get(CompanyLocators.addressLine1Input).clear(); }, ); @@ -143,12 +148,12 @@ describe('Search Account Component - Company', () => { companySearchMock.fsa_search_account_companies_search_criteria!.fsa_search_account_companies_post_code = 'POSTCODE?'; - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Post code must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.postcodeError).should('contain', 'Post code must only contain letters or numbers'); + cy.get(CommonLocators.errorSummary).should('contain', 'Post code must only contain letters or numbers'); + cy.get(CompanyLocators.postCodeError).should('contain', 'Post code must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.postcodeInput).clear(); + cy.get(CompanyLocators.postCodeInput).clear(); }, ); @@ -160,10 +165,10 @@ describe('Search Account Component - Company', () => { companySearchMock.fsa_search_account_companies_search_criteria!.fsa_search_account_companies_company_name = 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijs'; - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Company name must be 50 characters or fewer'); - cy.get(DOM_ELEMENTS.companyNameError).should('contain', 'Company name must be 50 characters or fewer'); - cy.get(DOM_ELEMENTS.companyNameInput).clear(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Company name must be 50 characters or fewer'); + cy.get(CompanyLocators.companyNameError).should('contain', 'Company name must be 50 characters or fewer'); + cy.get(CompanyLocators.companyNameInput).clear(); }, ); @@ -175,10 +180,10 @@ describe('Search Account Component - Company', () => { companySearchMock.fsa_search_account_companies_search_criteria!.fsa_search_account_companies_address_line_1 = 'Address1234Address1234Address12345'; - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Address line 1 must be 30 characters or fewer'); - cy.get(DOM_ELEMENTS.addressLine1Error).should('contain', 'Address line 1 must be 30 characters or fewer'); - cy.get(DOM_ELEMENTS.addressLine1Input).clear(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Address line 1 must be 30 characters or fewer'); + cy.get(CompanyLocators.addressLine1Error).should('contain', 'Address line 1 must be 30 characters or fewer'); + cy.get(CompanyLocators.addressLine1Input).clear(); }, ); @@ -190,10 +195,10 @@ describe('Search Account Component - Company', () => { companySearchMock.fsa_search_account_companies_search_criteria!.fsa_search_account_companies_post_code = 'POSTCODES'; - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Post code must be 8 characters or fewer'); - cy.get(DOM_ELEMENTS.postcodeError).should('contain', 'Post code must be 8 characters or fewer'); - cy.get(DOM_ELEMENTS.postcodeInput).clear(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Post code must be 8 characters or fewer'); + cy.get(CompanyLocators.postCodeError).should('contain', 'Post code must be 8 characters or fewer'); + cy.get(CompanyLocators.postCodeInput).clear(); }, ); @@ -205,10 +210,10 @@ describe('Search Account Component - Company', () => { companySearchMock.fsa_search_account_companies_search_criteria!.fsa_search_account_companies_post_code = 'POSTCODES'; - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Post code must be 8 characters or fewer'); - cy.get(DOM_ELEMENTS.postcodeError).should('contain', 'Post code must be 8 characters or fewer'); - cy.get(DOM_ELEMENTS.postcodeInput).clear(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Post code must be 8 characters or fewer'); + cy.get(CompanyLocators.postCodeError).should('contain', 'Post code must be 8 characters or fewer'); + cy.get(CompanyLocators.postCodeInput).clear(); }, ); @@ -218,11 +223,11 @@ describe('Search Account Component - Company', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.companiesTab).click(); - cy.get(DOM_ELEMENTS.includeAliasCheckbox).check().should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(NavLocators.companiesTab).click(); + cy.get(CompanyLocators.includeAliasesCheckbox).check().should('be.checked'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.companyNameError).should('exist').and('contain', 'Enter company name'); + cy.get(CompanyLocators.companyNameError).should('exist').and('contain', 'Enter company name'); }, ); @@ -232,11 +237,11 @@ describe('Search Account Component - Company', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.companiesTab).click(); - cy.get(DOM_ELEMENTS.companyNameExactMatchCheckbox).check().should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(NavLocators.companiesTab).click(); + cy.get(CompanyLocators.companyNameExactMatchCheckbox).check().should('be.checked'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.companyNameError).should('exist').and('contain', 'Enter company name'); + cy.get(CompanyLocators.companyNameError).should('exist').and('contain', 'Enter company name'); }, ); }); diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesIndividuals.cy.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesIndividuals.cy.ts index 95f90635bc..8a7a341cf0 100644 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesIndividuals.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesIndividuals.cy.ts @@ -4,7 +4,9 @@ import { FinesSaStore } from '../../../../src/app/flows/fines/fines-sa/stores/fi import { ActivatedRoute, provideRouter } from '@angular/router'; import { of } from 'rxjs'; import { provideHttpClient } from '@angular/common/http'; -import { DOM_ELEMENTS } from './constants/search_and_matches_individuals_elements'; +import { AccountSearchCommonLocators as CommonLocators } from '../../../shared/selectors/account-search/account.search.common.locators'; +import { AccountSearchIndividualsLocators as IndividualsLocators } from '../../../shared/selectors/account-search/account.search.individuals.locators'; +import { AccountSearchNavLocators as NavLocators } from '../../../shared/selectors/account-search/account.search.nav.locators'; import { INDIVIDUAL_SEARCH_STATE_MOCK } from './mocks/search_and_matches_individual_mock'; import { OpalFines } from '@services/fines/opal-fines-service/opal-fines.service'; import { finesSaDefendantAccountsResolver } from 'src/app/flows/fines/fines-sa/routing/resolvers/fines-sa-defendant-accounts/fines-sa-defendant-accounts.resolver'; @@ -73,39 +75,39 @@ describe('Search Account Component - Individuals', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.app).should('exist'); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search for an account'); - cy.get(DOM_ELEMENTS.tabs).should('exist'); - cy.get(DOM_ELEMENTS.tabsList).should('exist'); - cy.get(DOM_ELEMENTS.individualsTab).should('exist'); - cy.get(DOM_ELEMENTS.companiesTab).should('exist'); - cy.get(DOM_ELEMENTS.minorCreditorsTab).should('exist'); - cy.get(DOM_ELEMENTS.majorCreditorsTab).should('exist'); - cy.get(DOM_ELEMENTS.individualsPanel).should('exist'); - cy.get(DOM_ELEMENTS.individualsHeading).should('contain', 'Individuals'); - cy.get(DOM_ELEMENTS.businessUnitSummaryList).should('exist'); - cy.get(DOM_ELEMENTS.businessUnitLink).should('exist').contains('Change'); - cy.get(DOM_ELEMENTS.businessUnitLink).click(); - cy.get(DOM_ELEMENTS.accountNumberLabel).should('exist').and('contain', 'Account number'); - cy.get(DOM_ELEMENTS.referenceNumberLabel).should('exist').and('contain', 'Reference or case number'); - cy.get(DOM_ELEMENTS.referenceNumberInput).should('exist'); - cy.get(DOM_ELEMENTS.lastNameLabel).should('exist').and('contain', 'Last name'); - cy.get(DOM_ELEMENTS.lastNameInput).should('exist'); - cy.get(DOM_ELEMENTS.lastNameExactMatchCheckbox).should('exist').and('not.be.checked'); - cy.get(DOM_ELEMENTS.firstNamesLabel).should('exist').and('contain', 'First names'); - cy.get(DOM_ELEMENTS.firstNamesInput).should('exist'); - cy.get(DOM_ELEMENTS.firstNamesExactMatchCheckbox).should('exist').and('not.be.checked'); - cy.get(DOM_ELEMENTS.includeAliasesCheckbox).should('exist').and('not.be.checked'); - cy.get(DOM_ELEMENTS.dobLabel).should('exist').and('contain', 'Date of birth'); - cy.get(DOM_ELEMENTS.dobInput).should('exist'); - cy.get(DOM_ELEMENTS.niNumberLabel).should('exist').and('contain', 'National Insurance number'); - cy.get(DOM_ELEMENTS.niNumberInput).should('exist'); - cy.get(DOM_ELEMENTS.addressLine1Label).should('exist').and('contain', 'Address line 1'); - cy.get(DOM_ELEMENTS.addressLine1Input).should('exist'); - cy.get(DOM_ELEMENTS.postcodeLabel).should('exist').and('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.postcodeInput).should('exist'); - cy.get(DOM_ELEMENTS.activeAccountsOnlyCheckbox).should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).should('exist').and('contain', 'Search'); + cy.get(IndividualsLocators.root).should('exist'); + cy.get(CommonLocators.pageHeader).should('contain', 'Search for an account'); + cy.get(NavLocators.tabsContainer).should('exist'); + cy.get(NavLocators.tabsList).should('exist'); + cy.get(NavLocators.individualsTab).should('exist'); + cy.get(NavLocators.companiesTab).should('exist'); + cy.get(NavLocators.minorCreditorsTab).should('exist'); + cy.get(NavLocators.majorCreditorsTab).should('exist'); + cy.get(IndividualsLocators.individualsPanel).should('exist'); + cy.get(IndividualsLocators.individualsHeader).should('contain', 'Individuals'); + cy.get(CommonLocators.businessUnitSummaryList).should('exist'); + cy.get(CommonLocators.businessUnitFilterChangeLink).should('exist').contains('Change'); + cy.get(CommonLocators.businessUnitFilterChangeLink).click(); + cy.get(CommonLocators.accountNumberLabel).should('exist').and('contain', 'Account number'); + cy.get(CommonLocators.referenceOrCaseNumberLabel).should('exist').and('contain', 'Reference or case number'); + cy.get(CommonLocators.referenceOrCaseNumberInput).should('exist'); + cy.get(IndividualsLocators.lastNameLabel).should('exist').and('contain', 'Last name'); + cy.get(IndividualsLocators.lastNameInput).should('exist'); + cy.get(IndividualsLocators.lastNameExactMatchCheckbox).should('exist').and('not.be.checked'); + cy.get(IndividualsLocators.firstNamesLabel).should('exist').and('contain', 'First names'); + cy.get(IndividualsLocators.firstNameInput).should('exist'); + cy.get(IndividualsLocators.firstNamesExactMatchCheckbox).should('exist').and('not.be.checked'); + cy.get(IndividualsLocators.includeAliasesCheckbox).should('exist').and('not.be.checked'); + cy.get(IndividualsLocators.dobLabel).should('exist').and('contain', 'Date of birth'); + cy.get(IndividualsLocators.dobInput).should('exist'); + cy.get(IndividualsLocators.niNumberLabel).should('exist').and('contain', 'National Insurance number'); + cy.get(IndividualsLocators.niNumberInput).should('exist'); + cy.get(IndividualsLocators.addressLine1Label).should('exist').and('contain', 'Address line 1'); + cy.get(IndividualsLocators.addressLine1Input).should('exist'); + cy.get(IndividualsLocators.postcodeLabel).should('exist').and('contain', 'Postcode'); + cy.get(IndividualsLocators.postcodeInput).should('exist'); + cy.get(CommonLocators.activeAccountsOnlyCheckbox).should('be.checked'); + cy.get(CommonLocators.searchButton).should('exist').and('contain', 'Search'); }, ); @@ -116,19 +118,19 @@ describe('Search Account Component - Individuals', () => { setupComponent(null); individualSearchMock.fsa_search_account_number = '123$%^78'; - cy.get(DOM_ELEMENTS.accountNumberInput).should('have.value', '123$%^78'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.accountNumberInput).should('have.value', '123$%^78'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search for an account'); + cy.get(CommonLocators.pageHeader).should('contain', 'Search for an account'); - cy.get(DOM_ELEMENTS.errorSummary) + cy.get(CommonLocators.errorSummary) .should('exist') .and('contain', 'Account number must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.accountNumberError) + cy.get(CommonLocators.accountNumberError) .should('exist') .and('contain', 'Account number must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.accountNumberInput).clear(); + cy.get(CommonLocators.accountNumberInput).clear(); }, ); @@ -139,17 +141,17 @@ describe('Search Account Component - Individuals', () => { setupComponent(null); individualSearchMock.fsa_search_account_number = '1234567'; - cy.get(DOM_ELEMENTS.accountNumberInput).should('have.value', '1234567'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.accountNumberInput).should('have.value', '1234567'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary) + cy.get(CommonLocators.errorSummary) .should('exist') .and('contain', 'Enter account number in the correct format such as 12345678 or 12345678A'); - cy.get(DOM_ELEMENTS.accountNumberError) + cy.get(CommonLocators.accountNumberError) .should('exist') .and('contain', 'Enter account number in the correct format such as 12345678 or 12345678A'); - cy.get(DOM_ELEMENTS.accountNumberInput).clear(); + cy.get(CommonLocators.accountNumberInput).clear(); }, ); it( @@ -159,17 +161,17 @@ describe('Search Account Component - Individuals', () => { setupComponent(null); individualSearchMock.fsa_search_account_reference_case_number = 'REF@#$456'; - cy.get(DOM_ELEMENTS.referenceNumberInput).should('have.value', 'REF@#$456'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.referenceOrCaseNumberInput).should('have.value', 'REF@#$456'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary) + cy.get(CommonLocators.errorSummary) .should('exist') .and('contain', 'Reference or case number must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.referenceNumberError) + cy.get(CommonLocators.referenceOrCaseNumberError) .should('exist') .and('contain', 'Reference or case number must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.referenceNumberInput).clear(); + cy.get(CommonLocators.referenceOrCaseNumberInput).clear(); }, ); it( @@ -180,13 +182,13 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_last_name = 'Smith123'; - cy.get(DOM_ELEMENTS.lastNameInput).should('have.value', 'Smith123'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.lastNameInput).should('have.value', 'Smith123'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist').and('contain', 'Last name must only contain letters'); - cy.get(DOM_ELEMENTS.lastNameError).should('exist').and('contain', 'Last name must only contain letters'); + cy.get(CommonLocators.errorSummary).should('exist').and('contain', 'Last name must only contain letters'); + cy.get(IndividualsLocators.lastNameError).should('exist').and('contain', 'Last name must only contain letters'); - cy.get(DOM_ELEMENTS.lastNameInput).clear(); + cy.get(IndividualsLocators.lastNameInput).clear(); }, ); it( @@ -197,13 +199,15 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_first_names = 'John123'; - cy.get(DOM_ELEMENTS.firstNamesInput).should('have.value', 'John123'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.firstNameInput).should('have.value', 'John123'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist').and('contain', 'First names must only contain letters'); - cy.get(DOM_ELEMENTS.firstNamesError).should('exist').and('contain', 'First names must only contain letters'); + cy.get(CommonLocators.errorSummary).should('exist').and('contain', 'First names must only contain letters'); + cy.get(IndividualsLocators.firstNamesError) + .should('exist') + .and('contain', 'First names must only contain letters'); - cy.get(DOM_ELEMENTS.firstNamesInput).clear(); + cy.get(IndividualsLocators.firstNameInput).clear(); }, ); it( @@ -214,13 +218,13 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_date_of_birth = '15/AB/2020'; - cy.get(DOM_ELEMENTS.dobInput).should('have.value', '15/AB/2020'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.dobInput).should('have.value', '15/AB/2020'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist').and('contain', 'Date must be in the format DD/MM/YYYY'); - cy.get(DOM_ELEMENTS.dobError).should('exist').and('contain', 'Date must be in the format DD/MM/YYYY'); + cy.get(CommonLocators.errorSummary).should('exist').and('contain', 'Date must be in the format DD/MM/YYYY'); + cy.get(IndividualsLocators.dobError).should('exist').and('contain', 'Date must be in the format DD/MM/YYYY'); - cy.get(DOM_ELEMENTS.dobInput).clear(); + cy.get(IndividualsLocators.dobInput).clear(); }, ); it( @@ -231,13 +235,13 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_date_of_birth = '15/05/2030'; - cy.get(DOM_ELEMENTS.dobInput).should('have.value', '15/05/2030'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.dobInput).should('have.value', '15/05/2030'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist').and('contain', 'Date of birth must be in the past'); - cy.get(DOM_ELEMENTS.dobError).should('exist').and('contain', 'Date of birth must be in the past'); + cy.get(CommonLocators.errorSummary).should('exist').and('contain', 'Date of birth must be in the past'); + cy.get(IndividualsLocators.dobError).should('exist').and('contain', 'Date of birth must be in the past'); - cy.get(DOM_ELEMENTS.dobInput).clear(); + cy.get(IndividualsLocators.dobInput).clear(); }, ); it( @@ -248,13 +252,13 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_date_of_birth = '5/1/1980'; - cy.get(DOM_ELEMENTS.dobInput).should('have.value', '5/1/1980'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.dobInput).should('have.value', '5/1/1980'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist').and('contain', 'Date must be in the format DD/MM/YYYY'); - cy.get(DOM_ELEMENTS.dobError).should('exist').and('contain', 'Date must be in the format DD/MM/YYYY'); + cy.get(CommonLocators.errorSummary).should('exist').and('contain', 'Date must be in the format DD/MM/YYYY'); + cy.get(IndividualsLocators.dobError).should('exist').and('contain', 'Date must be in the format DD/MM/YYYY'); - cy.get(DOM_ELEMENTS.dobInput).clear(); + cy.get(IndividualsLocators.dobInput).clear(); }, ); @@ -264,12 +268,12 @@ describe('Search Account Component - Individuals', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.dobDatePickerToggle).click(); - cy.get(DOM_ELEMENTS.dobDatePickerPrevMonth).click(); - cy.get(DOM_ELEMENTS.dobDatePicker).contains(/^1$/).click(); + cy.get(IndividualsLocators.dobOpenButton).click(); + cy.get(IndividualsLocators.dobPreviousMonthButton).click(); + cy.get(IndividualsLocators.dobCalendarDialog).contains(/^1$/).click(); const expectedDate = getFirstDayOfPreviousMonth(); - cy.get(DOM_ELEMENTS.dobInput).should('have.value', expectedDate); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.dobInput).should('have.value', expectedDate); + cy.get(CommonLocators.searchButton).click(); }, ); @@ -281,17 +285,17 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_national_insurance_number = 'AB123$%^C'; - cy.get(DOM_ELEMENTS.niNumberInput).should('have.value', 'AB123$%^C'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.niNumberInput).should('have.value', 'AB123$%^C'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary) + cy.get(CommonLocators.errorSummary) .should('exist') .and('contain', 'National Insurance number must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.niNumberError) + cy.get(IndividualsLocators.niNumberError) .should('exist') .and('contain', 'National Insurance number must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.niNumberInput).clear(); + cy.get(IndividualsLocators.niNumberInput).clear(); }, ); it( @@ -302,17 +306,17 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_address_line_1 = '123 Test St. ®©™'; - cy.get(DOM_ELEMENTS.addressLine1Input).should('have.value', '123 Test St. ®©™'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.addressLine1Input).should('have.value', '123 Test St. ®©™'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary) + cy.get(CommonLocators.errorSummary) .should('exist') .and('contain', 'Address line 1 must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.addressLine1Error) + cy.get(IndividualsLocators.addressLine1Error) .should('exist') .and('contain', 'Address line 1 must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.addressLine1Input).clear(); + cy.get(IndividualsLocators.addressLine1Input).clear(); }, ); it( @@ -323,15 +327,17 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_post_code = 'SW1A @#!'; - cy.get(DOM_ELEMENTS.postcodeInput).should('have.value', 'SW1A @#!'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.postcodeInput).should('have.value', 'SW1A @#!'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist').and('contain', 'Postcode must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.postcodeError) + cy.get(CommonLocators.errorSummary) + .should('exist') + .and('contain', 'Postcode must only contain letters or numbers'); + cy.get(IndividualsLocators.postcodeError) .should('exist') .and('contain', 'Postcode must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.postcodeInput).clear(); + cy.get(IndividualsLocators.postcodeInput).clear(); }, ); @@ -342,11 +348,11 @@ describe('Search Account Component - Individuals', () => { setupComponent(null); individualSearchMock.fsa_search_account_number = '1234567890'; // 10 characters (exceeds 9) - cy.get(DOM_ELEMENTS.accountNumberInput).should('have.value', '1234567890'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.accountNumberInput).should('have.value', '1234567890'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.accountNumberError) + cy.get(CommonLocators.errorSummary).should('exist'); + cy.get(CommonLocators.accountNumberError) .should('exist') .and('contain', 'Account number must be 9 characters or fewer'); }, @@ -360,14 +366,14 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_reference_case_number = 'This reference number is way too long and exceeds thirty characters'; - cy.get(DOM_ELEMENTS.referenceNumberInput).should( + cy.get(CommonLocators.referenceOrCaseNumberInput).should( 'have.value', 'This reference number is way too long and exceeds thirty characters', ); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.referenceNumberError) + cy.get(CommonLocators.errorSummary).should('exist'); + cy.get(CommonLocators.referenceOrCaseNumberError) .should('exist') .and('contain', 'Reference or case number must be 30 characters or fewer'); }, @@ -381,11 +387,13 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_last_name = 'ThisLastNameIsTooLongAndExceedsThirtyCharacters'; - cy.get(DOM_ELEMENTS.lastNameInput).should('have.value', 'ThisLastNameIsTooLongAndExceedsThirtyCharacters'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.lastNameInput).should('have.value', 'ThisLastNameIsTooLongAndExceedsThirtyCharacters'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.lastNameError).should('exist').and('contain', 'Last name must be 30 characters or fewer'); + cy.get(CommonLocators.errorSummary).should('exist'); + cy.get(IndividualsLocators.lastNameError) + .should('exist') + .and('contain', 'Last name must be 30 characters or fewer'); }, ); @@ -397,11 +405,13 @@ describe('Search Account Component - Individuals', () => { 'ThisFirstNameIsTooLongAndExceedsTwentyChars'; setupComponent(null); - cy.get(DOM_ELEMENTS.firstNamesInput).should('have.value', 'ThisFirstNameIsTooLongAndExceedsTwentyChars'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.firstNameInput).should('have.value', 'ThisFirstNameIsTooLongAndExceedsTwentyChars'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.firstNamesError).should('exist').and('contain', 'First names must be 20 characters or fewer'); + cy.get(CommonLocators.errorSummary).should('exist'); + cy.get(IndividualsLocators.firstNamesError) + .should('exist') + .and('contain', 'First names must be 20 characters or fewer'); }, ); @@ -413,11 +423,11 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_national_insurance_number = 'AB123456CD'; - cy.get(DOM_ELEMENTS.niNumberInput).should('have.value', 'AB123456CD'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.niNumberInput).should('have.value', 'AB123456CD'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.niNumberError) + cy.get(CommonLocators.errorSummary).should('exist'); + cy.get(IndividualsLocators.niNumberError) .should('exist') .and('contain', 'National Insurance number must be 9 characters or fewer'); }, @@ -431,14 +441,14 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_address_line_1 = 'This address line is too long and exceeds thirty characters'; - cy.get(DOM_ELEMENTS.addressLine1Input).should( + cy.get(IndividualsLocators.addressLine1Input).should( 'have.value', 'This address line is too long and exceeds thirty characters', ); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.addressLine1Error) + cy.get(CommonLocators.errorSummary).should('exist'); + cy.get(IndividualsLocators.addressLine1Error) .should('exist') .and('contain', 'Address line 1 must be 30 characters or fewer'); }, @@ -452,11 +462,13 @@ describe('Search Account Component - Individuals', () => { individualSearchMock.fsa_search_account_individuals_search_criteria!.fsa_search_account_individuals_post_code = 'AB12 3CDEF'; // 9 characters (exceeds 8) - cy.get(DOM_ELEMENTS.postcodeInput).should('have.value', 'AB12 3CDEF'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.postcodeInput).should('have.value', 'AB12 3CDEF'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.postcodeError).should('exist').and('contain', 'Postcode must be 8 characters or fewer'); + cy.get(CommonLocators.errorSummary).should('exist'); + cy.get(IndividualsLocators.postcodeError) + .should('exist') + .and('contain', 'Postcode must be 8 characters or fewer'); }, ); @@ -466,12 +478,12 @@ describe('Search Account Component - Individuals', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.firstNamesInput).type('John', { delay: 0 }); - cy.get(DOM_ELEMENTS.lastNameInput).should('have.value', ''); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.firstNameInput).type('John', { delay: 0 }); + cy.get(IndividualsLocators.lastNameInput).should('have.value', ''); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.lastNameError).should('exist').and('contain', 'Enter last name'); + cy.get(CommonLocators.errorSummary).should('exist'); + cy.get(IndividualsLocators.lastNameError).should('exist').and('contain', 'Enter last name'); }, ); @@ -484,12 +496,12 @@ describe('Search Account Component - Individuals', () => { cy.stub(win.console, 'info').as('consoleLog'); }); - cy.get(DOM_ELEMENTS.dobInput).focus().type('15/05/2020', { delay: 0 }); - cy.get(DOM_ELEMENTS.lastNameInput).should('have.value', ''); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.dobInput).focus().type('15/05/2020', { delay: 0 }); + cy.get(IndividualsLocators.lastNameInput).should('have.value', ''); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.lastNameError).should('exist').and('contain', 'Enter last name'); + cy.get(CommonLocators.errorSummary).should('exist'); + cy.get(IndividualsLocators.lastNameError).should('exist').and('contain', 'Enter last name'); cy.get('@consoleLog').should('have.not.been.calledOnce'); }, @@ -501,10 +513,10 @@ describe('Search Account Component - Individuals', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.includeAliasesCheckbox).check().should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.includeAliasesCheckbox).check().should('be.checked'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.lastNameError).should('exist').and('contain', 'Enter last name'); + cy.get(IndividualsLocators.lastNameError).should('exist').and('contain', 'Enter last name'); }, ); @@ -514,10 +526,10 @@ describe('Search Account Component - Individuals', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.lastNameExactMatchCheckbox).check().should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.lastNameExactMatchCheckbox).check().should('be.checked'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.lastNameError).should('exist').and('contain', 'Enter last name'); + cy.get(IndividualsLocators.lastNameError).should('exist').and('contain', 'Enter last name'); }, ); it( @@ -526,10 +538,10 @@ describe('Search Account Component - Individuals', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.firstNamesExactMatchCheckbox).check().should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(IndividualsLocators.firstNamesExactMatchCheckbox).check().should('be.checked'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.firstNamesError).should('exist').and('contain', 'Enter first name'); + cy.get(IndividualsLocators.firstNamesError).should('exist').and('contain', 'Enter first name'); }, ); }); diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesMajorCreditors.cy.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesMajorCreditors.cy.ts index dd5fa2dbd1..d795f31849 100644 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesMajorCreditors.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesMajorCreditors.cy.ts @@ -3,7 +3,9 @@ import { FinesSaSearchAccountComponent } from '../../../../src/app/flows/fines/f import { FinesSaStore } from '../../../../src/app/flows/fines/fines-sa/stores/fines-sa.store'; import { ActivatedRoute, Router, NavigationExtras } from '@angular/router'; import { provideHttpClient } from '@angular/common/http'; -import { DOM_ELEMENTS } from './constants/search_and_matches_major_creditors_elements'; +import { AccountSearchCommonLocators as CommonLocators } from '../../../shared/selectors/account-search/account.search.common.locators'; +import { AccountSearchMajorCreditorsLocators as MajorCreditorsLocators } from '../../../shared/selectors/account-search/account.search.major-creditors.locators'; +import { AccountSearchNavLocators as NavLocators } from '../../../shared/selectors/account-search/account.search.nav.locators'; import { MAJOR_CREDITORS_SEARCH_STATE_MOCK } from './mocks/search_and_matches_major_creditors_mock'; import { OpalFines } from '../../../../src/app/flows/fines/services/opal-fines-service/opal-fines.service'; import { OPAL_FINES_BUSINESS_UNIT_REF_DATA_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-business-unit-ref-data.mock'; @@ -11,6 +13,8 @@ import { OPAL_FINES_MAJOR_CREDITOR_REF_DATA_MOCK } from '@services/fines/opal-fi import { BehaviorSubject } from 'rxjs'; const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; +const MajorAutocompleteLocators = MajorCreditorsLocators.autocomplete; +const MajorRequirementLocators = MajorCreditorsLocators.businessUnitRequirement; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; @@ -78,26 +82,26 @@ describe('Search Account Component - Major Creditors', () => { () => { setupComponent(); - cy.get(DOM_ELEMENTS.majorCreditorsTab).click(); - cy.get(DOM_ELEMENTS.app).should('exist'); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search for an account'); - cy.get(DOM_ELEMENTS.tabs).should('exist'); - cy.get(DOM_ELEMENTS.tabsList).should('exist'); - cy.get(DOM_ELEMENTS.individualsTab).should('exist'); - cy.get(DOM_ELEMENTS.companiesTab).should('exist'); - cy.get(DOM_ELEMENTS.minorCreditorsTab).should('exist'); - cy.get(DOM_ELEMENTS.majorCreditorsTab).should('exist'); - cy.get(DOM_ELEMENTS.majorCreditorsPanel).should('exist'); - cy.get(DOM_ELEMENTS.majorCreditorsHeading).should('exist').contains('Major creditors'); - cy.get(DOM_ELEMENTS.majorCreditorsHelpText).should('exist').contains('Search using creditor name or code'); - cy.get(DOM_ELEMENTS.majorCreditorDropdown).should('exist'); - cy.get(DOM_ELEMENTS.accountNumberLabel).should('exist').and('contain', 'Account number'); - cy.get(DOM_ELEMENTS.referenceNumberLabel).should('exist').and('contain', 'Reference or case number'); - cy.get(DOM_ELEMENTS.referenceNumberInput).should('exist'); - cy.get(DOM_ELEMENTS.activeAccountsOnlyCheckbox).should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).should('exist').and('contain', 'Search'); - - cy.get('a').contains('Change').click(); + cy.get(NavLocators.majorCreditorsTab).click(); + cy.get(CommonLocators.root).should('exist'); + cy.get(CommonLocators.pageHeader).should('contain', 'Search for an account'); + cy.get(NavLocators.tabsContainer).should('exist'); + cy.get(NavLocators.tabsList).should('exist'); + cy.get(NavLocators.individualsTab).should('exist'); + cy.get(NavLocators.companiesTab).should('exist'); + cy.get(NavLocators.minorCreditorsTab).should('exist'); + cy.get(NavLocators.majorCreditorsTab).should('exist'); + cy.get(MajorCreditorsLocators.panel.root).should('exist'); + cy.get(MajorCreditorsLocators.panel.heading).should('exist').contains('Major creditors'); + cy.get(MajorAutocompleteLocators.hint).should('exist').contains('Search using creditor name or code'); + cy.get(MajorAutocompleteLocators.input).should('exist'); + cy.get(CommonLocators.accountNumberLabel).should('exist').and('contain', 'Account number'); + cy.get(CommonLocators.referenceOrCaseNumberLabel).should('exist').and('contain', 'Reference or case number'); + cy.get(CommonLocators.referenceOrCaseNumberInput).should('exist'); + cy.get(CommonLocators.activeAccountsOnlyCheckbox).should('be.checked'); + cy.get(CommonLocators.searchButton).should('exist').and('contain', 'Search'); + + cy.get(CommonLocators.businessUnitFilterChangeLink).click(); cy.get('@routerNavigate').should('have.been.calledWithMatch', ['filter-business-units']); }, ); @@ -108,17 +112,14 @@ describe('Search Account Component - Major Creditors', () => { () => { setupComponent(); - cy.get(DOM_ELEMENTS.majorCreditorsHeading).should('exist').contains('Major creditors'); - cy.get(DOM_ELEMENTS.majorCreditorsHelpText).should('exist').contains('Search using creditor name or code'); - cy.get(DOM_ELEMENTS.majorCreditorDropdown).click(); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete).find('li').should('have.length', 4); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete) - .find('li') - .eq(0) - .should('contain', 'Abellio Greater Anglia (AGAL)'); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete).find('li').eq(1).should('contain', 'Aberdeen JP Court (ABJP)'); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete).find('li').eq(2).should('contain', 'Aldi Stores Ltd (ALDI)'); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete).find('li').eq(3).should('contain', 'Arriva Rail North (ARVA)'); + cy.get(MajorCreditorsLocators.panel.heading).should('exist').contains('Major creditors'); + cy.get(MajorAutocompleteLocators.hint).should('exist').contains('Search using creditor name or code'); + cy.get(MajorAutocompleteLocators.input).click(); + cy.get(MajorAutocompleteLocators.listbox).find('li').should('have.length', 4); + cy.get(MajorAutocompleteLocators.listbox).find('li').eq(0).should('contain', 'Abellio Greater Anglia (AGAL)'); + cy.get(MajorAutocompleteLocators.listbox).find('li').eq(1).should('contain', 'Aberdeen JP Court (ABJP)'); + cy.get(MajorAutocompleteLocators.listbox).find('li').eq(2).should('contain', 'Aldi Stores Ltd (ALDI)'); + cy.get(MajorAutocompleteLocators.listbox).find('li').eq(3).should('contain', 'Arriva Rail North (ARVA)'); }, ); @@ -128,12 +129,9 @@ describe('Search Account Component - Major Creditors', () => { () => { setupComponent(); - cy.get(DOM_ELEMENTS.majorCreditorDropdown).click().type('ab'); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete) - .find('li') - .eq(0) - .should('contain', 'Abellio Greater Anglia (AGAL)'); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete).find('li').eq(1).should('contain', 'Aberdeen JP Court (ABJP)'); + cy.get(MajorAutocompleteLocators.input).click().type('ab'); + cy.get(MajorAutocompleteLocators.listbox).find('li').eq(0).should('contain', 'Abellio Greater Anglia (AGAL)'); + cy.get(MajorAutocompleteLocators.listbox).find('li').eq(1).should('contain', 'Aberdeen JP Court (ABJP)'); }, ); @@ -143,11 +141,11 @@ describe('Search Account Component - Major Creditors', () => { () => { setupComponent(); - cy.get(DOM_ELEMENTS.majorCreditorDropdown).click(); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete).find('li').contains('Arriva Rail North').click(); - cy.get(DOM_ELEMENTS.majorCreditorDropdown).should('have.value', 'Arriva Rail North (ARVA)'); + cy.get(MajorAutocompleteLocators.input).click(); + cy.get(MajorAutocompleteLocators.listbox).find('li').contains('Arriva Rail North').click(); + cy.get(MajorAutocompleteLocators.input).should('have.value', 'Arriva Rail North (ARVA)'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.searchButton).click(); const accountId = OPAL_FINES_MAJOR_CREDITOR_REF_DATA_MOCK.refData[3].major_creditor_id; //3858 //The expected screen has not yet been developed, change URL once it has. cy.get('@urlTree').should('have.been.calledWithMatch', [`fines/account/${accountId}/defendant`]); @@ -166,12 +164,12 @@ describe('Search Account Component - Major Creditors', () => { majorCreditorsSearchMock.fsa_search_account_number = '12345678'; majorCreditorsSearchMock.fsa_search_account_reference_case_number = 'REF123'; - cy.get(DOM_ELEMENTS.majorCreditorDropdown).click(); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete).find('li').contains('Abellio Greater Anglia').click(); - cy.get(DOM_ELEMENTS.majorCreditorDropdown).should('have.value', 'Abellio Greater Anglia (AGAL)'); - cy.get(DOM_ELEMENTS.minorCreditorsTab).click(); - cy.get(DOM_ELEMENTS.majorCreditorsTab).click(); - cy.get(DOM_ELEMENTS.majorCreditorDropdown).should('have.value', ''); + cy.get(MajorAutocompleteLocators.input).click(); + cy.get(MajorAutocompleteLocators.listbox).find('li').contains('Abellio Greater Anglia').click(); + cy.get(MajorAutocompleteLocators.input).should('have.value', 'Abellio Greater Anglia (AGAL)'); + cy.get(NavLocators.minorCreditorsTab).click(); + cy.get(NavLocators.majorCreditorsTab).click(); + cy.get(MajorAutocompleteLocators.input).should('have.value', ''); }, ); @@ -179,12 +177,11 @@ describe('Search Account Component - Major Creditors', () => { setupComponent(); majorCreditorsSearchMock.fsa_search_account_business_unit_ids = [61, 67, 68, 69, 70, 71, 73]; - cy.get(DOM_ELEMENTS.majorCreditorsHeading).should('exist').contains('Major creditors'); - cy.get(DOM_ELEMENTS.majorCreditorBusinessUnitLabel) + cy.get(MajorCreditorsLocators.panel.heading).should('exist').contains('Major creditors'); + cy.get(MajorRequirementLocators.message) .should('exist') .contains('To search major creditors, filter by a single business unit'); - cy.get(DOM_ELEMENTS.majorCreditorBusinessUnitLink).should('exist').contains('filter by a single business unit'); - cy.get('a').contains('filter by a single business unit'); + cy.get(MajorRequirementLocators.link).should('exist').contains('filter by a single business unit'); }); it( @@ -193,11 +190,9 @@ describe('Search Account Component - Major Creditors', () => { () => { setupComponent(); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.majorCreditorMissingError) - .should('exist') - .and('contain', 'Enter a major creditor name or code'); + cy.get(MajorAutocompleteLocators.error).should('exist').and('contain', 'Enter a major creditor name or code'); }, ); @@ -208,11 +203,11 @@ describe('Search Account Component - Major Creditors', () => { setupComponent(); majorCreditorsSearchMock.fsa_search_account_number = '12345678'; majorCreditorsSearchMock.fsa_search_account_reference_case_number = 'REF123'; - cy.get(DOM_ELEMENTS.majorCreditorDropdown).click(); - cy.get(DOM_ELEMENTS.majorCreditorAutoComplete).find('li').contains('Abellio Greater Anglia').click(); - cy.get(DOM_ELEMENTS.majorCreditorDropdown).should('have.value', 'Abellio Greater Anglia (AGAL)'); + cy.get(MajorAutocompleteLocators.input).click(); + cy.get(MajorAutocompleteLocators.listbox).find('li').contains('Abellio Greater Anglia').click(); + cy.get(MajorAutocompleteLocators.input).should('have.value', 'Abellio Greater Anglia (AGAL)'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(CommonLocators.searchButton).click(); cy.get('@routerNavigate').should('have.been.calledWithMatch', ['problem']); }, ); diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesMinorCreditors.cy.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesMinorCreditors.cy.ts index 9e3036b0e0..aba2fd4dac 100644 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesMinorCreditors.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchAndMatchesMinorCreditors.cy.ts @@ -5,12 +5,17 @@ import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { provideHttpClient } from '@angular/common/http'; import { provideRouter } from '@angular/router'; -import { DOM_ELEMENTS } from './constants/search_and_matches_minor_creditors_elements'; +import { AccountSearchCommonLocators as CommonLocators } from '../../../shared/selectors/account-search/account.search.common.locators'; +import { AccountSearchMinorCreditorsLocators as MinorCreditorsLocators } from '../../../shared/selectors/account-search/account.search.minor-creditors.locators'; +import { AccountSearchNavLocators as NavLocators } from '../../../shared/selectors/account-search/account.search.nav.locators'; import { MINOR_CREDITORS_SEARCH_STATE_MOCK } from './mocks/search_and_matches_minor_creditors_mock'; import { finesSaMinorCreditorAccountsResolver } from '../../../../src/app/flows/fines/fines-sa/routing/resolvers/fines-sa-minor-creditor-accounts/fines-sa-minor-creditor-accounts.resolver'; import { OpalFines } from '../../../../src/app/flows/fines/services/opal-fines-service/opal-fines.service'; const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; +const MinorTypeLocators = MinorCreditorsLocators.type; +const MinorIndividualLocators = MinorCreditorsLocators.individual; +const MinorCompanyLocators = MinorCreditorsLocators.company; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; @@ -75,41 +80,41 @@ describe('Search Account Component - Minor Creditors', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.app).should('exist'); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search for an account'); - cy.get(DOM_ELEMENTS.tabs).should('exist'); - cy.get(DOM_ELEMENTS.tabsList).should('exist'); - cy.get(DOM_ELEMENTS.individualsTab).should('exist'); - cy.get(DOM_ELEMENTS.companiesTab).should('exist'); - cy.get(DOM_ELEMENTS.minorCreditorsTab).should('exist'); - cy.get(DOM_ELEMENTS.majorCreditorsTab).should('exist'); - cy.get(DOM_ELEMENTS.minorCreditorsPanel).should('exist'); - cy.get(DOM_ELEMENTS.minorCreditorCompanyRadioButton).should('exist'); - cy.get(DOM_ELEMENTS.minorCreditorIndividualRadioButton).should('exist'); - cy.get(DOM_ELEMENTS.minorCreditorCompanyRadioButton).click(); - cy.get(DOM_ELEMENTS.companyNameLabel).should('exist').contains('Company name'); - cy.get(DOM_ELEMENTS.companyNameInput).should('exist'); - cy.get(DOM_ELEMENTS.companyNameExactMatchCheckbox).should('exist').and('not.be.checked'); - cy.get(DOM_ELEMENTS.addressLine1Label).should('exist').contains('Address line 1'); - cy.get(DOM_ELEMENTS.addressLine1Input).should('exist'); - cy.get(DOM_ELEMENTS.postcodeLabel).should('exist').and('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.postcodeInput).should('exist'); - cy.get(DOM_ELEMENTS.minorCreditorIndividualRadioButton).click(); - cy.get(DOM_ELEMENTS.lastNameLabel).should('exist').and('contain', 'Last name'); - cy.get(DOM_ELEMENTS.lastNameInput).should('exist'); - cy.get(DOM_ELEMENTS.lastNameExactMatchCheckbox).should('exist').and('not.be.checked'); - cy.get(DOM_ELEMENTS.firstNamesLabel).should('exist').and('contain', 'First names'); - cy.get(DOM_ELEMENTS.firstNamesInput).should('exist'); - cy.get(DOM_ELEMENTS.firstNamesExactMatchCheckbox).should('exist').and('not.be.checked'); - cy.get(DOM_ELEMENTS.minorIndividualAddressLine1Label).should('exist').and('contain', 'Address line 1'); - cy.get(DOM_ELEMENTS.minorIndividualAddressLine1Input).should('exist'); - cy.get(DOM_ELEMENTS.minorIndividualPostcodeLabel).should('exist').and('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.minorIndividualPostcodeInput).should('exist'); - cy.get(DOM_ELEMENTS.accountNumberLabel).should('exist').and('contain', 'Account number'); - cy.get(DOM_ELEMENTS.referenceNumberLabel).should('exist').and('contain', 'Reference or case number'); - cy.get(DOM_ELEMENTS.referenceNumberInput).should('exist'); - cy.get(DOM_ELEMENTS.activeAccountsOnlyCheckbox).should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).should('exist').and('contain', 'Search'); + cy.get(CommonLocators.root).should('exist'); + cy.get(CommonLocators.pageHeader).should('contain', 'Search for an account'); + cy.get(NavLocators.tabsContainer).should('exist'); + cy.get(NavLocators.tabsList).should('exist'); + cy.get(NavLocators.individualsTab).should('exist'); + cy.get(NavLocators.companiesTab).should('exist'); + cy.get(NavLocators.minorCreditorsTab).should('exist'); + cy.get(NavLocators.majorCreditorsTab).should('exist'); + cy.get(MinorCreditorsLocators.panel.root).should('exist'); + cy.get(MinorTypeLocators.companyRadio).should('exist'); + cy.get(MinorTypeLocators.individualRadio).should('exist'); + cy.get(MinorTypeLocators.companyRadio).click(); + cy.get(MinorCompanyLocators.companyNameLabel).should('exist').contains('Company name'); + cy.get(MinorCompanyLocators.companyNameInput).should('exist'); + cy.get(MinorCompanyLocators.companyNameExactMatchCheckbox).should('exist').and('not.be.checked'); + cy.get(MinorCompanyLocators.companyAddressLine1Label).should('exist').contains('Address line 1'); + cy.get(MinorCompanyLocators.companyAddressLine1Input).should('exist'); + cy.get(MinorCompanyLocators.companyPostcodeLabel).should('exist').and('contain', 'Postcode'); + cy.get(MinorCompanyLocators.companyPostcodeInput).should('exist'); + cy.get(MinorTypeLocators.individualRadio).click(); + cy.get(MinorIndividualLocators.lastNameLabel).should('exist').and('contain', 'Last name'); + cy.get(MinorIndividualLocators.lastNameInput).should('exist'); + cy.get(MinorIndividualLocators.lastNameExactMatchCheckbox).should('exist').and('not.be.checked'); + cy.get(MinorIndividualLocators.firstNamesLabel).should('exist').and('contain', 'First names'); + cy.get(MinorIndividualLocators.firstNamesInput).should('exist'); + cy.get(MinorIndividualLocators.firstNamesExactMatchCheckbox).should('exist').and('not.be.checked'); + cy.get(MinorIndividualLocators.addressLine1Label).should('exist').and('contain', 'Address line 1'); + cy.get(MinorIndividualLocators.addressLine1Input).should('exist'); + cy.get(MinorIndividualLocators.postcodeLabel).should('exist').and('contain', 'Postcode'); + cy.get(MinorIndividualLocators.postcodeInput).should('exist'); + cy.get(CommonLocators.accountNumberLabel).should('exist').and('contain', 'Account number'); + cy.get(CommonLocators.referenceOrCaseNumberLabel).should('exist').and('contain', 'Reference or case number'); + cy.get(CommonLocators.referenceOrCaseNumberInput).should('exist'); + cy.get(CommonLocators.activeAccountsOnlyCheckbox).should('be.checked'); + cy.get(CommonLocators.searchButton).should('exist').and('contain', 'Search'); }, ); @@ -121,12 +126,14 @@ describe('Search Account Component - Minor Creditors', () => { minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_individual.fsa_search_account_minor_creditors_last_name = 'Smith123'; - cy.get(DOM_ELEMENTS.minorCreditorIndividualRadioButton).click(); - cy.get(DOM_ELEMENTS.lastNameInput).should('have.value', 'Smith123'); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist').and('contain', 'Last name must only contain letters'); - cy.get(DOM_ELEMENTS.lastNameError).should('exist').and('contain', 'Last name must only contain letters'); - cy.get(DOM_ELEMENTS.lastNameInput).clear(); + cy.get(MinorTypeLocators.individualRadio).click(); + cy.get(MinorIndividualLocators.lastNameInput).should('have.value', 'Smith123'); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('exist').and('contain', 'Last name must only contain letters'); + cy.get(MinorIndividualLocators.lastNameError) + .should('exist') + .and('contain', 'Last name must only contain letters'); + cy.get(MinorIndividualLocators.lastNameInput).clear(); }, ); @@ -138,13 +145,15 @@ describe('Search Account Component - Minor Creditors', () => { minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_individual.fsa_search_account_minor_creditors_first_names = 'Name123'; - cy.get(DOM_ELEMENTS.minorCreditorIndividualRadioButton).click(); - cy.get(DOM_ELEMENTS.firstNamesInput).should('have.value', 'Name123'); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist').and('contain', 'First names must only contain letters'); - cy.get(DOM_ELEMENTS.firstNamesError).should('exist').and('contain', 'First names must only contain letters'); + cy.get(MinorTypeLocators.individualRadio).click(); + cy.get(MinorIndividualLocators.firstNamesInput).should('have.value', 'Name123'); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('exist').and('contain', 'First names must only contain letters'); + cy.get(MinorIndividualLocators.firstNamesError) + .should('exist') + .and('contain', 'First names must only contain letters'); - cy.get(DOM_ELEMENTS.firstNamesInput).clear(); + cy.get(MinorIndividualLocators.firstNamesInput).clear(); }, ); @@ -156,17 +165,17 @@ describe('Search Account Component - Minor Creditors', () => { minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_company.fsa_search_account_minor_creditors_company_name = 'Company123?'; - cy.get(DOM_ELEMENTS.minorCreditorCompanyRadioButton).click(); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should( + cy.get(MinorTypeLocators.companyRadio).click(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should( 'contain', 'Company name must only include letters a to z, numbers 0-9 and certain special characters (hyphens, spaces, apostrophes)', ); - cy.get(DOM_ELEMENTS.companyNameError).should( + cy.get(MinorCompanyLocators.companyNameError).should( 'contain', 'Company name must only include letters a to z, numbers 0-9 and certain special characters (hyphens, spaces, apostrophes)', ); - cy.get(DOM_ELEMENTS.companyNameInput).clear(); + cy.get(MinorCompanyLocators.companyNameInput).clear(); }, ); @@ -177,14 +186,14 @@ describe('Search Account Component - Minor Creditors', () => { setupComponent(null); minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_individual.fsa_search_account_minor_creditors_individual_address_line_1 = 'Address123?'; - cy.get(DOM_ELEMENTS.minorCreditorIndividualRadioButton).click(); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Address line 1 must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.minorIndividualAddressLine1Error).should( + cy.get(MinorTypeLocators.individualRadio).click(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Address line 1 must only contain letters or numbers'); + cy.get(MinorIndividualLocators.addressLine1Error).should( 'contain', 'Address line 1 must only contain letters or numbers', ); - cy.get(DOM_ELEMENTS.minorIndividualAddressLine1Input).clear(); + cy.get(MinorIndividualLocators.addressLine1Input).clear(); }, ); @@ -196,11 +205,14 @@ describe('Search Account Component - Minor Creditors', () => { minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_company.fsa_search_account_minor_creditors_company_post_code = 'POSTCODE?'; - cy.get(DOM_ELEMENTS.minorCreditorCompanyRadioButton).click(); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Post code must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.postcodeError).should('contain', 'Post code must only contain letters or numbers'); - cy.get(DOM_ELEMENTS.postcodeInput).clear(); + cy.get(MinorTypeLocators.companyRadio).click(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Post code must only contain letters or numbers'); + cy.get(MinorCompanyLocators.companyPostcodeError).should( + 'contain', + 'Post code must only contain letters or numbers', + ); + cy.get(MinorCompanyLocators.companyPostcodeInput).clear(); }, ); @@ -212,11 +224,11 @@ describe('Search Account Component - Minor Creditors', () => { minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_individual.fsa_search_account_minor_creditors_last_name = 'Abcdefghijklmnopqrstuvwxyzabcdefg'; - cy.get(DOM_ELEMENTS.minorCreditorIndividualRadioButton).click(); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Last name must be 30 characters or fewer'); - cy.get(DOM_ELEMENTS.lastNameError).should('contain', 'Last name must be 30 characters or fewer'); - cy.get(DOM_ELEMENTS.lastNameInput).clear(); + cy.get(MinorTypeLocators.individualRadio).click(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Last name must be 30 characters or fewer'); + cy.get(MinorIndividualLocators.lastNameError).should('contain', 'Last name must be 30 characters or fewer'); + cy.get(MinorIndividualLocators.lastNameInput).clear(); }, ); @@ -228,11 +240,11 @@ describe('Search Account Component - Minor Creditors', () => { minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_individual.fsa_search_account_minor_creditors_first_names = 'AbcdefghijklmnopqrstA'; - cy.get(DOM_ELEMENTS.minorCreditorIndividualRadioButton).click(); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'First names must be 20 characters or fewer'); - cy.get(DOM_ELEMENTS.firstNamesError).should('contain', 'First names must be 20 characters or fewer'); - cy.get(DOM_ELEMENTS.firstNamesInput).clear(); + cy.get(MinorTypeLocators.individualRadio).click(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'First names must be 20 characters or fewer'); + cy.get(MinorIndividualLocators.firstNamesError).should('contain', 'First names must be 20 characters or fewer'); + cy.get(MinorIndividualLocators.firstNamesInput).clear(); }, ); @@ -244,11 +256,11 @@ describe('Search Account Component - Minor Creditors', () => { minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_company.fsa_search_account_minor_creditors_company_name = 'abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijs'; - cy.get(DOM_ELEMENTS.minorCreditorCompanyRadioButton).click(); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Company name must be 50 characters or fewer'); - cy.get(DOM_ELEMENTS.companyNameError).should('contain', 'Company name must be 50 characters or fewer'); - cy.get(DOM_ELEMENTS.companyNameInput).clear(); + cy.get(MinorTypeLocators.companyRadio).click(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Company name must be 50 characters or fewer'); + cy.get(MinorCompanyLocators.companyNameError).should('contain', 'Company name must be 50 characters or fewer'); + cy.get(MinorCompanyLocators.companyNameInput).clear(); }, ); @@ -260,11 +272,14 @@ describe('Search Account Component - Minor Creditors', () => { minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_company.fsa_search_account_minor_creditors_company_address_line_1 = 'Address1234Address1234Address12345'; - cy.get(DOM_ELEMENTS.minorCreditorCompanyRadioButton).click(); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Address line 1 must be 30 characters or fewer'); - cy.get(DOM_ELEMENTS.addressLine1Error).should('contain', 'Address line 1 must be 30 characters or fewer'); - cy.get(DOM_ELEMENTS.addressLine1Input).clear(); + cy.get(MinorTypeLocators.companyRadio).click(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Address line 1 must be 30 characters or fewer'); + cy.get(MinorCompanyLocators.companyAddressLine1Error).should( + 'contain', + 'Address line 1 must be 30 characters or fewer', + ); + cy.get(MinorCompanyLocators.companyAddressLine1Input).clear(); }, ); @@ -276,11 +291,11 @@ describe('Search Account Component - Minor Creditors', () => { minorCreditorsSearchMock.fsa_search_account_minor_creditors_search_criteria!.fsa_search_account_minor_creditors_company.fsa_search_account_minor_creditors_company_post_code = 'POSTCODES'; - cy.get(DOM_ELEMENTS.minorCreditorCompanyRadioButton).click(); - cy.get(DOM_ELEMENTS.searchButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('contain', 'Post code must be 8 characters or fewer'); - cy.get(DOM_ELEMENTS.postcodeError).should('contain', 'Post code must be 8 characters or fewer'); - cy.get(DOM_ELEMENTS.postcodeInput).clear(); + cy.get(MinorTypeLocators.companyRadio).click(); + cy.get(CommonLocators.searchButton).click(); + cy.get(CommonLocators.errorSummary).should('contain', 'Post code must be 8 characters or fewer'); + cy.get(MinorCompanyLocators.companyPostcodeError).should('contain', 'Post code must be 8 characters or fewer'); + cy.get(MinorCompanyLocators.companyPostcodeInput).clear(); }, ); @@ -290,12 +305,12 @@ describe('Search Account Component - Minor Creditors', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.minorCreditorsTab).click(); - cy.get(DOM_ELEMENTS.minorCreditorIndividualRadioButton).click(); - cy.get(DOM_ELEMENTS.lastNameExactMatchCheckbox).check().should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(NavLocators.minorCreditorsTab).click(); + cy.get(MinorTypeLocators.individualRadio).click(); + cy.get(MinorIndividualLocators.lastNameExactMatchCheckbox).check().should('be.checked'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.lastNameError).should('exist').and('contain', 'Enter last name'); + cy.get(MinorIndividualLocators.lastNameError).should('exist').and('contain', 'Enter last name'); }, ); @@ -305,12 +320,12 @@ describe('Search Account Component - Minor Creditors', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.minorCreditorsTab).click(); - cy.get(DOM_ELEMENTS.minorCreditorIndividualRadioButton).click(); - cy.get(DOM_ELEMENTS.firstNamesExactMatchCheckbox).check().should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(NavLocators.minorCreditorsTab).click(); + cy.get(MinorTypeLocators.individualRadio).click(); + cy.get(MinorIndividualLocators.firstNamesExactMatchCheckbox).check().should('be.checked'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.firstNamesError).should('exist').and('contain', 'Enter first name'); + cy.get(MinorIndividualLocators.firstNamesError).should('exist').and('contain', 'Enter first name'); }, ); @@ -320,12 +335,12 @@ describe('Search Account Component - Minor Creditors', () => { () => { setupComponent(null); - cy.get(DOM_ELEMENTS.minorCreditorsTab).click(); - cy.get(DOM_ELEMENTS.minorCreditorCompanyRadioButton).click(); - cy.get(DOM_ELEMENTS.companyNameExactMatchCheckbox).check().should('be.checked'); - cy.get(DOM_ELEMENTS.searchButton).click(); + cy.get(NavLocators.minorCreditorsTab).click(); + cy.get(MinorTypeLocators.companyRadio).click(); + cy.get(MinorCompanyLocators.companyNameExactMatchCheckbox).check().should('be.checked'); + cy.get(CommonLocators.searchButton).click(); - cy.get(DOM_ELEMENTS.companyNameError).should('exist').and('contain', 'Enter company name'); + cy.get(MinorCompanyLocators.companyNameError).should('exist').and('contain', 'Enter company name'); }, ); }); diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchForAccountFilterByBU.cy.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchForAccountFilterByBU.cy.ts index d37bf69350..ab8e20d9ce 100644 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/SearchForAccountFilterByBU.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchAndMatches/SearchForAccountFilterByBU.cy.ts @@ -6,7 +6,10 @@ import { provideHttpClient } from '@angular/common/http'; import { provideRouter, ActivatedRoute } from '@angular/router'; import { BehaviorSubject } from 'rxjs'; -import { DOM_ELEMENTS } from './constants/search_account_filter_by_bu'; +import { SearchFilterByBUCommonLocators as CommonLocators } from '../../../shared/selectors/account-search/account.search.filter-by-bu.common.locators'; +import { FinesFilterBusinessUnitConfiscationLocators as ConfiscationLocators } from '../../../shared/selectors/account-search/account.search.filter-by-bu-confiscation.locators'; +import { FinesFilterBusinessUnitLocators as FinesLocators } from '../../../shared/selectors/account-search/account.search.filter-by-bu-fines.locators'; +import { SearchFilterByBUNavLocators as NavLocators } from '../../../shared/selectors/account-search/account.search.filter-by-bu.nav.locators'; import { FinesSaStore } from 'src/app/flows/fines/fines-sa/stores/fines-sa.store'; import { OpalFines } from '@services/fines/opal-fines-service/opal-fines.service'; import { FinesSaSearchFilterBusinessUnitComponent } from 'src/app/flows/fines/fines-sa/fines-sa-search/fines-sa-search-filter-business-unit/fines-sa-search-filter-business-unit.component'; @@ -15,6 +18,39 @@ import { FinesSaSearchFilterBusinessUnitComponent } from 'src/app/flows/fines/fi import { OPAL_FINES_BUSINESS_UNIT_REF_DATA_MOCK } from '@services/fines/opal-fines-service/mocks/opal-fines-business-unit-ref-data.mock'; const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; +const EXACT_ERROR_TEXT = 'You must select at least one business unit'; + +type BusinessUnitTab = 'fines' | 'confiscation'; + +const TAB_LABELS: Record = { + fines: 'Fines', + confiscation: 'Confiscation', +}; + +const MASTER_LABEL_TEXT: Record = { + fines: 'Fines business units', + confiscation: 'Confiscation business units', +}; + +const TAB_LINK_SELECTORS: Record = { + fines: NavLocators.finesTabLink, + confiscation: NavLocators.confiscationTabLink, +}; + +const MASTER_LABEL_SELECTORS: Record = { + fines: FinesLocators.selectAllBusinessUnitsLabel, + confiscation: ConfiscationLocators.selectAllBusinessUnitsLabel, +}; + +const ROW_LABEL_SELECTORS: Record = { + fines: FinesLocators.businessUnitLabels, + confiscation: ConfiscationLocators.businessUnitLabels, +}; + +const ROW_CHECKBOX_SELECTORS: Record = { + fines: FinesLocators.businessUnitCheckboxes, + confiscation: ConfiscationLocators.businessUnitCheckboxes, +}; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; @@ -33,17 +69,18 @@ describe('Filter by Business Unit (CT)', () => { // Avoid TS casts: use jQuery -> array, then DOM API safely Cypress.$.makeArray($labels).map((el) => (el.textContent ?? '').trim()); - const getRowLabels = () => cy.get(`${DOM_ELEMENTS.tableRows} ${DOM_ELEMENTS.rowLabel}`); + const getRowLabels = (tab: BusinessUnitTab) => cy.get(ROW_LABEL_SELECTORS[tab]); + + const getRowCheckboxes = (tab: BusinessUnitTab) => cy.get(ROW_CHECKBOX_SELECTORS[tab]); - const getRowCheckboxes = () => cy.get(`${DOM_ELEMENTS.tableBody} ${DOM_ELEMENTS.rowCheckbox}`); + const getMasterLabel = (tab: BusinessUnitTab) => cy.get(MASTER_LABEL_SELECTORS[tab]); - const clickTabByText = (txt: string) => - cy.contains(DOM_ELEMENTS.tabLink, txt).scrollIntoView().click({ force: true }); + const clickTab = (tab: BusinessUnitTab) => cy.get(TAB_LINK_SELECTORS[tab]).scrollIntoView().click({ force: true }); const textNorm = (s: string) => s.replace(/\s+/g, ' ').trim(); const assertSaveCount = (n: number) => { - cy.get(DOM_ELEMENTS.saveButton) + cy.get(CommonLocators.saveSelectionButton) .invoke('text') .then((t) => { const txt = textNorm(t); @@ -52,19 +89,19 @@ describe('Filter by Business Unit (CT)', () => { }); }; - const ensureAtLeastNRows = (n: number) => - getRowCheckboxes().should(($rows) => { + const ensureAtLeastNRows = (tab: BusinessUnitTab, n: number) => + getRowCheckboxes(tab).should(($rows) => { expect($rows.length, `need at least ${n} rows`).to.be.gte(n); }); const switchToConfiscation = () => { - clickTabByText(DOM_ELEMENTS.confiscationTabText); + clickTab('confiscation'); cy.then(() => { fragment$.next('confiscation'); window.location.hash = '#confiscation'; window.dispatchEvent(new HashChangeEvent('hashchange')); }); - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.confMasterText).should('be.visible'); + getMasterLabel('confiscation').should('be.visible'); }; const setupComponent = () => { @@ -122,28 +159,28 @@ describe('Filter by Business Unit (CT)', () => { setupComponent(); // Tabs exist by visible text - cy.contains(DOM_ELEMENTS.tabLink, DOM_ELEMENTS.finesTabText).should('exist'); - cy.contains(DOM_ELEMENTS.tabLink, DOM_ELEMENTS.confiscationTabText).should('exist'); + cy.get(NavLocators.finesTabLink).should('contain.text', TAB_LABELS.fines); + cy.get(NavLocators.confiscationTabLink).should('contain.text', TAB_LABELS.confiscation); // Master checkbox label (Fines) - cy.get(DOM_ELEMENTS.masterCheckboxLabel) + getMasterLabel('fines') .invoke('text') - .then((t) => expect(t.trim()).to.eq(DOM_ELEMENTS.finesMasterText)); + .then((t) => expect(t.trim()).to.eq(MASTER_LABEL_TEXT.fines)); // Fines BU labels in the table - getRowLabels().then(($labels) => { + getRowLabels('fines').then(($labels) => { const actual = extractLabels($labels); expect(norm(actual), 'Fines members match').to.deep.equal(norm(expectedFinesNames)); expect(actual, 'Fines alphabetical (A→Z)').to.deep.equal(norm(actual)); }); // Controls - cy.get(DOM_ELEMENTS.saveButton) + cy.get(CommonLocators.saveSelectionButton) .invoke('text') .then((t) => { expect(t.trim()).to.match(/^Save selection/); }); - cy.get(DOM_ELEMENTS.cancelLink).should('have.text', 'Cancel'); + cy.get(CommonLocators.cancelLink).should('have.text', 'Cancel'); }, ); @@ -160,14 +197,14 @@ describe('Filter by Business Unit (CT)', () => { setupComponent(); - getRowCheckboxes() + getRowCheckboxes('fines') .should('have.length', preselectedIds.length) .each(($input) => { expect(($input[0] as HTMLInputElement).checked, 'row is checked').to.eq(true); }); // “n of n selected” - cy.get(DOM_ELEMENTS.selectedCounter) + cy.get(CommonLocators.selectedCountLabel) .invoke('text') .then((t) => { const txt = t.trim(); @@ -181,8 +218,8 @@ describe('Filter by Business Unit (CT)', () => { it('AC2a: shows two tabs – Fines and Confiscation', { tags: buildTags('@JIRA-KEY:POT-3750') }, () => { setupComponent(); - cy.contains(DOM_ELEMENTS.tabLink, DOM_ELEMENTS.finesTabText).should('exist'); - cy.contains(DOM_ELEMENTS.tabLink, DOM_ELEMENTS.confiscationTabText).should('exist'); + cy.get(NavLocators.finesTabLink).should('contain.text', TAB_LABELS.fines); + cy.get(NavLocators.confiscationTabLink).should('contain.text', TAB_LABELS.confiscation); }); // ---------------- AC2 (Fines) ---------------- @@ -192,9 +229,9 @@ describe('Filter by Business Unit (CT)', () => { { tags: buildTags('@JIRA-KEY:POT-3751') }, () => { setupComponent(); - clickTabByText(DOM_ELEMENTS.finesTabText); + clickTab('fines'); - getRowLabels().then(($labels) => { + getRowLabels('fines').then(($labels) => { const actual = extractLabels($labels); expect(norm(actual), 'Fines membership').to.deep.equal(norm(expectedFinesNames)); actual.forEach((label) => expect(expectedFinesNames, 'label equals BU name').to.include(label)); @@ -214,9 +251,9 @@ describe('Filter by Business Unit (CT)', () => { fragment$.next('confiscation'); cy.wrap(null).then(() => { - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.confMasterText).should('exist'); + getMasterLabel('confiscation').should('exist').and('contain.text', MASTER_LABEL_TEXT.confiscation); - getRowLabels().then(($labels) => { + getRowLabels('confiscation').then(($labels) => { const actual = extractLabels($labels); // membership + exact names (ignoring order) @@ -238,19 +275,19 @@ describe('Filter by Business Unit (CT)', () => { preselectedIds = []; setupComponent(); - clickTabByText(DOM_ELEMENTS.finesTabText); + clickTab('fines'); const n = expectedFinesNames.length; // Toggle ON via label - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.finesMasterText).click(); + getMasterLabel('fines').click(); // All checked - getRowCheckboxes() + getRowCheckboxes('fines') .should('have.length', n) .each(($input) => expect(($input[0] as HTMLInputElement).checked).to.eq(true)); // Counter "n of n" - cy.get(DOM_ELEMENTS.selectedCounter) + cy.get(CommonLocators.selectedCountLabel) .invoke('text') .then((txt) => { expect(txt.trim()).to.match(new RegExp(`^\\s*${n}\\s+of\\s+${n}\\s+selected\\s*$`)); @@ -268,19 +305,19 @@ describe('Filter by Business Unit (CT)', () => { setupComponent(); - clickTabByText(DOM_ELEMENTS.finesTabText); + clickTab('fines'); const n = expectedFinesNames.length; // Toggle OFF - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.finesMasterText).click(); + getMasterLabel('fines').click(); // All unchecked - getRowCheckboxes() + getRowCheckboxes('fines') .should('have.length', n) .each(($input) => expect(($input[0] as HTMLInputElement).checked).to.eq(false)); // Counter "0 of n" - cy.get(DOM_ELEMENTS.selectedCounter) + cy.get(CommonLocators.selectedCountLabel) .invoke('text') .then((txt) => { expect(txt.trim()).to.match(new RegExp(`^\\s*0\\s+of\\s+${n}\\s+selected\\s*$`)); @@ -299,16 +336,16 @@ describe('Filter by Business Unit (CT)', () => { fragment$.next('confiscation'); cy.wrap(null).then(() => { - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.confMasterText).should('exist'); + getMasterLabel('confiscation').should('exist').and('contain.text', MASTER_LABEL_TEXT.confiscation); const n = expectedConfNames.length; - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.confMasterText).click(); + getMasterLabel('confiscation').click(); - getRowCheckboxes() + getRowCheckboxes('confiscation') .should('have.length', n) .each(($input) => expect(($input[0] as HTMLInputElement).checked).to.eq(true)); - cy.get(DOM_ELEMENTS.selectedCounter) + cy.get(CommonLocators.selectedCountLabel) .invoke('text') .then((txt) => { expect(txt.trim()).to.match(new RegExp(`^\\s*${n}\\s+of\\s+${n}\\s+selected\\s*$`)); @@ -330,13 +367,13 @@ describe('Filter by Business Unit (CT)', () => { fragment$.next('confiscation'); cy.wrap(null).then(() => { const n = expectedConfNames.length; - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.confMasterText).click(); + getMasterLabel('confiscation').click(); - getRowCheckboxes() + getRowCheckboxes('confiscation') .should('have.length', n) .each(($input) => expect(($input[0] as HTMLInputElement).checked).to.eq(false)); - cy.get(DOM_ELEMENTS.selectedCounter) + cy.get(CommonLocators.selectedCountLabel) .invoke('text') .then((txt) => { expect(txt.trim()).to.match(new RegExp(`^\\s*0\\s+of\\s+${n}\\s+selected\\s*$`)); @@ -358,23 +395,23 @@ describe('Filter by Business Unit (CT)', () => { assertSaveCount(0); // Tick two Fines rows - ensureAtLeastNRows(2); - getRowCheckboxes().eq(0).check({ force: true }); + ensureAtLeastNRows('fines', 2); + getRowCheckboxes('fines').eq(0).check({ force: true }); assertSaveCount(1); - getRowCheckboxes().eq(1).check({ force: true }); + getRowCheckboxes('fines').eq(1).check({ force: true }); assertSaveCount(2); // Switch to Confiscation and tick one more switchToConfiscation(); - getRowCheckboxes().first().check({ force: true }); + getRowCheckboxes('confiscation').first().check({ force: true }); assertSaveCount(3); // Uncheck it -> total back to 2 - getRowCheckboxes().first().uncheck({ force: true }); + getRowCheckboxes('confiscation').first().uncheck({ force: true }); assertSaveCount(2); // Back to Fines; total should persist - clickTabByText(DOM_ELEMENTS.finesTabText); + clickTab('fines'); cy.then(() => { fragment$.next('fines'); window.location.hash = '#fines'; @@ -386,22 +423,22 @@ describe('Filter by Business Unit (CT)', () => { // ============ AC6 (error when saving with no selection) ============ - const clickSave = () => cy.get(DOM_ELEMENTS.saveButton).click(); + const clickSave = () => cy.get(CommonLocators.saveSelectionButton).click(); const assertErrorSummaryVisible = () => { - cy.get(DOM_ELEMENTS.errorSummary).should('be.visible'); + cy.get(CommonLocators.errorSummary).should('be.visible'); cy.get('body').then(($body) => { // Prefer the GOV.UK list if present - if ($body.find(DOM_ELEMENTS.errorSummaryList).length) { - cy.get(DOM_ELEMENTS.errorSummaryList) + if ($body.find(CommonLocators.errorSummaryList).length) { + cy.get(CommonLocators.errorSummaryList) .invoke('text') - .then((t) => expect(textNorm(t)).to.include(DOM_ELEMENTS.exactErrorText)); + .then((t) => expect(textNorm(t)).to.include(EXACT_ERROR_TEXT)); } else { // Fallback: check any visible text inside the summary wrapper - cy.get(DOM_ELEMENTS.errorSummary) + cy.get(CommonLocators.errorSummary) .invoke('text') - .then((t) => expect(textNorm(t)).to.include(DOM_ELEMENTS.exactErrorText)); + .then((t) => expect(textNorm(t)).to.include(EXACT_ERROR_TEXT)); } }); }; @@ -424,7 +461,7 @@ describe('Filter by Business Unit (CT)', () => { assertErrorSummaryVisible(); // Still on Fines tab (header unchanged) - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.finesMasterText).should('be.visible'); + getMasterLabel('fines').should('be.visible'); }, ); @@ -437,7 +474,7 @@ describe('Filter by Business Unit (CT)', () => { // Switch to Confiscation fragment$.next('confiscation'); - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.confMasterText).should('be.visible'); + getMasterLabel('confiscation').should('be.visible'); // Sanity: Save shows (0) assertSaveCount(0); @@ -449,7 +486,7 @@ describe('Filter by Business Unit (CT)', () => { assertErrorSummaryVisible(); // Still on Confiscation tab (header unchanged) - cy.contains(DOM_ELEMENTS.masterCheckboxLabel, DOM_ELEMENTS.confMasterText).should('be.visible'); + getMasterLabel('confiscation').should('be.visible'); }, ); }); diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_account_filter_by_bu.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_account_filter_by_bu.ts deleted file mode 100644 index e1174394dd..0000000000 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_account_filter_by_bu.ts +++ /dev/null @@ -1,36 +0,0 @@ -// constants/search_account_filter_by_bu.ts -export const DOM_ELEMENTS = { - // Page - app: 'app-fines-sa-search-filter-business-unit-form', - heading: 'h1.govuk-heading-l', - - // Tabs - tabLink: 'a.moj-sub-navigation__link', - finesTabText: 'Fines', - confiscationTabText: 'Confiscation', - - // Panels / counters - selectedCounter: 'form > div:first-of-type', - - // Table - table: 'table.govuk-table', - tableBody: 'table.govuk-table > tbody.govuk-table__body', - tableRows: 'table.govuk-table > tbody.govuk-table__body tr.govuk-table__row', - rowLabel: '.govuk-checkboxes__label', - rowCheckbox: '.govuk-checkboxes__input', - - // Master checkbox label in table header - masterCheckboxLabel: 'th .govuk-checkboxes__label', - finesMasterText: 'Fines business units', - confMasterText: 'Confiscation business units', - - // Buttons/links - saveButton: 'button#submitForm', - cancelLink: 'a.govuk-link.button-link', - - // error summary - errorSummary: 'opal-lib-govuk-error-summary, .govuk-error-summary', - errorSummaryTitle: '.govuk-error-summary__title', - errorSummaryList: '.govuk-error-summary__list', - exactErrorText: 'You must select at least one business unit', -}; diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_company_elements.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_company_elements.ts deleted file mode 100644 index 63840bac64..0000000000 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_company_elements.ts +++ /dev/null @@ -1,50 +0,0 @@ -export const DOM_ELEMENTS = { - app: 'app-fines-sa-search-account-form', - heading: '.govuk-heading-l', - tabs: 'opal-lib-govuk-tabs', - tabsList: '.govuk-tabs__list', - individualsTab: '[id="tab-individuals"]', - companiesTab: '[id="tab-companies"]', - minorCreditorsTab: '[id="tab-minor-creditors"]', - majorCreditorsTab: '[id="tab-major-creditors"]', - companiesPanel: '[id="companies"]', - companiesHeading: '[id="companies"] .govuk-heading-l', - searchButton: '[buttonId="submitForm"]', - - // Filter by business unit section - businessUnitSummaryList: '[summaryListId="accountDetails"]', - businessUnitLink: '[summaryListRowId="languagePreferences"] a', - businessUnitBadge: '.business-unit-badge', - - // Account number field - accountNumberLabel: '[for="fsa_search_account_number"]', - accountNumberInput: '#fsa_search_account_number', - accountNumberError: '#fsa_search_account_number-error-message', - - // Reference or case number field - referenceNumberLabel: '[for="fsa_search_account_reference_case_number"]', - referenceNumberInput: '#fsa_search_account_reference_case_number', - referenceNumberError: '#fsa_search_account_reference_case_number-error-message', - - // Company tab fields - companyNameLabel: '[for="fsa_search_account_companies_company_name"]', - companyNameInput: '#fsa_search_account_companies_company_name', - companyNameExactMatchCheckbox: '#fsa_search_account_companies_company_name_exact_match', - companyNameError: '#fsa_search_account_companies_company_name-error-message', - - includeAliasCheckbox: '#fsa_search_account_companies_include_aliases', - - addressLine1Label: '[for="fsa_search_account_companies_address_line_1"]', - addressLine1Input: '#fsa_search_account_companies_address_line_1', - addressLine1Error: '#fsa_search_account_companies_address_line_1-error-message', - - postcodeLabel: '[for="fsa_search_account_companies_post_code"]', - postcodeInput: '#fsa_search_account_companies_post_code', - postcodeError: '#fsa_search_account_companies_post_code-error-message', - - // Active accounts only checkbox - activeAccountsOnlyCheckbox: '#fsa_search_account_active_accounts_only', - - // Generic error message - errorSummary: '.govuk-error-summary', -}; diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_individuals_elements.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_individuals_elements.ts deleted file mode 100644 index d487be7cb0..0000000000 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_individuals_elements.ts +++ /dev/null @@ -1,66 +0,0 @@ -export const DOM_ELEMENTS = { - app: 'app-fines-sa-search-account-form', - heading: '.govuk-heading-l', - tabs: 'opal-lib-govuk-tabs', - tabsList: '.govuk-tabs__list', - individualsTab: '[id="tab-individuals"]', - companiesTab: '[id="tab-companies"]', - minorCreditorsTab: '[id="tab-minor-creditors"]', - majorCreditorsTab: '[id="tab-major-creditors"]', - individualsPanel: '[id="individuals"]', - individualsHeading: '[id="individuals"] .govuk-heading-l', - searchButton: '[buttonId="submitForm"]', - - // Filter by business unit section - businessUnitSummaryList: '[summaryListId="accountDetails"]', - businessUnitLink: '[summaryListRowId="languagePreferences"] a', - businessUnitBadge: '.business-unit-badge', - - // Account number field - accountNumberLabel: '[for="fsa_search_account_number"]', - accountNumberInput: '#fsa_search_account_number', - accountNumberError: '#fsa_search_account_number-error-message', - - // Reference or case number field - referenceNumberLabel: '[for="fsa_search_account_reference_case_number"]', - referenceNumberInput: '#fsa_search_account_reference_case_number', - referenceNumberError: '#fsa_search_account_reference_case_number-error-message', - - // Individual tab fields - lastNameLabel: '[for="fsa_search_account_individuals_last_name"]', - lastNameInput: '#fsa_search_account_individuals_last_name', - lastNameExactMatchCheckbox: '#fsa_search_account_individuals_last_name_exact_match', - lastNameError: '#fsa_search_account_individuals_last_name-error-message', - - firstNamesLabel: '[for="fsa_search_account_individuals_first_names"]', - firstNamesInput: '#fsa_search_account_individuals_first_names', - firstNamesExactMatchCheckbox: '#fsa_search_account_individuals_first_names_exact_match', - firstNamesError: '#fsa_search_account_individuals_first_names-error-message', - - includeAliasesCheckbox: '#fsa_search_account_individuals_include_aliases', - - dobLabel: '[for="fsa_search_account_individuals_date_of_birth"]', - dobInput: '#fsa_search_account_individuals_date_of_birth', - dobError: '#fsa_search_account_individuals_date_of_birth-error-message', - dobDatePickerToggle: '.moj-datepicker__toggle', - dobDatePicker: '#datepicker-fsa_search_account_individuals_date_of_birth', - dobDatePickerPrevMonth: '.moj-datepicker__button.moj-js-datepicker-prev-month', - - niNumberLabel: '[for="fsa_search_account_individuals_national_insurance_number"]', - niNumberInput: '#fsa_search_account_individuals_national_insurance_number', - niNumberError: '#fsa_search_account_individuals_national_insurance_number-error-message', - - addressLine1Label: '[for="fsa_search_account_individuals_address_line_1"]', - addressLine1Input: '#fsa_search_account_individuals_address_line_1', - addressLine1Error: '#fsa_search_account_individuals_address_line_1-error-message', - - postcodeLabel: '[for="fsa_search_account_individuals_post_code"]', - postcodeInput: '#fsa_search_account_individuals_post_code', - postcodeError: '#fsa_search_account_individuals_post_code-error-message', - - // Active accounts only checkbox - activeAccountsOnlyCheckbox: '#fsa_search_account_active_accounts_only', - - // Generic error message - errorSummary: '.govuk-error-summary', -}; diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_major_creditors_elements.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_major_creditors_elements.ts deleted file mode 100644 index 851e7b1709..0000000000 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_major_creditors_elements.ts +++ /dev/null @@ -1,90 +0,0 @@ -export const DOM_ELEMENTS = { - app: 'app-fines-sa-search-account-form', - heading: '.govuk-heading-l', - tabs: 'opal-lib-govuk-tabs', - tabsList: '.govuk-tabs__list', - individualsTab: '[id="tab-individuals"]', - companiesTab: '[id="tab-companies"]', - minorCreditorsTab: '[id="tab-minor-creditors"]', - majorCreditorsTab: '[id="tab-major-creditors"]', - minorCreditorsPanel: '[id="minorCreditors"]', - minorCreditorsHeading: '[id="minorCreditors"] .govuk-heading-l', - searchButton: '[buttonId="submitForm"]', - - // Filter by business unit section - businessUnitSummaryList: '[summaryListId="accountDetails"]', - businessUnitLink: '[summaryListRowId="languagePreferences"] a', - businessUnitBadge: '.business-unit-badge', - - // Account number field - accountNumberLabel: '[for="fsa_search_account_number"]', - accountNumberInput: '#fsa_search_account_number', - accountNumberError: '#fsa_search_account_number-error-message', - - // Reference or case number field - referenceNumberLabel: '[for="fsa_search_account_reference_case_number"]', - referenceNumberInput: '#fsa_search_account_reference_case_number', - referenceNumberError: '#fsa_search_account_reference_case_number-error-message', - - // Minor creditors tab fields - - minorCreditorIndividualRadioButton: - 'input[name="fsa_search_account_minor_creditors_minor_creditor_type"][value="individual"]', - minorCreditorCompanyRadioButton: - 'input[name="fsa_search_account_minor_creditors_minor_creditor_type"][value="company"]', - - //Individual - lastNameLabel: '[for="fsa_search_account_minor_creditors_last_name"]', - lastNameInput: '#fsa_search_account_minor_creditors_last_name', - lastNameExactMatchCheckbox: '#fsa_search_account_minor_creditors_last_name_exact_match', - lastNameError: '#fsa_search_account_minor_creditors_last_name-error-message', - - firstNamesLabel: '[for="fsa_search_account_minor_creditors_first_names"]', - firstNamesInput: '#fsa_search_account_minor_creditors_first_names', - firstNamesExactMatchCheckbox: '#fsa_search_account_minor_creditors_first_names_exact_match', - firstNamesError: '#fsa_search_account_minor_creditors_first_names-error-message', - - minorIndividualAddressLine1Label: '[for="fsa_search_account_minor_creditors_individual_address_line_1"]', - minorIndividualAddressLine1Input: '#fsa_search_account_minor_creditors_individual_address_line_1', - minorIndividualAddressLine1Error: '#fsa_search_account_minor_creditors_individual_address_line_1-error-message', - - minorIndividualPostcodeLabel: '[for="fsa_search_account_minor_creditors_individual_post_code"]', - minorIndividualPostcodeInput: '#fsa_search_account_minor_creditors_individual_post_code', - minorIndividualPostcodeError: '#fsa_search_account_minor_creditors_individual_post_code-error-message', - - //Company - companyNameLabel: '[for="fsa_search_account_minor_creditors_company_name"]', - companyNameInput: '#fsa_search_account_minor_creditors_company_name', - companyNameExactMatchCheckbox: '#fsa_search_account_minor_creditors_company_name_exact_match', - companyNameError: '#fsa_search_account_minor_creditors_company_name-error-message', - - addressLine1Label: '[for="fsa_search_account_minor_creditors_company_address_line_1"]', - addressLine1Input: '#fsa_search_account_minor_creditors_company_address_line_1', - addressLine1Error: '#fsa_search_account_minor_creditors_company_address_line_1-error-message', - - postcodeLabel: '[for="fsa_search_account_minor_creditors_company_post_code"]', - postcodeInput: '#fsa_search_account_minor_creditors_company_post_code', - postcodeError: '#fsa_search_account_minor_creditors_company_post_code-error-message', - - //Major creditors tab fields - majorCreditorsPanel: '[id="majorCreditors"]', - majorCreditorsHeading: '[id="majorCreditors"] .govuk-heading-l', - majorCreditorsHelpText: '[id="fsa_search_account_major_creditors_major_creditor_id-hint"]', - majorCreditorBusinessUnitLabel: '.govuk-body', - majorCreditorBusinessUnitLink: '.govuk-body > .govuk-link', - majorCreditorDropdown: '[id="fsa_search_account_major_creditors_major_creditor_id-autocomplete"]', - majorCreditorAutoComplete: `ul[id = "fsa_search_account_major_creditors_major_creditor_id-autocomplete__listbox"]`, - - //Get error message IDs - majorCreditorMissingError: '#fsa_search_account_major_creditors_major_creditor_id-autocomplete-error-message', - - majorCreditorSelectLabel: '[for="fsa_search_account_major_creditors_major_creditor_id"]', - majorCreditorSelect: '#fsa_search_account_major_creditors_major_creditor_id', - majorCreditorSelectError: '#fsa_search_account_major_creditors_major_creditor_id-error-message', - - // Active accounts only checkbox - activeAccountsOnlyCheckbox: '#fsa_search_account_active_accounts_only', - - // Generic error message - errorSummary: '.govuk-error-summary', -}; diff --git a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_minor_creditors_elements.ts b/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_minor_creditors_elements.ts deleted file mode 100644 index 2ff5fc2b9c..0000000000 --- a/cypress/component/fineAccountEnquiry/searchAndMatches/constants/search_and_matches_minor_creditors_elements.ts +++ /dev/null @@ -1,74 +0,0 @@ -export const DOM_ELEMENTS = { - app: 'app-fines-sa-search-account-form', - heading: '.govuk-heading-l', - tabs: 'opal-lib-govuk-tabs', - tabsList: '.govuk-tabs__list', - individualsTab: '[id="tab-individuals"]', - companiesTab: '[id="tab-companies"]', - minorCreditorsTab: '[id="tab-minor-creditors"]', - majorCreditorsTab: '[id="tab-major-creditors"]', - minorCreditorsPanel: '[id="minorCreditors"]', - minorCreditorsHeading: '[id="minorCreditors"] .govuk-heading-l', - searchButton: '[buttonId="submitForm"]', - - // Filter by business unit section - businessUnitSummaryList: '[summaryListId="accountDetails"]', - businessUnitLink: '[summaryListRowId="languagePreferences"] a', - businessUnitBadge: '.business-unit-badge', - - // Account number field - accountNumberLabel: '[for="fsa_search_account_number"]', - accountNumberInput: '#fsa_search_account_number', - accountNumberError: '#fsa_search_account_number-error-message', - - // Reference or case number field - referenceNumberLabel: '[for="fsa_search_account_reference_case_number"]', - referenceNumberInput: '#fsa_search_account_reference_case_number', - referenceNumberError: '#fsa_search_account_reference_case_number-error-message', - - // Minor creditors tab fields - - minorCreditorIndividualRadioButton: - 'input[name="fsa_search_account_minor_creditors_minor_creditor_type"][value="individual"]', - minorCreditorCompanyRadioButton: - 'input[name="fsa_search_account_minor_creditors_minor_creditor_type"][value="company"]', - - //Individual - lastNameLabel: '[for="fsa_search_account_minor_creditors_last_name"]', - lastNameInput: '#fsa_search_account_minor_creditors_last_name', - lastNameExactMatchCheckbox: '#fsa_search_account_minor_creditors_last_name_exact_match', - lastNameError: '#fsa_search_account_minor_creditors_last_name-error-message', - - firstNamesLabel: '[for="fsa_search_account_minor_creditors_first_names"]', - firstNamesInput: '#fsa_search_account_minor_creditors_first_names', - firstNamesExactMatchCheckbox: '#fsa_search_account_minor_creditors_first_names_exact_match', - firstNamesError: '#fsa_search_account_minor_creditors_first_names-error-message', - - minorIndividualAddressLine1Label: '[for="fsa_search_account_minor_creditors_individual_address_line_1"]', - minorIndividualAddressLine1Input: '#fsa_search_account_minor_creditors_individual_address_line_1', - minorIndividualAddressLine1Error: '#fsa_search_account_minor_creditors_individual_address_line_1-error-message', - - minorIndividualPostcodeLabel: '[for="fsa_search_account_minor_creditors_individual_post_code"]', - minorIndividualPostcodeInput: '#fsa_search_account_minor_creditors_individual_post_code', - minorIndividualPostcodeError: '#fsa_search_account_minor_creditors_individual_post_code-error-message', - - //Company - companyNameLabel: '[for="fsa_search_account_minor_creditors_company_name"]', - companyNameInput: '#fsa_search_account_minor_creditors_company_name', - companyNameExactMatchCheckbox: '#fsa_search_account_minor_creditors_company_name_exact_match', - companyNameError: '#fsa_search_account_minor_creditors_company_name-error-message', - - addressLine1Label: '[for="fsa_search_account_minor_creditors_company_address_line_1"]', - addressLine1Input: '#fsa_search_account_minor_creditors_company_address_line_1', - addressLine1Error: '#fsa_search_account_minor_creditors_company_address_line_1-error-message', - - postcodeLabel: '[for="fsa_search_account_minor_creditors_company_post_code"]', - postcodeInput: '#fsa_search_account_minor_creditors_company_post_code', - postcodeError: '#fsa_search_account_minor_creditors_company_post_code-error-message', - - // Active accounts only checkbox - activeAccountsOnlyCheckbox: '#fsa_search_account_active_accounts_only', - - // Generic error message - errorSummary: '.govuk-error-summary', -}; diff --git a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsAccountNumber.cy.ts b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsAccountNumber.cy.ts index 955a94daf0..3392746470 100644 --- a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsAccountNumber.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsAccountNumber.cy.ts @@ -3,14 +3,18 @@ import { FinesSaResultsComponent } from '../../../../src/app/flows/fines/fines-s import { FinesSaStore } from '../../../../src/app/flows/fines/fines-sa/stores/fines-sa.store'; import { ActivatedRoute } from '@angular/router'; import { provideHttpClient } from '@angular/common/http'; -import { DOM_ELEMENTS as INDIVIDUAL_DOM_ELEMENTS } from './constants/search_results_individuals_elements'; -import { DOM_ELEMENTS as MINOR_CREDITOR_DOM_ELEMENTS } from './constants/search_results_minor_creditors_elements'; +import { AccountEnquiryResultsLocators as ResultsLocators } from '../../../shared/selectors/account-enquiry/account.enquiry.results.locators'; import { UNIFIED_SEARCH_RESULTS_MOCK, getAllAccountTypes } from './mocks/search_results_account_mock'; import { INDIVIDUAL_SEARCH_STATE_MOCK } from '../searchAndMatches/mocks/search_and_matches_individual_mock'; import { OpalFines } from '../../../../src/app/flows/fines/services/opal-fines-service/opal-fines.service'; import { BehaviorSubject } from 'rxjs'; const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; +const ResultsPageLocators = ResultsLocators.page; +const ResultsMessageLocators = ResultsLocators.messages; +const ResultsTabLocators = ResultsLocators.tabs; +const ResultsHeaderCellLocators = ResultsLocators.headerCells; +const ResultsCellLocators = ResultsLocators.cols; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; @@ -96,8 +100,8 @@ describe('FinesSaResultsComponent - All Account Types', () => { () => { setupComponent('WITH_DATA'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); }, ); @@ -108,13 +112,13 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('EMPTY_RESULTS'); // AC3a: Verify the error screen is displayed when no search matches are found - cy.get(INDIVIDUAL_DOM_ELEMENTS.noResultsHeading).should('be.visible'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.noResultsHeading).should('contain', 'There are no matching results'); + cy.get(ResultsMessageLocators.noResultsHeading).should('be.visible'); + cy.get(ResultsMessageLocators.noResultsHeading).should('contain', 'There are no matching results'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.checkSearchLink).should('be.visible'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.checkSearchLink).should('contain', 'Check your search'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('be.visible'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('contain', 'Check your search'); // AC3b: Verify 'Check your search' link is clickable and functional - cy.get(INDIVIDUAL_DOM_ELEMENTS.checkSearchLink).click(); + cy.get(ResultsMessageLocators.checkYourSearchLink).click(); }, ); @@ -127,16 +131,16 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('LARGE_RESULTS'); // AC4a: Verify the "too many results" error screen is displayed - cy.get(INDIVIDUAL_DOM_ELEMENTS.tooManyResultsHeading).should('be.visible'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.tooManyResultsHeading).should('contain', 'There are more than 100 results'); + cy.get(ResultsMessageLocators.tooManyResultsHeading).should('be.visible'); + cy.get(ResultsMessageLocators.tooManyResultsHeading).should('contain', 'There are more than 100 results'); // Note: AC4b The 'Try adding more information' link will navigate a user back to the Search for an Account screen - Full Test to be implemented when API complete // AC4b: Verify 'Try adding more information' link is present - cy.get(INDIVIDUAL_DOM_ELEMENTS.addMoreInfoLink) + cy.get(ResultsMessageLocators.addMoreInfoLink) .should('be.visible') .should('contain', 'Try adding more information'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.addMoreInfoLink).should('have.class', 'govuk-link'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.addMoreInfoLink).click(); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('have.class', 'govuk-link'); + cy.get(ResultsMessageLocators.addMoreInfoLink).click(); }, ); @@ -147,43 +151,43 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('WITH_DATA', 'individuals'); // AC5b-Verify Individuals tab is in focus by default - verifyTabIsActive(INDIVIDUAL_DOM_ELEMENTS.individualsTab); + verifyTabIsActive(ResultsTabLocators.individualsTab); // Verify all column headers are present - cy.get(INDIVIDUAL_DOM_ELEMENTS.accountHeader).should('contain', 'Account'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.nameHeader).should('contain', 'Name'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.aliasesHeader).should('contain', 'Aliases'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.dobHeader).should('contain', 'Date of birth'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.addressHeader).should('contain', 'Address line 1'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.postcodeHeader).should('contain', 'Postcode'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.niNumberHeader).should('contain', 'NI number'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.parentGuardianHeader).should('contain', 'Parent or guardian'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.businessUnitHeader).should('contain', 'Business unit'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.refHeader).should('contain', 'Ref'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.enfHeader).should('contain', 'ENF'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.balanceHeader).should('contain', 'Balance'); - - cy.get(INDIVIDUAL_DOM_ELEMENTS.accountCell).first().should('contain', '13001BU'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.accountCell).first().find('a').should('exist'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.nameCell).first().should('contain', 'SMITH, John Michael'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.aliasesCell).first().should('contain', 'SMITH, John Michael'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.dobCell).first().should('contain', '01 Jun 1985'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.addressCell).first().should('contain', '1 High Street'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.postcodeCell).first().should('contain', 'RG1 9RT'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.niNumberCell).first().should('contain', 'JK 56 78 90 C'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.parentGuardianCell).first().should('contain', 'DOE, Jane'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.businessUnitCell).first().should('contain', 'Test Business Unit'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.refCell).first().should('contain', 'PCR19274548'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.enfCell).first().should('contain', 'BWTD'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.balanceCell).first().should('contain', '£714.00'); - - cy.get(INDIVIDUAL_DOM_ELEMENTS.accountCell).eq(1).should('contain', '13002BU'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.nameCell).eq(1).should('contain', 'DOE, Jane'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.dobCell).eq(1).should('contain', '15 Mar 1990'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.enfCell).eq(1).should('contain', 'WARRANT'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.balanceCell).eq(1).should('contain', '£524.00'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.aliasesCell).eq(1).should('not.contain', 'SMITH'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.parentGuardianCell).eq(1).should('not.contain', 'DOE, Jane'); + cy.get(ResultsHeaderCellLocators.account).should('contain', 'Account'); + cy.get(ResultsHeaderCellLocators.name).should('contain', 'Name'); + cy.get(ResultsHeaderCellLocators.aliases).should('contain', 'Aliases'); + cy.get(ResultsHeaderCellLocators.dob).should('contain', 'Date of birth'); + cy.get(ResultsHeaderCellLocators.addr1).should('contain', 'Address line 1'); + cy.get(ResultsHeaderCellLocators.postcode).should('contain', 'Postcode'); + cy.get(ResultsHeaderCellLocators.ni).should('contain', 'NI number'); + cy.get(ResultsHeaderCellLocators.pg).should('contain', 'Parent or guardian'); + cy.get(ResultsHeaderCellLocators.bu).should('contain', 'Business unit'); + cy.get(ResultsHeaderCellLocators.ref).should('contain', 'Ref'); + cy.get(ResultsHeaderCellLocators.enf).should('contain', 'ENF'); + cy.get(ResultsHeaderCellLocators.balance).should('contain', 'Balance'); + + cy.get(ResultsCellLocators.accountCell).first().should('contain', '13001BU'); + cy.get(ResultsCellLocators.accountCell).first().find('a').should('exist'); + cy.get(ResultsCellLocators.name).first().should('contain', 'SMITH, John Michael'); + cy.get(ResultsCellLocators.aliases).first().should('contain', 'SMITH, John Michael'); + cy.get(ResultsCellLocators.dob).first().should('contain', '01 Jun 1985'); + cy.get(ResultsCellLocators.addr1).first().should('contain', '1 High Street'); + cy.get(ResultsCellLocators.postcode).first().should('contain', 'RG1 9RT'); + cy.get(ResultsCellLocators.ni).first().should('contain', 'JK 56 78 90 C'); + cy.get(ResultsCellLocators.parentGuard).first().should('contain', 'DOE, Jane'); + cy.get(ResultsCellLocators.businessUnit).first().should('contain', 'Test Business Unit'); + cy.get(ResultsCellLocators.ref).first().should('contain', 'PCR19274548'); + cy.get(ResultsCellLocators.enf).first().should('contain', 'BWTD'); + cy.get(ResultsCellLocators.balance).first().should('contain', '£714.00'); + + cy.get(ResultsCellLocators.accountCell).eq(1).should('contain', '13002BU'); + cy.get(ResultsCellLocators.name).eq(1).should('contain', 'DOE, Jane'); + cy.get(ResultsCellLocators.dob).eq(1).should('contain', '15 Mar 1990'); + cy.get(ResultsCellLocators.enf).eq(1).should('contain', 'WARRANT'); + cy.get(ResultsCellLocators.balance).eq(1).should('contain', '£524.00'); + cy.get(ResultsCellLocators.aliases).eq(1).should('not.contain', 'SMITH'); + cy.get(ResultsCellLocators.parentGuard).eq(1).should('not.contain', 'DOE, Jane'); }, ); @@ -193,23 +197,23 @@ describe('FinesSaResultsComponent - All Account Types', () => { () => { setupComponent('WITH_DATA', 'companies'); - switchToTab('companies', INDIVIDUAL_DOM_ELEMENTS.companiesTab); - verifyTabIsActive(INDIVIDUAL_DOM_ELEMENTS.companiesTab); + switchToTab('companies', ResultsTabLocators.companiesTab); + verifyTabIsActive(ResultsTabLocators.companiesTab); // Verify table exists and headers match design - cy.get(INDIVIDUAL_DOM_ELEMENTS.tableWrapper).should('exist'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.accountHeader).should('contain', 'Account'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.addressHeader).should('contain', 'Address line 1'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.postcodeHeader).should('contain', 'Postcode'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.businessUnitHeader).should('contain', 'Business unit'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.refHeader).should('contain', 'Ref'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.enfHeader).should('contain', 'ENF'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.balanceHeader).should('contain', 'Balance'); + cy.get(ResultsLocators.table.root).should('exist'); + cy.get(ResultsHeaderCellLocators.account).should('contain', 'Account'); + cy.get(ResultsHeaderCellLocators.addr1).should('contain', 'Address line 1'); + cy.get(ResultsHeaderCellLocators.postcode).should('contain', 'Postcode'); + cy.get(ResultsHeaderCellLocators.bu).should('contain', 'Business unit'); + cy.get(ResultsHeaderCellLocators.ref).should('contain', 'Ref'); + cy.get(ResultsHeaderCellLocators.enf).should('contain', 'ENF'); + cy.get(ResultsHeaderCellLocators.balance).should('contain', 'Balance'); // Verify first row matches mock data - cy.get(INDIVIDUAL_DOM_ELEMENTS.nameCell).first().should('contain', 'ACME LTD'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.addressCell).first().should('contain', '10 Downing Street'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.balanceCell).first().should('contain', '£1,000.00'); + cy.get(ResultsCellLocators.name).first().should('contain', 'ACME LTD'); + cy.get(ResultsCellLocators.addr1).first().should('contain', '10 Downing Street'); + cy.get(ResultsCellLocators.balance).first().should('contain', '£1,000.00'); }, ); it( @@ -218,36 +222,36 @@ describe('FinesSaResultsComponent - All Account Types', () => { () => { setupComponent('WITH_DATA', 'individuals'); // Switch to minor creditors tab using helper function - switchToTab('minorCreditors', INDIVIDUAL_DOM_ELEMENTS.minorCreditorsTab); - verifyTabIsActive(INDIVIDUAL_DOM_ELEMENTS.minorCreditorsTab); + switchToTab('minorCreditors', ResultsTabLocators.minorCreditorsTab); + verifyTabIsActive(ResultsTabLocators.minorCreditorsTab); // Verify table headers for minor creditors - cy.get(INDIVIDUAL_DOM_ELEMENTS.accountHeader).should('contain', 'Account'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.nameHeader).should('contain', 'Name'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.addressHeader).should('contain', 'Address line 1'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.postcodeHeader).should('contain', 'Postcode'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.businessUnitHeader).should('contain', 'Business unit'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.defendantHeader).should('contain', 'Defendant'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.balanceHeader).should('contain', 'Balance'); + cy.get(ResultsHeaderCellLocators.account).should('contain', 'Account'); + cy.get(ResultsHeaderCellLocators.name).should('contain', 'Name'); + cy.get(ResultsHeaderCellLocators.addr1).should('contain', 'Address line 1'); + cy.get(ResultsHeaderCellLocators.postcode).should('contain', 'Postcode'); + cy.get(ResultsHeaderCellLocators.bu).should('contain', 'Business unit'); + cy.get(ResultsHeaderCellLocators.defendant).should('contain', 'Defendant'); + cy.get(ResultsHeaderCellLocators.balance).should('contain', 'Balance'); // Verify first row data matches mock - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.accountCell).first().should('contain', '14002MC'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.accountCell).first().find('a').should('exist'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.nameCell).first().should('contain', 'WILSON, James Robert'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.addressCell).first().should('contain', '8 Elm Street'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.postcodeCell).first().should('contain', 'MC3 5RT'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.businessUnitCell).first().should('contain', 'Minor Creditors Unit'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.defendantCell).first().should('contain', 'WILSON, James Robert'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.defendantCell).first().find('a').should('exist'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.balanceCell).first().should('contain', '£567.00'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).first().should('contain', '14002MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).first().find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorName).first().should('contain', 'WILSON, James Robert'); + cy.get(ResultsCellLocators.minorCreditorAddr1).first().should('contain', '8 Elm Street'); + cy.get(ResultsCellLocators.minorCreditorPostcode).first().should('contain', 'MC3 5RT'); + cy.get(ResultsCellLocators.minorCreditorBusinessUnit).first().should('contain', 'Minor Creditors Unit'); + cy.get(ResultsCellLocators.minorCreditorDefendant).first().should('contain', 'WILSON, James Robert'); + cy.get(ResultsCellLocators.minorCreditorDefendant).first().find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorBalance).first().should('contain', '£567.00'); // Verify second row data - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.accountCell).eq(1).should('contain', '14001MC'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.accountCell).eq(1).find('a').should('exist'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.nameCell).eq(1).should('contain', ' THOMPSON, Emma Claire '); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.addressCell).eq(1).should('contain', '5 Minor Court'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.postcodeCell).eq(1).should('contain', 'MC1 2RT'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.defendantCell).eq(1).should('contain', 'THOMPSON, Emma Claire'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.defendantCell).eq(1).find('a').should('exist'); - cy.get(MINOR_CREDITOR_DOM_ELEMENTS.balanceCell).eq(1).should('contain', '£345.00'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).eq(1).should('contain', '14001MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).eq(1).find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorName).eq(1).should('contain', ' THOMPSON, Emma Claire '); + cy.get(ResultsCellLocators.minorCreditorAddr1).eq(1).should('contain', '5 Minor Court'); + cy.get(ResultsCellLocators.minorCreditorPostcode).eq(1).should('contain', 'MC1 2RT'); + cy.get(ResultsCellLocators.minorCreditorDefendant).eq(1).should('contain', 'THOMPSON, Emma Claire'); + cy.get(ResultsCellLocators.minorCreditorDefendant).eq(1).find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorBalance).eq(1).should('contain', '£345.00'); }, ); @@ -259,9 +263,9 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('PARTIAL_RESULTS'); // Verify only individuals and companies tabs are shown - cy.get(INDIVIDUAL_DOM_ELEMENTS.individualsTab).should('be.visible'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.companiesTab).should('be.visible'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.minorCreditorsTab).should('not.exist'); + cy.get(ResultsTabLocators.individualsTab).should('be.visible'); + cy.get(ResultsTabLocators.companiesTab).should('be.visible'); + cy.get(ResultsTabLocators.minorCreditorsTab).should('not.exist'); }, ); @@ -272,9 +276,9 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('COMPANY_RESULTS_ONLY', 'companies'); // Verify companies tab is selected when individuals tab doesn't exist - cy.get(INDIVIDUAL_DOM_ELEMENTS.individualsTab).should('not.exist'); - verifyTabIsActive(INDIVIDUAL_DOM_ELEMENTS.companiesTab); - cy.get(INDIVIDUAL_DOM_ELEMENTS.tableWrapper).should('exist'); + cy.get(ResultsTabLocators.individualsTab).should('not.exist'); + verifyTabIsActive(ResultsTabLocators.companiesTab); + cy.get(ResultsLocators.table.root).should('exist'); }, ); @@ -284,9 +288,9 @@ describe('FinesSaResultsComponent - All Account Types', () => { () => { setupComponent('INDIVIDUALS_ONLY_RESULTS', 'individuals'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.individualsTab).should('be.visible'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.companiesTab).should('not.exist'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.minorCreditorsTab).should('not.exist'); + cy.get(ResultsTabLocators.individualsTab).should('be.visible'); + cy.get(ResultsTabLocators.companiesTab).should('not.exist'); + cy.get(ResultsTabLocators.minorCreditorsTab).should('not.exist'); }, ); @@ -296,9 +300,9 @@ describe('FinesSaResultsComponent - All Account Types', () => { () => { setupComponent('MINOR_CREDITOR_ONLY_RESULTS', 'minorCreditors'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.individualsTab).should('not.exist'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.companiesTab).should('not.exist'); - cy.get(INDIVIDUAL_DOM_ELEMENTS.minorCreditorsTab).should('be.visible'); + cy.get(ResultsTabLocators.individualsTab).should('not.exist'); + cy.get(ResultsTabLocators.companiesTab).should('not.exist'); + cy.get(ResultsTabLocators.minorCreditorsTab).should('be.visible'); }, ); }); diff --git a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsCompany.cy.ts b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsCompany.cy.ts index ada78eeffc..2d5e0494a7 100644 --- a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsCompany.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsCompany.cy.ts @@ -4,7 +4,7 @@ import { FinesSaStore } from '../../../../src/app/flows/fines/fines-sa/stores/fi import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { provideHttpClient } from '@angular/common/http'; -import { DOM_ELEMENTS } from './constants/search_results_individuals_elements'; +import { AccountEnquiryResultsLocators as ResultsLocators } from '../../../shared/selectors/account-enquiry/account.enquiry.results.locators'; import { EMPTY_SEARCH_RESULTS_MOCK, SEARCH_RESULTS_WITH_DATA_MOCK, @@ -16,6 +16,12 @@ import { COMPANY_SEARCH_STATE_MOCK } from '../searchAndMatches/mocks/search_and_ import { OpalFines } from '../../../../src/app/flows/fines/services/opal-fines-service/opal-fines.service'; const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; +const ResultsPageLocators = ResultsLocators.page; +const ResultsMessageLocators = ResultsLocators.messages; +const ResultsHeaderCellLocators = ResultsLocators.headerCells; +const ResultsHeaderButtonLocators = ResultsLocators.headers; +const ResultsCellLocators = ResultsLocators.cols; +const ResultsPaginationLocators = ResultsLocators.pagination; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; @@ -74,8 +80,8 @@ describe('FinesSaResultsComponent - Companies', () => { () => { setupComponent(); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); }, ); @@ -85,13 +91,13 @@ describe('FinesSaResultsComponent - Companies', () => { () => { setupComponent(EMPTY_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.noResultsHeading).should('contain', 'There are no matching results'); + cy.get(ResultsMessageLocators.noResultsHeading).should('contain', 'There are no matching results'); //(AC2b) Check your search link is clickable and functional // Test that the link is clickable (Full Test to be implemented when API complete) - cy.get(DOM_ELEMENTS.checkSearchLink).should('have.class', 'govuk-link'); - cy.get(DOM_ELEMENTS.checkSearchLink).should('be.visible').click(); - cy.get(DOM_ELEMENTS.checkSearchLink).should('contain', 'Check your search'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('have.class', 'govuk-link'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('be.visible').click(); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('contain', 'Check your search'); }, ); @@ -101,15 +107,15 @@ describe('FinesSaResultsComponent - Companies', () => { () => { setupComponent(LARGE_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.tooManyResultsHeading).should('contain', 'There are more than 100 results'); - cy.get(DOM_ELEMENTS.tableWrapper).should('not.exist'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('contain', 'Try adding more information'); - cy.get(DOM_ELEMENTS.tableWrapper).should('not.exist'); + cy.get(ResultsMessageLocators.tooManyResultsHeading).should('contain', 'There are more than 100 results'); + cy.get(ResultsLocators.table.root).should('not.exist'); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('contain', 'Try adding more information'); + cy.get(ResultsLocators.table.root).should('not.exist'); //(AC3b) Try adding more information link is clickable and functional // Test that the link is clickable (Full Test to be implemented when API complete) - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('have.class', 'govuk-link'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).click(); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('have.class', 'govuk-link'); + cy.get(ResultsMessageLocators.addMoreInfoLink).click(); }, ); @@ -120,19 +126,19 @@ describe('FinesSaResultsComponent - Companies', () => { setupComponent(SEARCH_RESULTS_WITH_DATA_MOCK); // Check table exists and headers match design - cy.get(DOM_ELEMENTS.tableWrapper).should('exist'); - cy.get(DOM_ELEMENTS.accountHeader).should('contain', 'Account'); - cy.get(DOM_ELEMENTS.addressHeader).should('contain', 'Address line 1'); - cy.get(DOM_ELEMENTS.postcodeHeader).should('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.businessUnitHeader).should('contain', 'Business unit'); - cy.get(DOM_ELEMENTS.refHeader).should('contain', 'Ref'); - cy.get(DOM_ELEMENTS.enfHeader).should('contain', 'ENF'); - cy.get(DOM_ELEMENTS.balanceHeader).should('contain', 'Balance'); + cy.get(ResultsLocators.table.root).should('exist'); + cy.get(ResultsHeaderCellLocators.account).should('contain', 'Account'); + cy.get(ResultsHeaderCellLocators.addr1).should('contain', 'Address line 1'); + cy.get(ResultsHeaderCellLocators.postcode).should('contain', 'Postcode'); + cy.get(ResultsHeaderCellLocators.bu).should('contain', 'Business unit'); + cy.get(ResultsHeaderCellLocators.ref).should('contain', 'Ref'); + cy.get(ResultsHeaderCellLocators.enf).should('contain', 'ENF'); + cy.get(ResultsHeaderCellLocators.balance).should('contain', 'Balance'); // Check first row matches mock data - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'ACME LTD'); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '10 Downing Street'); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£1,000.00'); + cy.get(ResultsCellLocators.name).first().should('contain', 'ACME LTD'); + cy.get(ResultsCellLocators.addr1).first().should('contain', '10 Downing Street'); + cy.get(ResultsCellLocators.balance).first().should('contain', '£1,000.00'); }, ); @@ -142,12 +148,12 @@ describe('FinesSaResultsComponent - Companies', () => { () => { setupComponent(PAGINATION_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.paginationElement).should('exist'); - cy.get(DOM_ELEMENTS.paginationText).should('contain', '100 total results'); - cy.get(DOM_ELEMENTS.table).should('have.length', 25); + cy.get(ResultsPaginationLocators.root).should('exist'); + cy.get(ResultsPaginationLocators.resultsText).should('contain', '100 total results'); + cy.get(ResultsLocators.table.rows).should('have.length', 25); - cy.get(DOM_ELEMENTS.paginationPageNumber(2)).click(); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '2'); + cy.get(ResultsPaginationLocators.pageNumber(2)).click(); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '2'); }, ); @@ -158,65 +164,65 @@ describe('FinesSaResultsComponent - Companies', () => { setupComponent(SORTING_SEARCH_RESULTS_MOCK_COMPANIES); // Default sort = order in the mock - cy.get(DOM_ELEMENTS.nameCell).eq(0).should('contain', 'ACME LTD'); - cy.get(DOM_ELEMENTS.nameCell).eq(1).should('contain', 'ZENITH CORP'); - cy.get(DOM_ELEMENTS.nameCell).eq(2).should('contain', 'BETA LTD'); - cy.get(DOM_ELEMENTS.nameCell).eq(3).should('contain', 'OMEGA INC'); - cy.get(DOM_ELEMENTS.nameCell).eq(4).should('contain', 'DELTA PLC'); - - cy.get(DOM_ELEMENTS.accountCell).eq(0).should('contain', '13006BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(1).should('contain', '13007BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(2).should('contain', '13008BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(3).should('contain', '13009BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(4).should('contain', '13010BU'); - - cy.get(DOM_ELEMENTS.postcodeCell).eq(0).should('contain', 'SW1A 2AA'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(1).should('contain', 'EC4Y 1AA'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(2).should('contain', 'NW1 6XE'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(3).should('contain', 'NE1 2DF'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(4).should('contain', 'L3 8GH'); - - cy.get(DOM_ELEMENTS.balanceCell).eq(0).should('contain', '£1,000.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(1).should('contain', '£1,200.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(2).should('contain', '£850.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(3).should('contain', '£675.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(4).should('contain', '£524.00'); + cy.get(ResultsCellLocators.name).eq(0).should('contain', 'ACME LTD'); + cy.get(ResultsCellLocators.name).eq(1).should('contain', 'ZENITH CORP'); + cy.get(ResultsCellLocators.name).eq(2).should('contain', 'BETA LTD'); + cy.get(ResultsCellLocators.name).eq(3).should('contain', 'OMEGA INC'); + cy.get(ResultsCellLocators.name).eq(4).should('contain', 'DELTA PLC'); + + cy.get(ResultsCellLocators.accountCell).eq(0).should('contain', '13006BU'); + cy.get(ResultsCellLocators.accountCell).eq(1).should('contain', '13007BU'); + cy.get(ResultsCellLocators.accountCell).eq(2).should('contain', '13008BU'); + cy.get(ResultsCellLocators.accountCell).eq(3).should('contain', '13009BU'); + cy.get(ResultsCellLocators.accountCell).eq(4).should('contain', '13010BU'); + + cy.get(ResultsCellLocators.postcode).eq(0).should('contain', 'SW1A 2AA'); + cy.get(ResultsCellLocators.postcode).eq(1).should('contain', 'EC4Y 1AA'); + cy.get(ResultsCellLocators.postcode).eq(2).should('contain', 'NW1 6XE'); + cy.get(ResultsCellLocators.postcode).eq(3).should('contain', 'NE1 2DF'); + cy.get(ResultsCellLocators.postcode).eq(4).should('contain', 'L3 8GH'); + + cy.get(ResultsCellLocators.balance).eq(0).should('contain', '£1,000.00'); + cy.get(ResultsCellLocators.balance).eq(1).should('contain', '£1,200.00'); + cy.get(ResultsCellLocators.balance).eq(2).should('contain', '£850.00'); + cy.get(ResultsCellLocators.balance).eq(3).should('contain', '£675.00'); + cy.get(ResultsCellLocators.balance).eq(4).should('contain', '£524.00'); // Account column sorting - cy.get(DOM_ELEMENTS.accountHeader).find('button').click(); // Ascending - cy.get(DOM_ELEMENTS.accountCell).eq(0).should('contain', '13006BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(4).should('contain', '13010BU'); + cy.get(ResultsHeaderButtonLocators.account).click(); // Ascending + cy.get(ResultsCellLocators.accountCell).eq(0).should('contain', '13006BU'); + cy.get(ResultsCellLocators.accountCell).eq(4).should('contain', '13010BU'); - cy.get(DOM_ELEMENTS.accountHeader).find('button').click(); // Descending - cy.get(DOM_ELEMENTS.accountCell).eq(0).should('contain', '13010BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(4).should('contain', '13006BU'); + cy.get(ResultsHeaderButtonLocators.account).click(); // Descending + cy.get(ResultsCellLocators.accountCell).eq(0).should('contain', '13010BU'); + cy.get(ResultsCellLocators.accountCell).eq(4).should('contain', '13006BU'); // Name column sorting - cy.get(DOM_ELEMENTS.nameHeader).find('button').click(); // Ascending - cy.get(DOM_ELEMENTS.nameCell).eq(0).should('contain', 'ACME LTD'); - cy.get(DOM_ELEMENTS.nameCell).eq(4).should('contain', 'ZENITH CORP'); + cy.get(ResultsHeaderButtonLocators.name).click(); // Ascending + cy.get(ResultsCellLocators.name).eq(0).should('contain', 'ACME LTD'); + cy.get(ResultsCellLocators.name).eq(4).should('contain', 'ZENITH CORP'); - cy.get(DOM_ELEMENTS.nameHeader).find('button').click(); // Descending - cy.get(DOM_ELEMENTS.nameCell).eq(0).should('contain', 'ZENITH CORP'); - cy.get(DOM_ELEMENTS.nameCell).eq(4).should('contain', 'ACME LTD'); + cy.get(ResultsHeaderButtonLocators.name).click(); // Descending + cy.get(ResultsCellLocators.name).eq(0).should('contain', 'ZENITH CORP'); + cy.get(ResultsCellLocators.name).eq(4).should('contain', 'ACME LTD'); // Postcode column sorting - cy.get(DOM_ELEMENTS.postcodeHeader).find('button').click(); // Ascending - cy.get(DOM_ELEMENTS.postcodeCell).eq(0).should('contain', 'EC4Y 1AA'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(4).should('contain', 'SW1A 2AA'); + cy.get(ResultsHeaderButtonLocators.postcode).click(); // Ascending + cy.get(ResultsCellLocators.postcode).eq(0).should('contain', 'EC4Y 1AA'); + cy.get(ResultsCellLocators.postcode).eq(4).should('contain', 'SW1A 2AA'); - cy.get(DOM_ELEMENTS.postcodeHeader).find('button').click(); // Descending - cy.get(DOM_ELEMENTS.postcodeCell).eq(0).should('contain', 'SW1A 2AA'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(4).should('contain', 'EC4Y 1AA'); + cy.get(ResultsHeaderButtonLocators.postcode).click(); // Descending + cy.get(ResultsCellLocators.postcode).eq(0).should('contain', 'SW1A 2AA'); + cy.get(ResultsCellLocators.postcode).eq(4).should('contain', 'EC4Y 1AA'); // Balance column sorting - cy.get(DOM_ELEMENTS.balanceHeader).find('button').click(); // Ascending - cy.get(DOM_ELEMENTS.balanceCell).eq(0).should('contain', '£524.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(4).should('contain', '£1,200.00'); + cy.get(ResultsHeaderButtonLocators.balance).click(); // Ascending + cy.get(ResultsCellLocators.balance).eq(0).should('contain', '£524.00'); + cy.get(ResultsCellLocators.balance).eq(4).should('contain', '£1,200.00'); - cy.get(DOM_ELEMENTS.balanceHeader).find('button').click(); // Descending - cy.get(DOM_ELEMENTS.balanceCell).eq(0).should('contain', '£1,200.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(4).should('contain', '£524.00'); + cy.get(ResultsHeaderButtonLocators.balance).click(); // Descending + cy.get(ResultsCellLocators.balance).eq(0).should('contain', '£1,200.00'); + cy.get(ResultsCellLocators.balance).eq(4).should('contain', '£524.00'); }, ); }); diff --git a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsIndividuals.cy.ts b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsIndividuals.cy.ts index 2c34cb7f8e..1350e61300 100644 --- a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsIndividuals.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsIndividuals.cy.ts @@ -4,7 +4,7 @@ import { FinesSaStore } from '../../../../src/app/flows/fines/fines-sa/stores/fi import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { provideHttpClient } from '@angular/common/http'; -import { DOM_ELEMENTS } from './constants/search_results_individuals_elements'; +import { AccountEnquiryResultsLocators as ResultsLocators } from '../../../shared/selectors/account-enquiry/account.enquiry.results.locators'; import { EMPTY_SEARCH_RESULTS_MOCK, SEARCH_RESULTS_WITH_DATA_MOCK, @@ -16,6 +16,12 @@ import { INDIVIDUAL_SEARCH_STATE_MOCK } from '../searchAndMatches/mocks/search_a import { OpalFines } from '../../../../src/app/flows/fines/services/opal-fines-service/opal-fines.service'; const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; +const ResultsPageLocators = ResultsLocators.page; +const ResultsMessageLocators = ResultsLocators.messages; +const ResultsHeaderCellLocators = ResultsLocators.headerCells; +const ResultsHeaderButtonLocators = ResultsLocators.headers; +const ResultsCellLocators = ResultsLocators.cols; +const ResultsPaginationLocators = ResultsLocators.pagination; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; @@ -74,8 +80,8 @@ describe('FinesSaResultsComponent - Individuals', () => { () => { setupComponent(); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); }, ); @@ -85,15 +91,15 @@ describe('FinesSaResultsComponent - Individuals', () => { () => { setupComponent(EMPTY_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.noResultsHeading).should('be.visible'); - cy.get(DOM_ELEMENTS.noResultsHeading).should('contain', 'There are no matching results'); + cy.get(ResultsMessageLocators.noResultsHeading).should('be.visible'); + cy.get(ResultsMessageLocators.noResultsHeading).should('contain', 'There are no matching results'); - cy.get(DOM_ELEMENTS.checkSearchLink).should('be.visible'); - cy.get(DOM_ELEMENTS.checkSearchLink).should('contain', 'Check your search'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('be.visible'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('contain', 'Check your search'); //(AC2b) Check your search link is clickable and functional // Test that the link is clickable (Full Test to be implemented when API complete) - cy.get(DOM_ELEMENTS.checkSearchLink).should('have.class', 'govuk-link'); - cy.get(DOM_ELEMENTS.checkSearchLink).click(); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('have.class', 'govuk-link'); + cy.get(ResultsMessageLocators.checkYourSearchLink).click(); }, ); @@ -103,22 +109,22 @@ describe('FinesSaResultsComponent - Individuals', () => { () => { setupComponent(LARGE_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); // Should show too many results message when more than 100 results - cy.get(DOM_ELEMENTS.tooManyResultsHeading).should('be.visible'); - cy.get(DOM_ELEMENTS.tooManyResultsHeading).should('contain', 'There are more than 100 results'); + cy.get(ResultsMessageLocators.tooManyResultsHeading).should('be.visible'); + cy.get(ResultsMessageLocators.tooManyResultsHeading).should('contain', 'There are more than 100 results'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('be.visible'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('contain', 'Try adding more information'); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('be.visible'); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('contain', 'Try adding more information'); - cy.get(DOM_ELEMENTS.tableWrapper).should('not.exist'); + cy.get(ResultsLocators.table.root).should('not.exist'); //(AC3b) Try adding more information link is clickable and functional // Test that the link is clickable (Full Test to be implemented when API complete) - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('have.class', 'govuk-link'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).click(); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('have.class', 'govuk-link'); + cy.get(ResultsMessageLocators.addMoreInfoLink).click(); }, ); @@ -128,60 +134,60 @@ describe('FinesSaResultsComponent - Individuals', () => { () => { setupComponent(SEARCH_RESULTS_WITH_DATA_MOCK); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); - cy.get(DOM_ELEMENTS.tableWrapper).should('exist'); + cy.get(ResultsLocators.table.root).should('exist'); // Verify all column headers are present (AC4 requirements) - cy.get(DOM_ELEMENTS.accountHeader).should('contain', 'Account'); - cy.get(DOM_ELEMENTS.nameHeader).should('contain', 'Name'); - cy.get(DOM_ELEMENTS.aliasesHeader).should('contain', 'Aliases'); - cy.get(DOM_ELEMENTS.dobHeader).should('contain', 'Date of birth'); - cy.get(DOM_ELEMENTS.addressHeader).should('contain', 'Address line 1'); - cy.get(DOM_ELEMENTS.postcodeHeader).should('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.niNumberHeader).should('contain', 'NI number'); - cy.get(DOM_ELEMENTS.parentGuardianHeader).should('contain', 'Parent or guardian'); - cy.get(DOM_ELEMENTS.businessUnitHeader).should('contain', 'Business unit'); - cy.get(DOM_ELEMENTS.refHeader).should('contain', 'Ref'); - cy.get(DOM_ELEMENTS.enfHeader).should('contain', 'ENF'); - cy.get(DOM_ELEMENTS.balanceHeader).should('contain', 'Balance'); + cy.get(ResultsHeaderCellLocators.account).should('contain', 'Account'); + cy.get(ResultsHeaderCellLocators.name).should('contain', 'Name'); + cy.get(ResultsHeaderCellLocators.aliases).should('contain', 'Aliases'); + cy.get(ResultsHeaderCellLocators.dob).should('contain', 'Date of birth'); + cy.get(ResultsHeaderCellLocators.addr1).should('contain', 'Address line 1'); + cy.get(ResultsHeaderCellLocators.postcode).should('contain', 'Postcode'); + cy.get(ResultsHeaderCellLocators.ni).should('contain', 'NI number'); + cy.get(ResultsHeaderCellLocators.pg).should('contain', 'Parent or guardian'); + cy.get(ResultsHeaderCellLocators.bu).should('contain', 'Business unit'); + cy.get(ResultsHeaderCellLocators.ref).should('contain', 'Ref'); + cy.get(ResultsHeaderCellLocators.enf).should('contain', 'ENF'); + cy.get(ResultsHeaderCellLocators.balance).should('contain', 'Balance'); // Verify data is displayed correctly (AC4 field requirements) - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '13001BU'); - cy.get(DOM_ELEMENTS.accountCell).first().find('a').should('exist'); + cy.get(ResultsCellLocators.accountCell).first().should('contain', '13001BU'); + cy.get(ResultsCellLocators.accountCell).first().find('a').should('exist'); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'SMITH, John Michael'); + cy.get(ResultsCellLocators.name).first().should('contain', 'SMITH, John Michael'); - cy.get(DOM_ELEMENTS.aliasesCell).first().should('contain', 'SMITH, John Michael'); + cy.get(ResultsCellLocators.aliases).first().should('contain', 'SMITH, John Michael'); - cy.get(DOM_ELEMENTS.dobCell).first().should('contain', '01 Jun 1985'); + cy.get(ResultsCellLocators.dob).first().should('contain', '01 Jun 1985'); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '1 High Street'); + cy.get(ResultsCellLocators.addr1).first().should('contain', '1 High Street'); - cy.get(DOM_ELEMENTS.postcodeCell).first().should('contain', 'RG1 9RT'); + cy.get(ResultsCellLocators.postcode).first().should('contain', 'RG1 9RT'); - cy.get(DOM_ELEMENTS.niNumberCell).first().should('contain', 'JK 56 78 90 C'); + cy.get(ResultsCellLocators.ni).first().should('contain', 'JK 56 78 90 C'); - cy.get(DOM_ELEMENTS.parentGuardianCell).first().should('contain', 'DOE, Jane'); + cy.get(ResultsCellLocators.parentGuard).first().should('contain', 'DOE, Jane'); - cy.get(DOM_ELEMENTS.businessUnitCell).first().should('contain', 'Test Business Unit'); + cy.get(ResultsCellLocators.businessUnit).first().should('contain', 'Test Business Unit'); - cy.get(DOM_ELEMENTS.refCell).first().should('contain', 'PCR19274548'); + cy.get(ResultsCellLocators.ref).first().should('contain', 'PCR19274548'); - cy.get(DOM_ELEMENTS.enfCell).first().should('contain', 'BWTD'); + cy.get(ResultsCellLocators.enf).first().should('contain', 'BWTD'); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£714.00'); + cy.get(ResultsCellLocators.balance).first().should('contain', '£714.00'); - cy.get(DOM_ELEMENTS.accountCell).eq(1).should('contain', '13002BU'); - cy.get(DOM_ELEMENTS.nameCell).eq(1).should('contain', 'DOE, Jane'); - cy.get(DOM_ELEMENTS.dobCell).eq(1).should('contain', '15 Mar 1990'); - cy.get(DOM_ELEMENTS.enfCell).eq(1).should('contain', 'WARRANT'); - cy.get(DOM_ELEMENTS.balanceCell).eq(1).should('contain', '£524.00'); + cy.get(ResultsCellLocators.accountCell).eq(1).should('contain', '13002BU'); + cy.get(ResultsCellLocators.name).eq(1).should('contain', 'DOE, Jane'); + cy.get(ResultsCellLocators.dob).eq(1).should('contain', '15 Mar 1990'); + cy.get(ResultsCellLocators.enf).eq(1).should('contain', 'WARRANT'); + cy.get(ResultsCellLocators.balance).eq(1).should('contain', '£524.00'); - cy.get(DOM_ELEMENTS.aliasesCell).eq(1).should('not.contain', 'SMITH'); + cy.get(ResultsCellLocators.aliases).eq(1).should('not.contain', 'SMITH'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(1).should('not.contain', 'DOE, Jane'); + cy.get(ResultsCellLocators.parentGuard).eq(1).should('not.contain', 'DOE, Jane'); }, ); @@ -191,68 +197,68 @@ describe('FinesSaResultsComponent - Individuals', () => { () => { setupComponent(PAGINATION_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); - cy.get(DOM_ELEMENTS.tableWrapper).should('exist'); + cy.get(ResultsLocators.table.root).should('exist'); - cy.get(DOM_ELEMENTS.paginationElement).should('exist'); + cy.get(ResultsPaginationLocators.root).should('exist'); // Verify pagination text shows correct total results - cy.get(DOM_ELEMENTS.paginationText).should('contain', '100 total results'); + cy.get(ResultsPaginationLocators.resultsText).should('contain', '100 total results'); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '1'); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '1'); - cy.get(DOM_ELEMENTS.paginationList).within(() => { - cy.get(DOM_ELEMENTS.paginationListItem).should('have.length.at.least', 4); + cy.get(ResultsPaginationLocators.list).within(() => { + cy.get(ResultsPaginationLocators.listItem).should('have.length.at.least', 4); cy.contains('1').should('exist'); cy.contains('2').should('exist'); - cy.get(DOM_ELEMENTS.paginationListItemEllipses).should('exist'); + cy.get(ResultsPaginationLocators.listItemEllipses).should('exist'); cy.contains('4').should('exist'); }); // Verify exactly 25 results are displayed - cy.get(DOM_ELEMENTS.table).should('have.length', 25); + cy.get(ResultsLocators.table.rows).should('have.length', 25); - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '1300001BU'); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'SMITH1, John'); + cy.get(ResultsCellLocators.accountCell).first().should('contain', '1300001BU'); + cy.get(ResultsCellLocators.name).first().should('contain', 'SMITH1, John'); - cy.get(DOM_ELEMENTS.accountCell).eq(24).should('contain', '1300025BU'); - cy.get(DOM_ELEMENTS.nameCell).eq(24).should('contain', 'SMITH25, John'); + cy.get(ResultsCellLocators.accountCell).eq(24).should('contain', '1300025BU'); + cy.get(ResultsCellLocators.name).eq(24).should('contain', 'SMITH25, John'); - cy.get(DOM_ELEMENTS.paginationPageNumber(2)).click(); + cy.get(ResultsPaginationLocators.pageNumber(2)).click(); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '2'); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '2'); - cy.get(DOM_ELEMENTS.table).should('have.length', 25); + cy.get(ResultsLocators.table.rows).should('have.length', 25); - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '1300026BU'); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'SMITH26, Jane'); + cy.get(ResultsCellLocators.accountCell).first().should('contain', '1300026BU'); + cy.get(ResultsCellLocators.name).first().should('contain', 'SMITH26, Jane'); - cy.get(DOM_ELEMENTS.paginationPageNumber(4)).click(); + cy.get(ResultsPaginationLocators.pageNumber(4)).click(); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '4'); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '4'); - cy.get(DOM_ELEMENTS.table).should('have.length', 25); + cy.get(ResultsLocators.table.rows).should('have.length', 25); - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '1300076BU'); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'SMITH76, Jane'); + cy.get(ResultsCellLocators.accountCell).first().should('contain', '1300076BU'); + cy.get(ResultsCellLocators.name).first().should('contain', 'SMITH76, Jane'); - cy.get(DOM_ELEMENTS.accountCell).eq(24).should('contain', '1300100BU'); - cy.get(DOM_ELEMENTS.nameCell).eq(24).should('contain', 'SMITH100, Jane'); + cy.get(ResultsCellLocators.accountCell).eq(24).should('contain', '1300100BU'); + cy.get(ResultsCellLocators.name).eq(24).should('contain', 'SMITH100, Jane'); - cy.get(DOM_ELEMENTS.previousPageButton).should('exist'); + cy.get(ResultsPaginationLocators.previousButton).should('exist'); // Should not exist on last page - cy.get(DOM_ELEMENTS.nextPageButton).should('not.exist'); + cy.get(ResultsPaginationLocators.nextButton).should('not.exist'); // Navigate back to page 1 using Previous button - cy.get(DOM_ELEMENTS.previousPageButton).click(); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '3'); + cy.get(ResultsPaginationLocators.previousButton).click(); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '3'); // Navigate to page 2 using Next button - cy.get(DOM_ELEMENTS.nextPageButton).should('exist'); - cy.get(DOM_ELEMENTS.nextPageButton).click(); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '4'); + cy.get(ResultsPaginationLocators.nextButton).should('exist'); + cy.get(ResultsPaginationLocators.nextButton).click(); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '4'); }, ); @@ -263,194 +269,194 @@ describe('FinesSaResultsComponent - Individuals', () => { setupComponent(SORTING_SEARCH_RESULTS_MOCK); //Account column sorting - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '13003BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(1).should('contain', '13001BU'); + cy.get(ResultsCellLocators.accountCell).first().should('contain', '13003BU'); + cy.get(ResultsCellLocators.accountCell).eq(1).should('contain', '13001BU'); - cy.get(DOM_ELEMENTS.accountHeader).click(); + cy.get(ResultsHeaderButtonLocators.account).click(); - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '13001BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(1).should('contain', '13002BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(2).should('contain', '13003BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(3).should('contain', '13004BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(4).should('contain', '13005BU'); + cy.get(ResultsCellLocators.accountCell).first().should('contain', '13001BU'); + cy.get(ResultsCellLocators.accountCell).eq(1).should('contain', '13002BU'); + cy.get(ResultsCellLocators.accountCell).eq(2).should('contain', '13003BU'); + cy.get(ResultsCellLocators.accountCell).eq(3).should('contain', '13004BU'); + cy.get(ResultsCellLocators.accountCell).eq(4).should('contain', '13005BU'); - cy.get(DOM_ELEMENTS.accountHeader).click(); + cy.get(ResultsHeaderButtonLocators.account).click(); - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '13005BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(1).should('contain', '13004BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(2).should('contain', '13003BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(3).should('contain', '13002BU'); - cy.get(DOM_ELEMENTS.accountCell).eq(4).should('contain', '13001BU'); + cy.get(ResultsCellLocators.accountCell).first().should('contain', '13005BU'); + cy.get(ResultsCellLocators.accountCell).eq(1).should('contain', '13004BU'); + cy.get(ResultsCellLocators.accountCell).eq(2).should('contain', '13003BU'); + cy.get(ResultsCellLocators.accountCell).eq(3).should('contain', '13002BU'); + cy.get(ResultsCellLocators.accountCell).eq(4).should('contain', '13001BU'); // Name column sorting - cy.get(DOM_ELEMENTS.nameHeader).find('button').click(); + cy.get(ResultsHeaderButtonLocators.name).click(); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'ANDERSON, Lisa Marie'); - cy.get(DOM_ELEMENTS.nameCell).eq(1).should('contain', 'BROWN, David Paul'); - cy.get(DOM_ELEMENTS.nameCell).eq(2).should('contain', 'JOHNSON, Emily Rose'); - cy.get(DOM_ELEMENTS.nameCell).eq(3).should('contain', 'SMITH, John Michael'); - cy.get(DOM_ELEMENTS.nameCell).eq(4).should('contain', 'WILLIAMS, Sarah Jane'); + cy.get(ResultsCellLocators.name).first().should('contain', 'ANDERSON, Lisa Marie'); + cy.get(ResultsCellLocators.name).eq(1).should('contain', 'BROWN, David Paul'); + cy.get(ResultsCellLocators.name).eq(2).should('contain', 'JOHNSON, Emily Rose'); + cy.get(ResultsCellLocators.name).eq(3).should('contain', 'SMITH, John Michael'); + cy.get(ResultsCellLocators.name).eq(4).should('contain', 'WILLIAMS, Sarah Jane'); - cy.get(DOM_ELEMENTS.nameHeader).find('button').click(); + cy.get(ResultsHeaderButtonLocators.name).click(); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'WILLIAMS, Sarah Jane'); - cy.get(DOM_ELEMENTS.nameCell).eq(1).should('contain', 'SMITH, John Michael'); - cy.get(DOM_ELEMENTS.nameCell).eq(2).should('contain', 'JOHNSON, Emily Rose'); - cy.get(DOM_ELEMENTS.nameCell).eq(3).should('contain', 'BROWN, David Paul'); - cy.get(DOM_ELEMENTS.nameCell).eq(4).should('contain', 'ANDERSON, Lisa Marie'); + cy.get(ResultsCellLocators.name).first().should('contain', 'WILLIAMS, Sarah Jane'); + cy.get(ResultsCellLocators.name).eq(1).should('contain', 'SMITH, John Michael'); + cy.get(ResultsCellLocators.name).eq(2).should('contain', 'JOHNSON, Emily Rose'); + cy.get(ResultsCellLocators.name).eq(3).should('contain', 'BROWN, David Paul'); + cy.get(ResultsCellLocators.name).eq(4).should('contain', 'ANDERSON, Lisa Marie'); // DOB column sorting - cy.get(DOM_ELEMENTS.dobHeader).click(); + cy.get(ResultsHeaderButtonLocators.dob).click(); - cy.get(DOM_ELEMENTS.dobCell).first().should('contain', '08 Nov 1975'); - cy.get(DOM_ELEMENTS.dobCell).eq(1).should('contain', '12 Sep 1982'); - cy.get(DOM_ELEMENTS.dobCell).eq(2).should('contain', '01 Jun 1985'); - cy.get(DOM_ELEMENTS.dobCell).eq(3).should('contain', '25 Dec 1988'); - cy.get(DOM_ELEMENTS.dobCell).eq(4).should('contain', '15 Mar 1990'); + cy.get(ResultsCellLocators.dob).first().should('contain', '08 Nov 1975'); + cy.get(ResultsCellLocators.dob).eq(1).should('contain', '12 Sep 1982'); + cy.get(ResultsCellLocators.dob).eq(2).should('contain', '01 Jun 1985'); + cy.get(ResultsCellLocators.dob).eq(3).should('contain', '25 Dec 1988'); + cy.get(ResultsCellLocators.dob).eq(4).should('contain', '15 Mar 1990'); - cy.get(DOM_ELEMENTS.dobHeader).click(); + cy.get(ResultsHeaderButtonLocators.dob).click(); - cy.get(DOM_ELEMENTS.dobCell).first().should('contain', '15 Mar 1990'); - cy.get(DOM_ELEMENTS.dobCell).eq(1).should('contain', '25 Dec 1988'); - cy.get(DOM_ELEMENTS.dobCell).eq(2).should('contain', '01 Jun 1985'); - cy.get(DOM_ELEMENTS.dobCell).eq(3).should('contain', '12 Sep 1982'); - cy.get(DOM_ELEMENTS.dobCell).eq(4).should('contain', '08 Nov 1975'); + cy.get(ResultsCellLocators.dob).first().should('contain', '15 Mar 1990'); + cy.get(ResultsCellLocators.dob).eq(1).should('contain', '25 Dec 1988'); + cy.get(ResultsCellLocators.dob).eq(2).should('contain', '01 Jun 1985'); + cy.get(ResultsCellLocators.dob).eq(3).should('contain', '12 Sep 1982'); + cy.get(ResultsCellLocators.dob).eq(4).should('contain', '08 Nov 1975'); // Address line 1 column sorting - cy.get(DOM_ELEMENTS.addressHeader).click(); + cy.get(ResultsHeaderButtonLocators.addr1).click(); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '1 High Street'); - cy.get(DOM_ELEMENTS.addressCell).eq(1).should('contain', '15 Oak Street'); - cy.get(DOM_ELEMENTS.addressCell).eq(2).should('contain', '22 Victoria Road'); - cy.get(DOM_ELEMENTS.addressCell).eq(3).should('contain', '5 Church Lane'); - cy.get(DOM_ELEMENTS.addressCell).eq(4).should('contain', '8 Park Avenue'); + cy.get(ResultsCellLocators.addr1).first().should('contain', '1 High Street'); + cy.get(ResultsCellLocators.addr1).eq(1).should('contain', '15 Oak Street'); + cy.get(ResultsCellLocators.addr1).eq(2).should('contain', '22 Victoria Road'); + cy.get(ResultsCellLocators.addr1).eq(3).should('contain', '5 Church Lane'); + cy.get(ResultsCellLocators.addr1).eq(4).should('contain', '8 Park Avenue'); - cy.get(DOM_ELEMENTS.addressHeader).click(); + cy.get(ResultsHeaderButtonLocators.addr1).click(); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '8 Park Avenue'); - cy.get(DOM_ELEMENTS.addressCell).eq(1).should('contain', '5 Church Lane'); - cy.get(DOM_ELEMENTS.addressCell).eq(2).should('contain', '22 Victoria Road'); - cy.get(DOM_ELEMENTS.addressCell).eq(3).should('contain', '15 Oak Street'); - cy.get(DOM_ELEMENTS.addressCell).eq(4).should('contain', '1 High Street'); + cy.get(ResultsCellLocators.addr1).first().should('contain', '8 Park Avenue'); + cy.get(ResultsCellLocators.addr1).eq(1).should('contain', '5 Church Lane'); + cy.get(ResultsCellLocators.addr1).eq(2).should('contain', '22 Victoria Road'); + cy.get(ResultsCellLocators.addr1).eq(3).should('contain', '15 Oak Street'); + cy.get(ResultsCellLocators.addr1).eq(4).should('contain', '1 High Street'); // Postcode column sorting - cy.get(DOM_ELEMENTS.postcodeHeader).click(); + cy.get(ResultsHeaderButtonLocators.postcode).click(); - cy.get(DOM_ELEMENTS.postcodeCell).first().should('contain', 'B2 4TY'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(1).should('contain', 'L3 8GH'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(2).should('contain', 'M1 5AB'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(3).should('contain', 'NE1 2DF'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(4).should('contain', 'RG1 9RT'); + cy.get(ResultsCellLocators.postcode).first().should('contain', 'B2 4TY'); + cy.get(ResultsCellLocators.postcode).eq(1).should('contain', 'L3 8GH'); + cy.get(ResultsCellLocators.postcode).eq(2).should('contain', 'M1 5AB'); + cy.get(ResultsCellLocators.postcode).eq(3).should('contain', 'NE1 2DF'); + cy.get(ResultsCellLocators.postcode).eq(4).should('contain', 'RG1 9RT'); - cy.get(DOM_ELEMENTS.postcodeHeader).click(); + cy.get(ResultsHeaderButtonLocators.postcode).click(); - cy.get(DOM_ELEMENTS.postcodeCell).first().should('contain', 'RG1 9RT'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(1).should('contain', 'NE1 2DF'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(2).should('contain', 'M1 5AB'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(3).should('contain', 'L3 8GH'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(4).should('contain', 'B2 4TY'); + cy.get(ResultsCellLocators.postcode).first().should('contain', 'RG1 9RT'); + cy.get(ResultsCellLocators.postcode).eq(1).should('contain', 'NE1 2DF'); + cy.get(ResultsCellLocators.postcode).eq(2).should('contain', 'M1 5AB'); + cy.get(ResultsCellLocators.postcode).eq(3).should('contain', 'L3 8GH'); + cy.get(ResultsCellLocators.postcode).eq(4).should('contain', 'B2 4TY'); // NI number column sorting - cy.get(DOM_ELEMENTS.niNumberHeader).click(); + cy.get(ResultsHeaderButtonLocators.ni).click(); - cy.get(DOM_ELEMENTS.niNumberCell).first().should('contain', 'AB 12 34 56 C'); - cy.get(DOM_ELEMENTS.niNumberCell).eq(1).should('contain', 'CD 78 90 12 E'); - cy.get(DOM_ELEMENTS.niNumberCell).eq(2).should('contain', 'EF 34 56 78 G'); - cy.get(DOM_ELEMENTS.niNumberCell).eq(3).should('contain', 'GH 90 12 34 H'); - cy.get(DOM_ELEMENTS.niNumberCell).eq(4).should('contain', 'JK 56 78 90 C'); + cy.get(ResultsCellLocators.ni).first().should('contain', 'AB 12 34 56 C'); + cy.get(ResultsCellLocators.ni).eq(1).should('contain', 'CD 78 90 12 E'); + cy.get(ResultsCellLocators.ni).eq(2).should('contain', 'EF 34 56 78 G'); + cy.get(ResultsCellLocators.ni).eq(3).should('contain', 'GH 90 12 34 H'); + cy.get(ResultsCellLocators.ni).eq(4).should('contain', 'JK 56 78 90 C'); - cy.get(DOM_ELEMENTS.niNumberHeader).click(); + cy.get(ResultsHeaderButtonLocators.ni).click(); - cy.get(DOM_ELEMENTS.niNumberCell).first().should('contain', 'JK 56 78 90 C'); - cy.get(DOM_ELEMENTS.niNumberCell).eq(1).should('contain', 'GH 90 12 34 H'); - cy.get(DOM_ELEMENTS.niNumberCell).eq(2).should('contain', 'EF 34 56 78 G'); - cy.get(DOM_ELEMENTS.niNumberCell).eq(3).should('contain', 'CD 78 90 12 E'); - cy.get(DOM_ELEMENTS.niNumberCell).eq(4).should('contain', 'AB 12 34 56 C'); + cy.get(ResultsCellLocators.ni).first().should('contain', 'JK 56 78 90 C'); + cy.get(ResultsCellLocators.ni).eq(1).should('contain', 'GH 90 12 34 H'); + cy.get(ResultsCellLocators.ni).eq(2).should('contain', 'EF 34 56 78 G'); + cy.get(ResultsCellLocators.ni).eq(3).should('contain', 'CD 78 90 12 E'); + cy.get(ResultsCellLocators.ni).eq(4).should('contain', 'AB 12 34 56 C'); // Parent or guardian column sorting - cy.get(DOM_ELEMENTS.parentGuardianHeader).click(); + cy.get(ResultsHeaderButtonLocators.pg).click(); - cy.get(DOM_ELEMENTS.parentGuardianCell).first().should('contain', 'BROWN, Michael'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(1).should('contain', 'DOE, Jane'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(2).should('contain', 'TAYLOR, Susan'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(3).should('contain', '—'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(4).should('contain', '—'); + cy.get(ResultsCellLocators.parentGuard).first().should('contain', 'BROWN, Michael'); + cy.get(ResultsCellLocators.parentGuard).eq(1).should('contain', 'DOE, Jane'); + cy.get(ResultsCellLocators.parentGuard).eq(2).should('contain', 'TAYLOR, Susan'); + cy.get(ResultsCellLocators.parentGuard).eq(3).should('contain', '—'); + cy.get(ResultsCellLocators.parentGuard).eq(4).should('contain', '—'); - cy.get(DOM_ELEMENTS.parentGuardianHeader).click(); + cy.get(ResultsHeaderButtonLocators.pg).click(); - cy.get(DOM_ELEMENTS.parentGuardianCell).first().should('contain', 'TAYLOR, Susan'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(1).should('contain', 'DOE, Jane'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(2).should('contain', 'BROWN, Michael'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(3).should('contain', '—'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(4).should('contain', '—'); + cy.get(ResultsCellLocators.parentGuard).first().should('contain', 'TAYLOR, Susan'); + cy.get(ResultsCellLocators.parentGuard).eq(1).should('contain', 'DOE, Jane'); + cy.get(ResultsCellLocators.parentGuard).eq(2).should('contain', 'BROWN, Michael'); + cy.get(ResultsCellLocators.parentGuard).eq(3).should('contain', '—'); + cy.get(ResultsCellLocators.parentGuard).eq(4).should('contain', '—'); // Business unit column sorting - cy.get(DOM_ELEMENTS.businessUnitHeader).click(); + cy.get(ResultsHeaderButtonLocators.bu).click(); - cy.get(DOM_ELEMENTS.businessUnitCell).first().should('contain', 'Birmingham Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(1).should('contain', 'Liverpool Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(2).should('contain', 'Manchester Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(3).should('contain', 'Newcastle Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(4).should('contain', 'Reading Unit'); + cy.get(ResultsCellLocators.businessUnit).first().should('contain', 'Birmingham Unit'); + cy.get(ResultsCellLocators.businessUnit).eq(1).should('contain', 'Liverpool Unit'); + cy.get(ResultsCellLocators.businessUnit).eq(2).should('contain', 'Manchester Unit'); + cy.get(ResultsCellLocators.businessUnit).eq(3).should('contain', 'Newcastle Unit'); + cy.get(ResultsCellLocators.businessUnit).eq(4).should('contain', 'Reading Unit'); - cy.get(DOM_ELEMENTS.businessUnitHeader).click(); + cy.get(ResultsHeaderButtonLocators.bu).click(); - cy.get(DOM_ELEMENTS.businessUnitCell).first().should('contain', 'Reading Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(1).should('contain', 'Newcastle Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(2).should('contain', 'Manchester Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(3).should('contain', 'Liverpool Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(4).should('contain', 'Birmingham Unit'); + cy.get(ResultsCellLocators.businessUnit).first().should('contain', 'Reading Unit'); + cy.get(ResultsCellLocators.businessUnit).eq(1).should('contain', 'Newcastle Unit'); + cy.get(ResultsCellLocators.businessUnit).eq(2).should('contain', 'Manchester Unit'); + cy.get(ResultsCellLocators.businessUnit).eq(3).should('contain', 'Liverpool Unit'); + cy.get(ResultsCellLocators.businessUnit).eq(4).should('contain', 'Birmingham Unit'); // ref column sorting - cy.get(DOM_ELEMENTS.refHeader).find('button').click(); + cy.get(ResultsHeaderButtonLocators.ref).click(); - cy.get(DOM_ELEMENTS.refCell).first().should('contain', 'PCR19274548'); - cy.get(DOM_ELEMENTS.refCell).eq(1).should('contain', 'PCR19274549'); - cy.get(DOM_ELEMENTS.refCell).eq(2).should('contain', 'PCR19274550'); - cy.get(DOM_ELEMENTS.refCell).eq(3).should('contain', 'PCR19274551'); - cy.get(DOM_ELEMENTS.refCell).eq(4).should('contain', 'PCR19274552'); + cy.get(ResultsCellLocators.ref).first().should('contain', 'PCR19274548'); + cy.get(ResultsCellLocators.ref).eq(1).should('contain', 'PCR19274549'); + cy.get(ResultsCellLocators.ref).eq(2).should('contain', 'PCR19274550'); + cy.get(ResultsCellLocators.ref).eq(3).should('contain', 'PCR19274551'); + cy.get(ResultsCellLocators.ref).eq(4).should('contain', 'PCR19274552'); - cy.get(DOM_ELEMENTS.refHeader).find('button').click(); + cy.get(ResultsHeaderButtonLocators.ref).click(); - cy.get(DOM_ELEMENTS.refCell).first().should('contain', 'PCR19274552'); - cy.get(DOM_ELEMENTS.refCell).eq(1).should('contain', 'PCR19274551'); - cy.get(DOM_ELEMENTS.refCell).eq(2).should('contain', 'PCR19274550'); - cy.get(DOM_ELEMENTS.refCell).eq(3).should('contain', 'PCR19274549'); - cy.get(DOM_ELEMENTS.refCell).eq(4).should('contain', 'PCR19274548'); + cy.get(ResultsCellLocators.ref).first().should('contain', 'PCR19274552'); + cy.get(ResultsCellLocators.ref).eq(1).should('contain', 'PCR19274551'); + cy.get(ResultsCellLocators.ref).eq(2).should('contain', 'PCR19274550'); + cy.get(ResultsCellLocators.ref).eq(3).should('contain', 'PCR19274549'); + cy.get(ResultsCellLocators.ref).eq(4).should('contain', 'PCR19274548'); // ENF column sorting - cy.get(DOM_ELEMENTS.enfHeader).find('button').click(); + cy.get(ResultsHeaderButtonLocators.enf).click(); - cy.get(DOM_ELEMENTS.enfCell).first().should('contain', 'BWTD'); - cy.get(DOM_ELEMENTS.enfCell).eq(1).should('contain', 'BWTD'); - cy.get(DOM_ELEMENTS.enfCell).eq(2).should('contain', 'ENFORCEMENT'); - cy.get(DOM_ELEMENTS.enfCell).eq(3).should('contain', 'WARRANT'); - cy.get(DOM_ELEMENTS.enfCell).eq(4).should('contain', 'WARRANT'); + cy.get(ResultsCellLocators.enf).first().should('contain', 'BWTD'); + cy.get(ResultsCellLocators.enf).eq(1).should('contain', 'BWTD'); + cy.get(ResultsCellLocators.enf).eq(2).should('contain', 'ENFORCEMENT'); + cy.get(ResultsCellLocators.enf).eq(3).should('contain', 'WARRANT'); + cy.get(ResultsCellLocators.enf).eq(4).should('contain', 'WARRANT'); - cy.get(DOM_ELEMENTS.enfHeader).find('button').click(); + cy.get(ResultsHeaderButtonLocators.enf).click(); - cy.get(DOM_ELEMENTS.enfCell).first().should('contain', 'WARRANT'); - cy.get(DOM_ELEMENTS.enfCell).eq(1).should('contain', 'WARRANT'); - cy.get(DOM_ELEMENTS.enfCell).eq(2).should('contain', 'ENFORCEMENT'); - cy.get(DOM_ELEMENTS.enfCell).eq(3).should('contain', 'BWTD'); - cy.get(DOM_ELEMENTS.enfCell).eq(4).should('contain', 'BWTD'); + cy.get(ResultsCellLocators.enf).first().should('contain', 'WARRANT'); + cy.get(ResultsCellLocators.enf).eq(1).should('contain', 'WARRANT'); + cy.get(ResultsCellLocators.enf).eq(2).should('contain', 'ENFORCEMENT'); + cy.get(ResultsCellLocators.enf).eq(3).should('contain', 'BWTD'); + cy.get(ResultsCellLocators.enf).eq(4).should('contain', 'BWTD'); // Balance column sorting - cy.get(DOM_ELEMENTS.balanceHeader).click(); + cy.get(ResultsHeaderButtonLocators.balance).click(); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£524.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(1).should('contain', '£675.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(2).should('contain', '£714.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(3).should('contain', '£850.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(4).should('contain', '£1,200.00'); + cy.get(ResultsCellLocators.balance).first().should('contain', '£524.00'); + cy.get(ResultsCellLocators.balance).eq(1).should('contain', '£675.00'); + cy.get(ResultsCellLocators.balance).eq(2).should('contain', '£714.00'); + cy.get(ResultsCellLocators.balance).eq(3).should('contain', '£850.00'); + cy.get(ResultsCellLocators.balance).eq(4).should('contain', '£1,200.00'); - cy.get(DOM_ELEMENTS.balanceHeader).click(); + cy.get(ResultsHeaderButtonLocators.balance).click(); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£1,200.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(1).should('contain', '£850.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(2).should('contain', '£714.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(3).should('contain', '£675.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(4).should('contain', '£524.00'); + cy.get(ResultsCellLocators.balance).first().should('contain', '£1,200.00'); + cy.get(ResultsCellLocators.balance).eq(1).should('contain', '£850.00'); + cy.get(ResultsCellLocators.balance).eq(2).should('contain', '£714.00'); + cy.get(ResultsCellLocators.balance).eq(3).should('contain', '£675.00'); + cy.get(ResultsCellLocators.balance).eq(4).should('contain', '£524.00'); }, ); }); diff --git a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsMinorCreditors.cy.ts b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsMinorCreditors.cy.ts index 0b7bcd78b7..bb3aeeeed4 100644 --- a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsMinorCreditors.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsMinorCreditors.cy.ts @@ -4,7 +4,7 @@ import { FinesSaStore } from '../../../../src/app/flows/fines/fines-sa/stores/fi import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { provideHttpClient } from '@angular/common/http'; -import { DOM_ELEMENTS } from './constants/search_results_minor_creditors_elements'; +import { AccountEnquiryResultsLocators as ResultsLocators } from '../../../shared/selectors/account-enquiry/account.enquiry.results.locators'; import { EMPTY_SEARCH_RESULTS_MOCK, INDIVIDUAL_SEARCH_RESULTS_MOCK, @@ -16,6 +16,11 @@ import { MINOR_CREDITORS_SEARCH_STATE_MOCK } from '../searchAndMatches/mocks/sea import { OpalFines } from '../../../../src/app/flows/fines/services/opal-fines-service/opal-fines.service'; const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; +const ResultsPageLocators = ResultsLocators.page; +const ResultsMessageLocators = ResultsLocators.messages; +const ResultsHeaderLocators = ResultsLocators.headerCells; +const ResultsCellLocators = ResultsLocators.cols; +const ResultsPaginationLocators = ResultsLocators.pagination; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; @@ -74,8 +79,8 @@ describe('FinesSaResultsComponent - Minor Creditors', () => { () => { setupComponent(); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); }, ); @@ -85,16 +90,16 @@ describe('FinesSaResultsComponent - Minor Creditors', () => { () => { setupComponent(EMPTY_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.noResultsHeading).should('be.visible'); - cy.get(DOM_ELEMENTS.noResultsHeading).should('contain', 'There are no matching results'); + cy.get(ResultsMessageLocators.noResultsHeading).should('be.visible'); + cy.get(ResultsMessageLocators.noResultsHeading).should('contain', 'There are no matching results'); - cy.get(DOM_ELEMENTS.checkSearchLink).should('be.visible'); - cy.get(DOM_ELEMENTS.checkSearchLink).should('contain', 'Check your search'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('be.visible'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('contain', 'Check your search'); //(AC2b) Check your search link is clickable and functional // Test that the link is clickable (Full Test to be implemented when API complete) - cy.get(DOM_ELEMENTS.checkSearchLink).should('have.class', 'govuk-link'); - cy.get(DOM_ELEMENTS.checkSearchLink).click(); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('have.class', 'govuk-link'); + cy.get(ResultsMessageLocators.checkYourSearchLink).click(); }, ); @@ -104,22 +109,22 @@ describe('FinesSaResultsComponent - Minor Creditors', () => { () => { setupComponent(LARGE_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); // Should show too many results message when more than 100 results - cy.get(DOM_ELEMENTS.tooManyResultsHeading).should('be.visible'); - cy.get(DOM_ELEMENTS.tooManyResultsHeading).should('contain', 'There are more than 100 results'); + cy.get(ResultsMessageLocators.tooManyResultsHeading).should('be.visible'); + cy.get(ResultsMessageLocators.tooManyResultsHeading).should('contain', 'There are more than 100 results'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('be.visible'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('contain', 'Try adding more information'); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('be.visible'); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('contain', 'Try adding more information'); - cy.get(DOM_ELEMENTS.tableWrapper).should('not.exist'); + cy.get(ResultsLocators.table.root).should('not.exist'); //(AC3b) Try adding more information link is clickable and functional // Test that the link is clickable (Full Test to be implemented when API complete) - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('have.class', 'govuk-link'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).click(); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('have.class', 'govuk-link'); + cy.get(ResultsMessageLocators.addMoreInfoLink).click(); }, ); @@ -129,46 +134,46 @@ describe('FinesSaResultsComponent - Minor Creditors', () => { () => { setupComponent(INDIVIDUAL_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); - cy.get(DOM_ELEMENTS.tableWrapper).should('exist'); + cy.get(ResultsLocators.table.root).should('exist'); - cy.get(DOM_ELEMENTS.accountHeader).should('contain', 'Account'); - cy.get(DOM_ELEMENTS.accountHeader).find('button').click(); - cy.get(DOM_ELEMENTS.nameHeader).should('contain', 'Name'); - cy.get(DOM_ELEMENTS.addressHeader).should('contain', 'Address line 1'); - cy.get(DOM_ELEMENTS.postcodeHeader).should('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.businessUnitHeader).should('contain', 'Business unit'); - cy.get(DOM_ELEMENTS.defendantHeader).should('contain', 'Defendant'); - cy.get(DOM_ELEMENTS.balanceHeader).should('contain', 'Balance'); + cy.get(ResultsHeaderLocators.account).should('contain', 'Account'); + cy.get(ResultsHeaderLocators.account).find('button').click(); + cy.get(ResultsHeaderLocators.name).should('contain', 'Name'); + cy.get(ResultsHeaderLocators.addr1).should('contain', 'Address line 1'); + cy.get(ResultsHeaderLocators.postcode).should('contain', 'Postcode'); + cy.get(ResultsHeaderLocators.bu).should('contain', 'Business unit'); + cy.get(ResultsHeaderLocators.defendant).should('contain', 'Defendant'); + cy.get(ResultsHeaderLocators.balance).should('contain', 'Balance'); - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '14001MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).first().should('contain', '14001MC'); - cy.get(DOM_ELEMENTS.accountCell).first().find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).first().find('a').should('exist'); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'THOMPSON, Emma Claire'); + cy.get(ResultsCellLocators.minorCreditorName).first().should('contain', 'THOMPSON, Emma Claire'); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '5 Minor Court'); + cy.get(ResultsCellLocators.minorCreditorAddr1).first().should('contain', '5 Minor Court'); - cy.get(DOM_ELEMENTS.postcodeCell).first().should('contain', 'MC1 2RT'); + cy.get(ResultsCellLocators.minorCreditorPostcode).first().should('contain', 'MC1 2RT'); - cy.get(DOM_ELEMENTS.businessUnitCell).first().should('contain', 'Minor Creditors Unit'); + cy.get(ResultsCellLocators.minorCreditorBusinessUnit).first().should('contain', 'Minor Creditors Unit'); - cy.get(DOM_ELEMENTS.defendantCell).first().should('contain', 'THOMPSON, Emma Claire'); + cy.get(ResultsCellLocators.minorCreditorDefendant).first().should('contain', 'THOMPSON, Emma Claire'); - cy.get(DOM_ELEMENTS.defendantCell).first().find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorDefendant).first().find('a').should('exist'); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£345.00'); + cy.get(ResultsCellLocators.minorCreditorBalance).first().should('contain', '£345.00'); - cy.get(DOM_ELEMENTS.accountCell).eq(1).should('contain', '14002MC'); - cy.get(DOM_ELEMENTS.accountCell).eq(1).find('a').should('exist'); - cy.get(DOM_ELEMENTS.nameCell).eq(1).should('contain', 'WILSON, James Robert'); - cy.get(DOM_ELEMENTS.addressCell).eq(1).should('contain', '8 Elm Street'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(1).should('contain', 'MC3 5RT'); - cy.get(DOM_ELEMENTS.defendantCell).eq(1).should('contain', 'WILSON, James Robert'); - cy.get(DOM_ELEMENTS.defendantCell).eq(1).find('a').should('exist'); - cy.get(DOM_ELEMENTS.balanceCell).eq(1).should('contain', '£567.00'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).eq(1).should('contain', '14002MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).eq(1).find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorName).eq(1).should('contain', 'WILSON, James Robert'); + cy.get(ResultsCellLocators.minorCreditorAddr1).eq(1).should('contain', '8 Elm Street'); + cy.get(ResultsCellLocators.minorCreditorPostcode).eq(1).should('contain', 'MC3 5RT'); + cy.get(ResultsCellLocators.minorCreditorDefendant).eq(1).should('contain', 'WILSON, James Robert'); + cy.get(ResultsCellLocators.minorCreditorDefendant).eq(1).find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorBalance).eq(1).should('contain', '£567.00'); }, ); @@ -178,44 +183,44 @@ describe('FinesSaResultsComponent - Minor Creditors', () => { () => { setupComponent(COMPANY_SEARCH_RESULTS_MOCK); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); - cy.get(DOM_ELEMENTS.tableWrapper).should('exist'); + cy.get(ResultsLocators.table.root).should('exist'); - cy.get(DOM_ELEMENTS.accountHeader).should('contain', 'Account'); - cy.get(DOM_ELEMENTS.accountHeader).find('button').click(); - cy.get(DOM_ELEMENTS.nameHeader).should('contain', 'Name'); - cy.get(DOM_ELEMENTS.addressHeader).should('contain', 'Address line 1'); - cy.get(DOM_ELEMENTS.postcodeHeader).should('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.businessUnitHeader).should('contain', 'Business unit'); - cy.get(DOM_ELEMENTS.defendantHeader).should('contain', 'Defendant'); - cy.get(DOM_ELEMENTS.balanceHeader).should('contain', 'Balance'); + cy.get(ResultsHeaderLocators.account).should('contain', 'Account'); + cy.get(ResultsHeaderLocators.account).find('button').click(); + cy.get(ResultsHeaderLocators.name).should('contain', 'Name'); + cy.get(ResultsHeaderLocators.addr1).should('contain', 'Address line 1'); + cy.get(ResultsHeaderLocators.postcode).should('contain', 'Postcode'); + cy.get(ResultsHeaderLocators.bu).should('contain', 'Business unit'); + cy.get(ResultsHeaderLocators.defendant).should('contain', 'Defendant'); + cy.get(ResultsHeaderLocators.balance).should('contain', 'Balance'); - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '14003MC'); - cy.get(DOM_ELEMENTS.accountCell).first().find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).first().should('contain', '14003MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).first().find('a').should('exist'); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'Young Entrepreneurs Ltd'); + cy.get(ResultsCellLocators.minorCreditorName).first().should('contain', 'Young Entrepreneurs Ltd'); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '12 Business Park'); + cy.get(ResultsCellLocators.minorCreditorAddr1).first().should('contain', '12 Business Park'); - cy.get(DOM_ELEMENTS.postcodeCell).first().should('contain', 'MC2 4RT'); + cy.get(ResultsCellLocators.minorCreditorPostcode).first().should('contain', 'MC2 4RT'); - cy.get(DOM_ELEMENTS.businessUnitCell).first().should('contain', 'Minor Creditors Unit'); + cy.get(ResultsCellLocators.minorCreditorBusinessUnit).first().should('contain', 'Minor Creditors Unit'); - cy.get(DOM_ELEMENTS.defendantCell).first().should('contain', 'Young Entrepreneurs Ltd'); - cy.get(DOM_ELEMENTS.defendantCell).first().find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorDefendant).first().should('contain', 'Young Entrepreneurs Ltd'); + cy.get(ResultsCellLocators.minorCreditorDefendant).first().find('a').should('exist'); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£890.00'); + cy.get(ResultsCellLocators.minorCreditorBalance).first().should('contain', '£890.00'); - cy.get(DOM_ELEMENTS.accountCell).eq(1).should('contain', '14004MC'); - cy.get(DOM_ELEMENTS.accountCell).eq(1).find('a').should('exist'); - cy.get(DOM_ELEMENTS.nameCell).eq(1).should('contain', 'Tech Solutions Inc'); - cy.get(DOM_ELEMENTS.addressCell).eq(1).should('contain', '45 Industrial Estate'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(1).should('contain', 'MC4 7RT'); - cy.get(DOM_ELEMENTS.defendantCell).eq(1).should('contain', 'Tech Solutions Inc'); - cy.get(DOM_ELEMENTS.defendantCell).eq(1).find('a').should('exist'); - cy.get(DOM_ELEMENTS.balanceCell).eq(1).should('contain', '£1,250.00'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).eq(1).should('contain', '14004MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).eq(1).find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorName).eq(1).should('contain', 'Tech Solutions Inc'); + cy.get(ResultsCellLocators.minorCreditorAddr1).eq(1).should('contain', '45 Industrial Estate'); + cy.get(ResultsCellLocators.minorCreditorPostcode).eq(1).should('contain', 'MC4 7RT'); + cy.get(ResultsCellLocators.minorCreditorDefendant).eq(1).should('contain', 'Tech Solutions Inc'); + cy.get(ResultsCellLocators.minorCreditorDefendant).eq(1).find('a').should('exist'); + cy.get(ResultsCellLocators.minorCreditorBalance).eq(1).should('contain', '£1,250.00'); }, ); @@ -231,40 +236,40 @@ describe('FinesSaResultsComponent - Minor Creditors', () => { setupComponent(paginationMock); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.paginationElement).should('exist'); - cy.get(DOM_ELEMENTS.paginationText).should('contain', '100 total results'); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '1'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPaginationLocators.root).should('exist'); + cy.get(ResultsPaginationLocators.resultsText).should('contain', '100 total results'); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '1'); // Verify pagination shows 4 pages total - cy.get(DOM_ELEMENTS.paginationList).within(() => { - cy.get(DOM_ELEMENTS.paginationListItem).should('have.length.at.least', 4); + cy.get(ResultsPaginationLocators.list).within(() => { + cy.get(ResultsPaginationLocators.listItem).should('have.length.at.least', 4); cy.contains('1').should('exist'); cy.contains('2').should('exist'); - cy.get(DOM_ELEMENTS.paginationListItemEllipses).should('exist'); + cy.get(ResultsPaginationLocators.listItemEllipses).should('exist'); cy.contains('4').should('exist'); }); - cy.get(DOM_ELEMENTS.table).should('have.length', 25); + cy.get(ResultsLocators.table.rows).should('have.length', 25); - cy.get(DOM_ELEMENTS.paginationPageNumber(2)).click(); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '2'); - cy.get(DOM_ELEMENTS.table).should('have.length', 25); + cy.get(ResultsPaginationLocators.pageNumber(2)).click(); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '2'); + cy.get(ResultsLocators.table.rows).should('have.length', 25); - cy.get(DOM_ELEMENTS.paginationPageNumber(4)).click(); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '4'); - cy.get(DOM_ELEMENTS.table).should('have.length', 25); + cy.get(ResultsPaginationLocators.pageNumber(4)).click(); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '4'); + cy.get(ResultsLocators.table.rows).should('have.length', 25); - cy.get(DOM_ELEMENTS.previousPageButton).should('exist'); - cy.get(DOM_ELEMENTS.nextPageButton).should('not.exist'); + cy.get(ResultsPaginationLocators.previousButton).should('exist'); + cy.get(ResultsPaginationLocators.nextButton).should('not.exist'); - cy.get(DOM_ELEMENTS.previousPageButton).click(); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '3'); - cy.get(DOM_ELEMENTS.table).should('have.length', 25); + cy.get(ResultsPaginationLocators.previousButton).click(); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '3'); + cy.get(ResultsLocators.table.rows).should('have.length', 25); - cy.get(DOM_ELEMENTS.nextPageButton).should('exist'); - cy.get(DOM_ELEMENTS.nextPageButton).click(); - cy.get(DOM_ELEMENTS.paginationCurrentPage).should('contain', '4'); + cy.get(ResultsPaginationLocators.nextButton).should('exist'); + cy.get(ResultsPaginationLocators.nextButton).click(); + cy.get(ResultsPaginationLocators.currentPage).should('contain', '4'); }, ); @@ -274,83 +279,83 @@ describe('FinesSaResultsComponent - Minor Creditors', () => { () => { setupComponent(SORTING_MINOR_CREDITORS_MOCK); - cy.get(DOM_ELEMENTS.heading).should('contain', 'Search results'); - cy.get(DOM_ELEMENTS.backLink).should('exist'); - cy.get(DOM_ELEMENTS.tableWrapper).should('exist'); + cy.get(ResultsPageLocators.heading).should('contain', 'Search results'); + cy.get(ResultsPageLocators.backLinkHost).should('exist'); + cy.get(ResultsLocators.table.root).should('exist'); // Initially account number in descending order - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '14005MC'); - cy.get(DOM_ELEMENTS.accountCell).eq(4).should('contain', '14001MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).first().should('contain', '14005MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).eq(4).should('contain', '14001MC'); // Test Account column sorting - sort ascending - cy.get(DOM_ELEMENTS.accountHeader).find('button').click(); - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '14001MC'); - cy.get(DOM_ELEMENTS.accountCell).eq(4).should('contain', '14005MC'); + cy.get(ResultsHeaderLocators.account).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorAccountCell).first().should('contain', '14001MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).eq(4).should('contain', '14005MC'); // sort descending - cy.get(DOM_ELEMENTS.accountHeader).find('button').click(); - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '14005MC'); - cy.get(DOM_ELEMENTS.accountCell).eq(4).should('contain', '14001MC'); + cy.get(ResultsHeaderLocators.account).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorAccountCell).first().should('contain', '14005MC'); + cy.get(ResultsCellLocators.minorCreditorAccountCell).eq(4).should('contain', '14001MC'); // Test Name column sorting - sort ascending - cy.get(DOM_ELEMENTS.nameHeader).find('button').click(); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'ANDERSON, Lisa'); - cy.get(DOM_ELEMENTS.nameCell).eq(4).should('contain', 'WILLIAMS, Sarah'); + cy.get(ResultsHeaderLocators.name).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorName).first().should('contain', 'ANDERSON, Lisa'); + cy.get(ResultsCellLocators.minorCreditorName).eq(4).should('contain', 'WILLIAMS, Sarah'); // sort descending - cy.get(DOM_ELEMENTS.nameHeader).find('button').click(); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'WILLIAMS, Sarah'); - cy.get(DOM_ELEMENTS.nameCell).eq(4).should('contain', 'ANDERSON, Lisa'); + cy.get(ResultsHeaderLocators.name).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorName).first().should('contain', 'WILLIAMS, Sarah'); + cy.get(ResultsCellLocators.minorCreditorName).eq(4).should('contain', 'ANDERSON, Lisa'); // Test Address column sorting - sort ascending - cy.get(DOM_ELEMENTS.addressHeader).find('button').click(); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '1 High Street'); - cy.get(DOM_ELEMENTS.addressCell).eq(4).should('contain', '8 Park Avenue'); + cy.get(ResultsHeaderLocators.addr1).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorAddr1).first().should('contain', '1 High Street'); + cy.get(ResultsCellLocators.minorCreditorAddr1).eq(4).should('contain', '8 Park Avenue'); // sort descending - cy.get(DOM_ELEMENTS.addressHeader).find('button').click(); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '8 Park Avenue'); - cy.get(DOM_ELEMENTS.addressCell).eq(4).should('contain', '1 High Street'); + cy.get(ResultsHeaderLocators.addr1).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorAddr1).first().should('contain', '8 Park Avenue'); + cy.get(ResultsCellLocators.minorCreditorAddr1).eq(4).should('contain', '1 High Street'); // Test Postcode column sorting - sort ascending - cy.get(DOM_ELEMENTS.postcodeHeader).find('button').click(); - cy.get(DOM_ELEMENTS.postcodeCell).first().should('contain', 'B2 4TY'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(4).should('contain', 'RG1 9RT'); + cy.get(ResultsHeaderLocators.postcode).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorPostcode).first().should('contain', 'B2 4TY'); + cy.get(ResultsCellLocators.minorCreditorPostcode).eq(4).should('contain', 'RG1 9RT'); // sort descending - cy.get(DOM_ELEMENTS.postcodeHeader).find('button').click(); - cy.get(DOM_ELEMENTS.postcodeCell).first().should('contain', 'RG1 9RT'); - cy.get(DOM_ELEMENTS.postcodeCell).eq(4).should('contain', 'B2 4TY'); + cy.get(ResultsHeaderLocators.postcode).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorPostcode).first().should('contain', 'RG1 9RT'); + cy.get(ResultsCellLocators.minorCreditorPostcode).eq(4).should('contain', 'B2 4TY'); // Test Balance column sorting - sort ascending - cy.get(DOM_ELEMENTS.balanceHeader).find('button').click(); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£310.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(4).should('contain', '£890.00'); + cy.get(ResultsHeaderLocators.balance).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorBalance).first().should('contain', '£310.00'); + cy.get(ResultsCellLocators.minorCreditorBalance).eq(4).should('contain', '£890.00'); // sort descending - cy.get(DOM_ELEMENTS.balanceHeader).find('button').click(); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£890.00'); - cy.get(DOM_ELEMENTS.balanceCell).eq(4).should('contain', '£310.00'); + cy.get(ResultsHeaderLocators.balance).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorBalance).first().should('contain', '£890.00'); + cy.get(ResultsCellLocators.minorCreditorBalance).eq(4).should('contain', '£310.00'); // Test Business unit column sorting - sort ascending - cy.get(DOM_ELEMENTS.businessUnitHeader).find('button').click(); - cy.get(DOM_ELEMENTS.businessUnitCell).first().should('contain', 'Central Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(4).should('contain', 'West Unit'); + cy.get(ResultsHeaderLocators.bu).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorBusinessUnit).first().should('contain', 'Central Unit'); + cy.get(ResultsCellLocators.minorCreditorBusinessUnit).eq(4).should('contain', 'West Unit'); // sort descending - cy.get(DOM_ELEMENTS.businessUnitHeader).find('button').click(); - cy.get(DOM_ELEMENTS.businessUnitCell).first().should('contain', 'West Unit'); - cy.get(DOM_ELEMENTS.businessUnitCell).eq(4).should('contain', 'Central Unit'); + cy.get(ResultsHeaderLocators.bu).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorBusinessUnit).first().should('contain', 'West Unit'); + cy.get(ResultsCellLocators.minorCreditorBusinessUnit).eq(4).should('contain', 'Central Unit'); // Test Defendant column sorting - sort ascending - cy.get(DOM_ELEMENTS.defendantHeader).find('button').click(); - cy.get(DOM_ELEMENTS.defendantCell).first().should('contain', 'ANDERSON, Lisa'); - cy.get(DOM_ELEMENTS.defendantCell).eq(4).should('contain', 'WILLIAMS, Sarah'); + cy.get(ResultsHeaderLocators.defendant).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorDefendant).first().should('contain', 'ANDERSON, Lisa'); + cy.get(ResultsCellLocators.minorCreditorDefendant).eq(4).should('contain', 'WILLIAMS, Sarah'); // sort descending - cy.get(DOM_ELEMENTS.defendantHeader).find('button').click(); - cy.get(DOM_ELEMENTS.defendantCell).first().should('contain', 'WILLIAMS, Sarah'); - cy.get(DOM_ELEMENTS.defendantCell).eq(4).should('contain', 'ANDERSON, Lisa'); + cy.get(ResultsHeaderLocators.defendant).find('button').click(); + cy.get(ResultsCellLocators.minorCreditorDefendant).first().should('contain', 'WILLIAMS, Sarah'); + cy.get(ResultsCellLocators.minorCreditorDefendant).eq(4).should('contain', 'ANDERSON, Lisa'); }, ); }); diff --git a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsReferenceNumber.cy.ts b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsReferenceNumber.cy.ts index 2572598f4a..8dc5b34b6f 100644 --- a/cypress/component/fineAccountEnquiry/searchResults/SearchResultsReferenceNumber.cy.ts +++ b/cypress/component/fineAccountEnquiry/searchResults/SearchResultsReferenceNumber.cy.ts @@ -3,13 +3,17 @@ import { FinesSaResultsComponent } from '../../../../src/app/flows/fines/fines-s import { FinesSaStore } from '../../../../src/app/flows/fines/fines-sa/stores/fines-sa.store'; import { ActivatedRoute } from '@angular/router'; import { provideHttpClient } from '@angular/common/http'; -import { DOM_ELEMENTS } from './constants/search_results_individuals_elements'; +import { AccountEnquiryResultsLocators as ResultsLocators } from '../../../shared/selectors/account-enquiry/account.enquiry.results.locators'; import { UNIFIED_SEARCH_RESULTS_MOCK, getAllAccountTypes } from './mocks/search_results_account_mock'; import { INDIVIDUAL_SEARCH_STATE_MOCK } from '../searchAndMatches/mocks/search_and_matches_individual_mock'; import { OpalFines } from '../../../../src/app/flows/fines/services/opal-fines-service/opal-fines.service'; import { BehaviorSubject } from 'rxjs'; const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; +const ResultsMessageLocators = ResultsLocators.messages; +const ResultsTabLocators = ResultsLocators.tabs; +const ResultsHeaderCellLocators = ResultsLocators.headerCells; +const ResultsCellLocators = ResultsLocators.cols; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; @@ -95,13 +99,13 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('EMPTY_RESULTS'); // AC3a: Verify the error screen is displayed when no search matches are found - cy.get(DOM_ELEMENTS.noResultsHeading).should('be.visible'); - cy.get(DOM_ELEMENTS.noResultsHeading).should('contain', 'There are no matching results'); + cy.get(ResultsMessageLocators.noResultsHeading).should('be.visible'); + cy.get(ResultsMessageLocators.noResultsHeading).should('contain', 'There are no matching results'); - cy.get(DOM_ELEMENTS.checkSearchLink).should('be.visible'); - cy.get(DOM_ELEMENTS.checkSearchLink).should('contain', 'Check your search'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('be.visible'); + cy.get(ResultsMessageLocators.checkYourSearchLink).should('contain', 'Check your search'); // AC3b: Verify 'Check your search' link is clickable and functional - cy.get(DOM_ELEMENTS.checkSearchLink).click(); + cy.get(ResultsMessageLocators.checkYourSearchLink).click(); }, ); @@ -112,13 +116,15 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('LARGE_RESULTS_REF_NUM'); // AC4a: Verify the "too many results" error screen is displayed - cy.get(DOM_ELEMENTS.tooManyResultsHeading).should('be.visible'); - cy.get(DOM_ELEMENTS.tooManyResultsHeading).should('contain', 'There are more than 100 results'); + cy.get(ResultsMessageLocators.tooManyResultsHeading).should('be.visible'); + cy.get(ResultsMessageLocators.tooManyResultsHeading).should('contain', 'There are more than 100 results'); // AC4b: Verify 'Try adding more information' link is present - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('be.visible').should('contain', 'Try adding more information'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).should('have.class', 'govuk-link'); - cy.get(DOM_ELEMENTS.addMoreInfoLink).click(); + cy.get(ResultsMessageLocators.addMoreInfoLink) + .should('be.visible') + .should('contain', 'Try adding more information'); + cy.get(ResultsMessageLocators.addMoreInfoLink).should('have.class', 'govuk-link'); + cy.get(ResultsMessageLocators.addMoreInfoLink).click(); }, ); @@ -129,43 +135,43 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('WITH_DATA', 'individuals'); // AC5b-Verify Individuals tab is in focus by default - verifyTabIsActive(DOM_ELEMENTS.individualsTab); + verifyTabIsActive(ResultsTabLocators.individualsTab); // Verify all column headers are present - cy.get(DOM_ELEMENTS.accountHeader).should('contain', 'Account'); - cy.get(DOM_ELEMENTS.nameHeader).should('contain', 'Name'); - cy.get(DOM_ELEMENTS.aliasesHeader).should('contain', 'Aliases'); - cy.get(DOM_ELEMENTS.dobHeader).should('contain', 'Date of birth'); - cy.get(DOM_ELEMENTS.addressHeader).should('contain', 'Address line 1'); - cy.get(DOM_ELEMENTS.postcodeHeader).should('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.niNumberHeader).should('contain', 'NI number'); - cy.get(DOM_ELEMENTS.parentGuardianHeader).should('contain', 'Parent or guardian'); - cy.get(DOM_ELEMENTS.businessUnitHeader).should('contain', 'Business unit'); - cy.get(DOM_ELEMENTS.refHeader).should('contain', 'Ref'); - cy.get(DOM_ELEMENTS.enfHeader).should('contain', 'ENF'); - cy.get(DOM_ELEMENTS.balanceHeader).should('contain', 'Balance'); - - cy.get(DOM_ELEMENTS.accountCell).first().should('contain', '13001BU'); - cy.get(DOM_ELEMENTS.accountCell).first().find('a').should('exist'); - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'SMITH, John Michael'); - cy.get(DOM_ELEMENTS.aliasesCell).first().should('contain', 'SMITH, John Michael'); - cy.get(DOM_ELEMENTS.dobCell).first().should('contain', '01 Jun 1985'); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '1 High Street'); - cy.get(DOM_ELEMENTS.postcodeCell).first().should('contain', 'RG1 9RT'); - cy.get(DOM_ELEMENTS.niNumberCell).first().should('contain', 'JK 56 78 90 C'); - cy.get(DOM_ELEMENTS.parentGuardianCell).first().should('contain', 'DOE, Jane'); - cy.get(DOM_ELEMENTS.businessUnitCell).first().should('contain', 'Test Business Unit'); - cy.get(DOM_ELEMENTS.refCell).first().should('contain', 'PCR19274548'); - cy.get(DOM_ELEMENTS.enfCell).first().should('contain', 'BWTD'); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£714.00'); - - cy.get(DOM_ELEMENTS.accountCell).eq(1).should('contain', '13002BU'); - cy.get(DOM_ELEMENTS.nameCell).eq(1).should('contain', 'DOE, Jane'); - cy.get(DOM_ELEMENTS.dobCell).eq(1).should('contain', '15 Mar 1990'); - cy.get(DOM_ELEMENTS.enfCell).eq(1).should('contain', 'WARRANT'); - cy.get(DOM_ELEMENTS.balanceCell).eq(1).should('contain', '£524.00'); - cy.get(DOM_ELEMENTS.aliasesCell).eq(1).should('not.contain', 'SMITH'); - cy.get(DOM_ELEMENTS.parentGuardianCell).eq(1).should('not.contain', 'DOE, Jane'); + cy.get(ResultsHeaderCellLocators.account).should('contain', 'Account'); + cy.get(ResultsHeaderCellLocators.name).should('contain', 'Name'); + cy.get(ResultsHeaderCellLocators.aliases).should('contain', 'Aliases'); + cy.get(ResultsHeaderCellLocators.dob).should('contain', 'Date of birth'); + cy.get(ResultsHeaderCellLocators.addr1).should('contain', 'Address line 1'); + cy.get(ResultsHeaderCellLocators.postcode).should('contain', 'Postcode'); + cy.get(ResultsHeaderCellLocators.ni).should('contain', 'NI number'); + cy.get(ResultsHeaderCellLocators.pg).should('contain', 'Parent or guardian'); + cy.get(ResultsHeaderCellLocators.bu).should('contain', 'Business unit'); + cy.get(ResultsHeaderCellLocators.ref).should('contain', 'Ref'); + cy.get(ResultsHeaderCellLocators.enf).should('contain', 'ENF'); + cy.get(ResultsHeaderCellLocators.balance).should('contain', 'Balance'); + + cy.get(ResultsCellLocators.accountCell).first().should('contain', '13001BU'); + cy.get(ResultsCellLocators.accountCell).first().find('a').should('exist'); + cy.get(ResultsCellLocators.name).first().should('contain', 'SMITH, John Michael'); + cy.get(ResultsCellLocators.aliases).first().should('contain', 'SMITH, John Michael'); + cy.get(ResultsCellLocators.dob).first().should('contain', '01 Jun 1985'); + cy.get(ResultsCellLocators.addr1).first().should('contain', '1 High Street'); + cy.get(ResultsCellLocators.postcode).first().should('contain', 'RG1 9RT'); + cy.get(ResultsCellLocators.ni).first().should('contain', 'JK 56 78 90 C'); + cy.get(ResultsCellLocators.parentGuard).first().should('contain', 'DOE, Jane'); + cy.get(ResultsCellLocators.businessUnit).first().should('contain', 'Test Business Unit'); + cy.get(ResultsCellLocators.ref).first().should('contain', 'PCR19274548'); + cy.get(ResultsCellLocators.enf).first().should('contain', 'BWTD'); + cy.get(ResultsCellLocators.balance).first().should('contain', '£714.00'); + + cy.get(ResultsCellLocators.accountCell).eq(1).should('contain', '13002BU'); + cy.get(ResultsCellLocators.name).eq(1).should('contain', 'DOE, Jane'); + cy.get(ResultsCellLocators.dob).eq(1).should('contain', '15 Mar 1990'); + cy.get(ResultsCellLocators.enf).eq(1).should('contain', 'WARRANT'); + cy.get(ResultsCellLocators.balance).eq(1).should('contain', '£524.00'); + cy.get(ResultsCellLocators.aliases).eq(1).should('not.contain', 'SMITH'); + cy.get(ResultsCellLocators.parentGuard).eq(1).should('not.contain', 'DOE, Jane'); }, ); @@ -175,23 +181,23 @@ describe('FinesSaResultsComponent - All Account Types', () => { () => { setupComponent('WITH_DATA', 'companies'); - switchToTab('companies', DOM_ELEMENTS.companiesTab); - verifyTabIsActive(DOM_ELEMENTS.companiesTab); + switchToTab('companies', ResultsTabLocators.companiesTab); + verifyTabIsActive(ResultsTabLocators.companiesTab); // Verify table exists and headers match design - cy.get(DOM_ELEMENTS.tableWrapper).should('exist'); - cy.get(DOM_ELEMENTS.accountHeader).should('contain', 'Account'); - cy.get(DOM_ELEMENTS.addressHeader).should('contain', 'Address line 1'); - cy.get(DOM_ELEMENTS.postcodeHeader).should('contain', 'Postcode'); - cy.get(DOM_ELEMENTS.businessUnitHeader).should('contain', 'Business unit'); - cy.get(DOM_ELEMENTS.refHeader).should('contain', 'Ref'); - cy.get(DOM_ELEMENTS.enfHeader).should('contain', 'ENF'); - cy.get(DOM_ELEMENTS.balanceHeader).should('contain', 'Balance'); + cy.get(ResultsLocators.table.root).should('exist'); + cy.get(ResultsHeaderCellLocators.account).should('contain', 'Account'); + cy.get(ResultsHeaderCellLocators.addr1).should('contain', 'Address line 1'); + cy.get(ResultsHeaderCellLocators.postcode).should('contain', 'Postcode'); + cy.get(ResultsHeaderCellLocators.bu).should('contain', 'Business unit'); + cy.get(ResultsHeaderCellLocators.ref).should('contain', 'Ref'); + cy.get(ResultsHeaderCellLocators.enf).should('contain', 'ENF'); + cy.get(ResultsHeaderCellLocators.balance).should('contain', 'Balance'); // Verify first row matches mock data - cy.get(DOM_ELEMENTS.nameCell).first().should('contain', 'ACME LTD'); - cy.get(DOM_ELEMENTS.addressCell).first().should('contain', '10 Downing Street'); - cy.get(DOM_ELEMENTS.balanceCell).first().should('contain', '£1,000.00'); + cy.get(ResultsCellLocators.name).first().should('contain', 'ACME LTD'); + cy.get(ResultsCellLocators.addr1).first().should('contain', '10 Downing Street'); + cy.get(ResultsCellLocators.balance).first().should('contain', '£1,000.00'); }, ); @@ -202,9 +208,9 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('INDIVIDUALS_ONLY_RESULTS'); // Verify only individuals and companies tabs are shown - cy.get(DOM_ELEMENTS.individualsTab).should('be.visible'); - cy.get(DOM_ELEMENTS.companiesTab).should('not.exist'); - cy.get(DOM_ELEMENTS.minorCreditorsTab).should('not.exist'); + cy.get(ResultsTabLocators.individualsTab).should('be.visible'); + cy.get(ResultsTabLocators.companiesTab).should('not.exist'); + cy.get(ResultsTabLocators.minorCreditorsTab).should('not.exist'); }, ); @@ -215,9 +221,9 @@ describe('FinesSaResultsComponent - All Account Types', () => { setupComponent('COMPANY_RESULTS_ONLY'); // Verify only companies tab are shown - cy.get(DOM_ELEMENTS.individualsTab).should('not.exist'); - cy.get(DOM_ELEMENTS.companiesTab).should('be.visible'); - cy.get(DOM_ELEMENTS.minorCreditorsTab).should('not.exist'); + cy.get(ResultsTabLocators.individualsTab).should('not.exist'); + cy.get(ResultsTabLocators.companiesTab).should('be.visible'); + cy.get(ResultsTabLocators.minorCreditorsTab).should('not.exist'); }, ); }); diff --git a/cypress/component/fineAccountEnquiry/searchResults/constants/search_results_individuals_elements.ts b/cypress/component/fineAccountEnquiry/searchResults/constants/search_results_individuals_elements.ts deleted file mode 100644 index 47a0f6de65..0000000000 --- a/cypress/component/fineAccountEnquiry/searchResults/constants/search_results_individuals_elements.ts +++ /dev/null @@ -1,66 +0,0 @@ -export const DOM_ELEMENTS = { - heading: 'h1.govuk-heading-l', - backLink: 'opal-lib-govuk-back-link', - - // No results message elements (based on actual template structure) - noResultsHeading: 'h2.govuk-heading-m', - noResultsText: 'p.govuk-body-m', - noResultsMessage: '.govuk-grid-column-full-width > p:nth-of-type(1)', - noResultsFollowupMessage: '.govuk-grid-column-full-width > p:nth-of-type(2)', - checkSearchLink: 'a.govuk-link', - - tooManyResultsHeading: 'h2.govuk-heading-m', - tooManyResultsText: 'p.govuk-body-m', - addMoreInfoLink: 'a.govuk-link', - - tableWrapper: 'app-fines-sa-results-defendant-table-wrapper', - table: 'tbody tr', - - accountHeader: 'th[columnkey="Account"]', - nameHeader: 'th[columnkey="Name"]', - aliasesHeader: 'th[columnkey="Aliases"]', - dobHeader: 'th[columnkey="Date of birth"]', - addressHeader: 'th[columnkey="Address line 1"]', - postcodeHeader: 'th[columnkey="Postcode"]', - niNumberHeader: 'th[columnkey="NI number"]', - parentGuardianHeader: 'th[columnkey="Parent or guardian"]', - businessUnitHeader: 'th[columnkey="Business unit"]', - defendantHeader: 'th[columnkey="Defendant"]', - refHeader: 'th[columnkey="Ref"]', - enfHeader: 'th[columnkey="Enf"]', - balanceHeader: 'th[columnkey="Balance"]', - - accountCell: 'td[id="defendantAccountNumber"]', - nameCell: 'td[id="defendantName"]', - aliasesCell: 'td[id="defendantAliases"]', - dobCell: 'td[id="defendantDateOfBirth"]', - addressCell: 'td[id="defendantAddressLine1"]', - postcodeCell: 'td[id="defendantPostcode"]', - niNumberCell: 'td[id="defendantNationalInsuranceNumber"]', - parentGuardianCell: 'td[id="defendantParentOrGuardian"]', - businessUnitCell: 'td[id="defendantBusinessUnit"]', - refCell: 'td[id="defendantRef"]', - enfCell: 'td[id="defendantEnf"]', - balanceCell: 'td[id="defendantBalance"]', - defendantCell: 'td[id="defendant"]', - - tabs: 'opal-lib-govuk-tabs', - tabsList: '.govuk-tabs__list', - individualsTab: '[tabitemid="tab-individuals"]', - companiesTab: '[tabitemid="tab-companies"]', - minorCreditorsTab: '[tabitemid="tab-minor-creditors"]', - - individualsPanel: '[id="individuals"]', - companiesPanel: '[id="companies"]', - minorCreditorsPanel: '[id="minor-creditors"]', - - paginationElement: 'opal-lib-moj-pagination', - paginationText: '.moj-pagination__results', - previousPageButton: '.govuk-pagination__prev', - nextPageButton: '.govuk-pagination__next', - paginationList: '.govuk-pagination__list', - paginationListItem: '.govuk-pagination__item', - paginationListItemEllipses: '.govuk-pagination__item--ellipses', - paginationCurrentPage: '.govuk-pagination__item--current', - paginationPageNumber: (pageNum: number | string) => `.govuk-pagination__item:contains("${pageNum}")`, -}; diff --git a/cypress/component/fineAccountEnquiry/searchResults/constants/search_results_minor_creditors_elements.ts b/cypress/component/fineAccountEnquiry/searchResults/constants/search_results_minor_creditors_elements.ts deleted file mode 100644 index 3a267bf10c..0000000000 --- a/cypress/component/fineAccountEnquiry/searchResults/constants/search_results_minor_creditors_elements.ts +++ /dev/null @@ -1,54 +0,0 @@ -export const DOM_ELEMENTS = { - heading: 'h1.govuk-heading-l', - backLink: 'opal-lib-govuk-back-link', - - // No results message elements (based on actual template structure) - noResultsHeading: 'h2.govuk-heading-m', - noResultsText: 'p.govuk-body-m', - noResultsMessage: '.govuk-grid-column-full-width > p:nth-of-type(1)', - noResultsFollowupMessage: '.govuk-grid-column-full-width > p:nth-of-type(2)', - checkSearchLink: 'a.govuk-link', - - tooManyResultsHeading: 'h2.govuk-heading-m', - tooManyResultsText: 'p.govuk-body-m', - addMoreInfoLink: 'a.govuk-link', - - tableWrapper: 'app-fines-sa-results-minor-creditor-table-wrapper', - table: 'tbody tr', - - accountHeader: 'th[columnkey="Account"]', - nameHeader: 'th[columnkey="Name"]', - addressHeader: 'th[columnkey="Address line 1"]', - postcodeHeader: 'th[columnkey="Postcode"]', - businessUnitHeader: 'th[columnkey="Business unit"]', - defendantHeader: 'th[columnkey="Defendant"]', - balanceHeader: 'th[columnkey="Balance"]', - - accountCell: 'td[id="minorCreditorAccountNumber"]', - nameCell: 'td[id="minorCreditorName"]', - addressCell: 'td[id="minorCreditorAddressLine1"]', - postcodeCell: 'td[id="minorCreditorPostcode"]', - businessUnitCell: 'td[id="minorCreditorBusinessUnit"]', - defendantCell: 'td[id="minorCreditorDefendant"]', - balanceCell: 'td[id="minorCreditorBalance"]', - - tabs: 'opal-lib-govuk-tabs', - tabsList: '.govuk-tabs__list', - individualsTab: '[id="tab-individuals"]', - companiesTab: '[id="tab-companies"]', - minorCreditorsTab: '[id="tab-minor-creditors"]', - - individualsPanel: '[id="individuals"]', - companiesPanel: '[id="companies"]', - minorCreditorsPanel: '[id="minor-creditors"]', - - paginationElement: 'opal-lib-moj-pagination', - paginationText: '.moj-pagination__results', - previousPageButton: '.govuk-pagination__prev', - nextPageButton: '.govuk-pagination__next', - paginationList: '.govuk-pagination__list', - paginationListItem: '.govuk-pagination__item', - paginationListItemEllipses: '.govuk-pagination__item--ellipses', - paginationCurrentPage: '.govuk-pagination__item--current', - paginationPageNumber: (pageNum: number | string) => `.govuk-pagination__item:contains("${pageNum}")`, -}; diff --git a/cypress/component/fineAccountEnquiry/viewDefendantAccountSummary/addComments/addComments.cy.ts b/cypress/component/fineAccountEnquiry/viewDefendantAccountSummary/addComments/addComments.cy.ts index 4881df2e62..34562cc3ab 100644 --- a/cypress/component/fineAccountEnquiry/viewDefendantAccountSummary/addComments/addComments.cy.ts +++ b/cypress/component/fineAccountEnquiry/viewDefendantAccountSummary/addComments/addComments.cy.ts @@ -6,8 +6,7 @@ import { FinesAccountStore } from '../../../../../src/app/flows/fines/fines-acc/ import { FinesAccPayloadService } from '../../../../../src/app/flows/fines/fines-acc/services/fines-acc-payload.service'; import { OpalFines } from '../../../../../src/app/flows/fines/services/opal-fines-service/opal-fines.service'; import { UtilsService } from '@hmcts/opal-frontend-common/services/utils-service'; - -import { DOM_ELEMENTS } from './constants/add_comments_elements'; +import { AccountCommentsAddLocators } from '../../../../shared/selectors/account-details/account.comments.details.locators'; import { ADD_COMMENTS_FORM_STATE_MOCK, MOCK_ACCOUNT_STATE, @@ -21,6 +20,10 @@ import { const ACCOUNT_ENQUIRY_JIRA_LABEL = '@JIRA-LABEL:account-enquiry'; const buildTags = (...tags: string[]): string[] => [...tags, ACCOUNT_ENQUIRY_JIRA_LABEL]; +const CommentFields = AccountCommentsAddLocators.fields; +const CommentErrors = AccountCommentsAddLocators.errors; +const CommentCharacterCounts = AccountCommentsAddLocators.characterCounts; +const CommentActions = AccountCommentsAddLocators.actions; describe('FinesAccCommentsAddComponent', () => { const setupComponent = (prefilledData = ADD_COMMENTS_FORM_STATE_MOCK, formSubmit: any = null) => { @@ -78,19 +81,19 @@ describe('FinesAccCommentsAddComponent', () => { () => { setupComponent(); - cy.get(DOM_ELEMENTS.form).should('exist'); - cy.get(DOM_ELEMENTS.commentField).should('exist'); - cy.get(DOM_ELEMENTS.freeText1Field).should('exist'); - cy.get(DOM_ELEMENTS.freeText2Field).should('exist'); - cy.get(DOM_ELEMENTS.freeText3Field).should('exist'); + cy.get(AccountCommentsAddLocators.form).should('exist'); + cy.get(CommentFields.comment).should('exist'); + cy.get(CommentFields.line1).should('exist'); + cy.get(CommentFields.line2).should('exist'); + cy.get(CommentFields.line3).should('exist'); - cy.get(DOM_ELEMENTS.commentField).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText2Field).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText3Field).should('have.value', ''); + cy.get(CommentFields.comment).should('have.value', ''); + cy.get(CommentFields.line1).should('have.value', ''); + cy.get(CommentFields.line2).should('have.value', ''); + cy.get(CommentFields.line3).should('have.value', ''); - cy.get(DOM_ELEMENTS.submitButton).should('exist'); - cy.get(DOM_ELEMENTS.cancelButton).should('exist'); + cy.get(CommentActions.saveButton).should('exist'); + cy.get(CommentActions.cancelLink).should('exist'); }, ); @@ -100,11 +103,11 @@ describe('FinesAccCommentsAddComponent', () => { () => { setupComponent(ADD_COMMENTS_FORM_STATE_MAX_LENGTH_MOCK); - cy.get(DOM_ELEMENTS.commentField).should('have.value', 'A'.repeat(30)); + cy.get(CommentFields.comment).should('have.value', 'A'.repeat(30)); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', 'B'.repeat(76)); - cy.get(DOM_ELEMENTS.freeText2Field).should('have.value', 'C'.repeat(76)); - cy.get(DOM_ELEMENTS.freeText3Field).should('have.value', 'D'.repeat(76)); + cy.get(CommentFields.line1).should('have.value', 'B'.repeat(76)); + cy.get(CommentFields.line2).should('have.value', 'C'.repeat(76)); + cy.get(CommentFields.line3).should('have.value', 'D'.repeat(76)); }, ); @@ -114,10 +117,10 @@ describe('FinesAccCommentsAddComponent', () => { () => { setupComponent(ADD_COMMENTS_FORM_STATE_ALPHANUMERIC_MOCK); - cy.get(DOM_ELEMENTS.commentField).should('have.value', 'Test123'); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', 'ABC123'); - cy.get(DOM_ELEMENTS.freeText2Field).should('have.value', 'ABC123'); - cy.get(DOM_ELEMENTS.freeText3Field).should('have.value', 'ABC123'); + cy.get(CommentFields.comment).should('have.value', 'Test123'); + cy.get(CommentFields.line1).should('have.value', 'ABC123'); + cy.get(CommentFields.line2).should('have.value', 'ABC123'); + cy.get(CommentFields.line3).should('have.value', 'ABC123'); }, ); @@ -130,37 +133,37 @@ describe('FinesAccCommentsAddComponent', () => { // AC3: Test character count displays correctly at maximum limits (0 remaining) setupComponent(ADD_COMMENTS_FORM_STATE_MAX_LENGTH_MOCK, mockFormSubmit); - cy.get(DOM_ELEMENTS.commentField).should('have.value', 'A'.repeat(30)); - cy.get(DOM_ELEMENTS.commentCharacterCount).should('contain', 'You have 0 characters remaining'); + cy.get(CommentFields.comment).should('have.value', 'A'.repeat(30)); + cy.get(CommentCharacterCounts.comment).should('contain', 'You have 0 characters remaining'); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', 'B'.repeat(76)); - cy.get(DOM_ELEMENTS.freeText1CharacterCount).should('contain', 'You have 0 characters remaining'); + cy.get(CommentFields.line1).should('have.value', 'B'.repeat(76)); + cy.get(CommentCharacterCounts.line1).should('contain', 'You have 0 characters remaining'); - cy.get(DOM_ELEMENTS.freeText2Field).should('have.value', 'C'.repeat(76)); - cy.get(DOM_ELEMENTS.freeText2CharacterCount).should('contain', 'You have 0 characters remaining'); + cy.get(CommentFields.line2).should('have.value', 'C'.repeat(76)); + cy.get(CommentCharacterCounts.line2).should('contain', 'You have 0 characters remaining'); - cy.get(DOM_ELEMENTS.freeText3Field).should('have.value', 'D'.repeat(76)); - cy.get(DOM_ELEMENTS.freeText3CharacterCount).should('contain', 'You have 0 characters remaining'); + cy.get(CommentFields.line3).should('have.value', 'D'.repeat(76)); + cy.get(CommentCharacterCounts.line3).should('contain', 'You have 0 characters remaining'); // AC3a: Test clearing all fields and verify no errors occur - cy.get(DOM_ELEMENTS.commentField).clear(); - cy.get(DOM_ELEMENTS.freeText1Field).clear(); - cy.get(DOM_ELEMENTS.freeText2Field).clear(); - cy.get(DOM_ELEMENTS.freeText3Field).clear(); + cy.get(CommentFields.comment).clear(); + cy.get(CommentFields.line1).clear(); + cy.get(CommentFields.line2).clear(); + cy.get(CommentFields.line3).clear(); - cy.get(DOM_ELEMENTS.commentField).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText2Field).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText3Field).should('have.value', ''); + cy.get(CommentFields.comment).should('have.value', ''); + cy.get(CommentFields.line1).should('have.value', ''); + cy.get(CommentFields.line2).should('have.value', ''); + cy.get(CommentFields.line3).should('have.value', ''); - cy.get(DOM_ELEMENTS.commentCharacterCount).should('contain', 'You have 30 characters remaining'); - cy.get(DOM_ELEMENTS.freeText1CharacterCount).should('contain', 'You have 76 characters remaining'); - cy.get(DOM_ELEMENTS.freeText2CharacterCount).should('contain', 'You have 76 characters remaining'); - cy.get(DOM_ELEMENTS.freeText3CharacterCount).should('contain', 'You have 76 characters remaining'); + cy.get(CommentCharacterCounts.comment).should('contain', 'You have 30 characters remaining'); + cy.get(CommentCharacterCounts.line1).should('contain', 'You have 76 characters remaining'); + cy.get(CommentCharacterCounts.line2).should('contain', 'You have 76 characters remaining'); + cy.get(CommentCharacterCounts.line3).should('contain', 'You have 76 characters remaining'); // AC2a: Should verify all fields are optional - cy.get(DOM_ELEMENTS.submitButton).should('not.be.disabled'); - cy.get(DOM_ELEMENTS.submitButton).click(); + cy.get(CommentActions.saveButton).should('not.be.disabled'); + cy.get(CommentActions.saveButton).click(); cy.get('@formSubmitSpy').should('have.been.calledOnce'); }, @@ -172,16 +175,16 @@ describe('FinesAccCommentsAddComponent', () => { () => { setupComponent(ADD_COMMENTS_FORM_STATE_NON_ALPHANUMERIC_MOCK); - cy.get(DOM_ELEMENTS.commentField).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText2Field).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText3Field).should('have.value', ''); + cy.get(CommentFields.comment).should('have.value', ''); + cy.get(CommentFields.line1).should('have.value', ''); + cy.get(CommentFields.line2).should('have.value', ''); + cy.get(CommentFields.line3).should('have.value', ''); - cy.get(DOM_ELEMENTS.submitButton).click(); + cy.get(CommentActions.saveButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); + cy.get(AccountCommentsAddLocators.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.commentError) + cy.get(CommentErrors.comment) .should('exist') .and('be.visible') .and( @@ -189,7 +192,7 @@ describe('FinesAccCommentsAddComponent', () => { 'Account comment must only include letters a to z, numbers 0-9 and certain special characters (hyphens, spaces, apostrophes)', ); - cy.get(DOM_ELEMENTS.freeText1Error) + cy.get(CommentErrors.line1) .should('exist') .and('be.visible') .and( @@ -197,7 +200,7 @@ describe('FinesAccCommentsAddComponent', () => { 'Free text 1 must only include letters a to z, numbers 0-9 and certain special characters (hyphens, spaces, apostrophes)', ); - cy.get(DOM_ELEMENTS.freeText2Error) + cy.get(CommentErrors.line2) .should('exist') .and('be.visible') .and( @@ -205,7 +208,7 @@ describe('FinesAccCommentsAddComponent', () => { 'Free text 2 must only include letters a to z, numbers 0-9 and certain special characters (hyphens, spaces, apostrophes)', ); - cy.get(DOM_ELEMENTS.freeText3Error) + cy.get(CommentErrors.line3) .should('exist') .and('be.visible') .and( @@ -221,31 +224,31 @@ describe('FinesAccCommentsAddComponent', () => { () => { setupComponent(ADD_COMMENTS_FORM_STATE_EXCEEDS_LIMITS_MOCK); - cy.get(DOM_ELEMENTS.commentField).should('have.value', 'A'.repeat(31)); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', 'B'.repeat(77)); - cy.get(DOM_ELEMENTS.freeText2Field).should('have.value', 'C'.repeat(77)); - cy.get(DOM_ELEMENTS.freeText3Field).should('have.value', 'D'.repeat(77)); + cy.get(CommentFields.comment).should('have.value', 'A'.repeat(31)); + cy.get(CommentFields.line1).should('have.value', 'B'.repeat(77)); + cy.get(CommentFields.line2).should('have.value', 'C'.repeat(77)); + cy.get(CommentFields.line3).should('have.value', 'D'.repeat(77)); - cy.get(DOM_ELEMENTS.submitButton).click(); + cy.get(CommentActions.saveButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); + cy.get(AccountCommentsAddLocators.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.commentError) + cy.get(CommentErrors.comment) .should('exist') .and('be.visible') .and('contain', 'Account note must be 30 characters or fewer'); - cy.get(DOM_ELEMENTS.freeText1Error) + cy.get(CommentErrors.line1) .should('exist') .and('be.visible') .and('contain', 'Free text 1 must be 76 characters or fewer'); - cy.get(DOM_ELEMENTS.freeText2Error) + cy.get(CommentErrors.line2) .should('exist') .and('be.visible') .and('contain', 'Free text 2 must be 76 characters or fewer'); - cy.get(DOM_ELEMENTS.freeText3Error) + cy.get(CommentErrors.line3) .should('exist') .and('be.visible') .and('contain', 'Free text 3 must be 76 characters or fewer'); @@ -261,31 +264,31 @@ describe('FinesAccCommentsAddComponent', () => { setupComponent(ADD_COMMENTS_FORM_STATE_MIXED_ERROR_MOCK, mockFormSubmit); // Verify we have the mixed error data loaded - cy.get(DOM_ELEMENTS.commentField).should('have.value', 'A'.repeat(31)); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', 'B'.repeat(77)); - cy.get(DOM_ELEMENTS.freeText2Field).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText3Field).should('have.value', 'C'.repeat(77)); + cy.get(CommentFields.comment).should('have.value', 'A'.repeat(31)); + cy.get(CommentFields.line1).should('have.value', 'B'.repeat(77)); + cy.get(CommentFields.line2).should('have.value', ''); + cy.get(CommentFields.line3).should('have.value', 'C'.repeat(77)); // Trigger validation errors - cy.get(DOM_ELEMENTS.submitButton).click(); - cy.get(DOM_ELEMENTS.errorSummary).should('exist'); - cy.get(DOM_ELEMENTS.commentError).should('exist'); + cy.get(CommentActions.saveButton).click(); + cy.get(AccountCommentsAddLocators.errorSummary).should('exist'); + cy.get(CommentErrors.comment).should('exist'); // Now clear the fields and enter valid data - cy.get(DOM_ELEMENTS.commentField).clear().type('Valid comment', { delay: 0 }); - cy.get(DOM_ELEMENTS.freeText1Field).clear().type('Valid free text 1', { delay: 0 }); - cy.get(DOM_ELEMENTS.freeText2Field).clear().type('Valid free text 2', { delay: 0 }); - cy.get(DOM_ELEMENTS.freeText3Field).clear().type('Valid free text 3', { delay: 0 }); + cy.get(CommentFields.comment).clear().type('Valid comment', { delay: 0 }); + cy.get(CommentFields.line1).clear().type('Valid free text 1', { delay: 0 }); + cy.get(CommentFields.line2).clear().type('Valid free text 2', { delay: 0 }); + cy.get(CommentFields.line3).clear().type('Valid free text 3', { delay: 0 }); // Submit with valid data - cy.get(DOM_ELEMENTS.submitButton).click(); + cy.get(CommentActions.saveButton).click(); cy.get('@formSubmitSpy').should('have.been.calledOnce'); // Verify error messages are cleared - cy.get(DOM_ELEMENTS.errorSummary).should('not.exist'); - cy.get(DOM_ELEMENTS.commentError).should('not.exist'); - cy.get(DOM_ELEMENTS.freeText1Error).should('not.exist'); - cy.get(DOM_ELEMENTS.freeText2Error).should('not.exist'); - cy.get(DOM_ELEMENTS.freeText3Error).should('not.exist'); + cy.get(AccountCommentsAddLocators.errorSummary).should('not.exist'); + cy.get(CommentErrors.comment).should('not.exist'); + cy.get(CommentErrors.line1).should('not.exist'); + cy.get(CommentErrors.line2).should('not.exist'); + cy.get(CommentErrors.line3).should('not.exist'); }, ); @@ -297,20 +300,20 @@ describe('FinesAccCommentsAddComponent', () => { setupComponent(ADD_COMMENTS_FORM_STATE_MOCK, mockFormSubmit); // Verify initial empty state - cy.get(DOM_ELEMENTS.commentField).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText2Field).should('have.value', ''); - cy.get(DOM_ELEMENTS.freeText3Field).should('have.value', ''); + cy.get(CommentFields.comment).should('have.value', ''); + cy.get(CommentFields.line1).should('have.value', ''); + cy.get(CommentFields.line2).should('have.value', ''); + cy.get(CommentFields.line3).should('have.value', ''); // AC5d: Verify the fields appear in the correct order in the DOM - cy.get(DOM_ELEMENTS.freeText1Field).should('exist'); - cy.get(DOM_ELEMENTS.freeText2Field).should('exist'); - cy.get(DOM_ELEMENTS.freeText3Field).should('exist'); + cy.get(CommentFields.line1).should('exist'); + cy.get(CommentFields.line2).should('exist'); + cy.get(CommentFields.line3).should('exist'); // Verify the order by checking their relative positions - cy.get(DOM_ELEMENTS.freeText1Field).then(($field1) => { - cy.get(DOM_ELEMENTS.freeText2Field).then(($field2) => { - cy.get(DOM_ELEMENTS.freeText3Field).then(($field3) => { + cy.get(CommentFields.line1).then(($field1) => { + cy.get(CommentFields.line2).then(($field2) => { + cy.get(CommentFields.line3).then(($field3) => { const field1Top = $field1[0].getBoundingClientRect().top; const field2Top = $field2[0].getBoundingClientRect().top; const field3Top = $field3[0].getBoundingClientRect().top; @@ -322,8 +325,8 @@ describe('FinesAccCommentsAddComponent', () => { }); // AC2a: Test that all fields are optional - submit with empty form - cy.get(DOM_ELEMENTS.submitButton).should('not.be.disabled'); - cy.get(DOM_ELEMENTS.submitButton).click(); + cy.get(CommentActions.saveButton).should('not.be.disabled'); + cy.get(CommentActions.saveButton).click(); cy.get('@formSubmitSpy').should('have.been.calledOnce'); }, ); @@ -337,12 +340,12 @@ describe('FinesAccCommentsAddComponent', () => { setupComponent(ADD_COMMENTS_FORM_STATE_ALPHANUMERIC_MOCK, mockFormSubmit); // Verify data is pre-filled - cy.get(DOM_ELEMENTS.commentField).should('have.value', 'Test123'); - cy.get(DOM_ELEMENTS.freeText1Field).should('have.value', 'ABC123'); + cy.get(CommentFields.comment).should('have.value', 'Test123'); + cy.get(CommentFields.line1).should('have.value', 'ABC123'); // Don't make any changes - just click Save comment button - cy.get(DOM_ELEMENTS.submitButton).should('not.be.disabled'); - cy.get(DOM_ELEMENTS.submitButton).click(); + cy.get(CommentActions.saveButton).should('not.be.disabled'); + cy.get(CommentActions.saveButton).click(); // Verify form submission was triggered even without changes (AC8a - API call will be made) cy.get('@formSubmitSpy').should('have.been.calledOnce'); diff --git a/cypress/component/fineAccountEnquiry/viewDefendantAccountSummary/addComments/constants/add_comments_elements.ts b/cypress/component/fineAccountEnquiry/viewDefendantAccountSummary/addComments/constants/add_comments_elements.ts deleted file mode 100644 index 0914d536df..0000000000 --- a/cypress/component/fineAccountEnquiry/viewDefendantAccountSummary/addComments/constants/add_comments_elements.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const DOM_ELEMENTS = { - app: '#app-fines-acc-comments-add', - heading: '.govuk-\!-margin-bottom-30', - form: 'form.ng-untouched', - commentField: '#facc_add_comment', - freeText1Field: '#facc_add_free_text_1', - freeText2Field: '#facc_add_free_text_2', - freeText3Field: '#facc_add_free_text_3', - submitButton: '#save-comments', - cancelButton: '.govuk-link', - errorSummary: '.govuk-error-summary', - commentError: '#facc_add_comment-error-message', - freeText1Error: '#facc_add_free_text_1-error-message', - freeText2Error: '#facc_add_free_text_2-error-message', - freeText3Error: '#facc_add_free_text_3-error-message', - commentCharacterCount: '#facc_add_comment ~ .govuk-character-count__message.govuk-character-count__status', - freeText1CharacterCount: '#facc_add_free_text_1 ~ .govuk-character-count__message.govuk-character-count__status', - freeText2CharacterCount: '#facc_add_free_text_2 ~ .govuk-character-count__message.govuk-character-count__status', - freeText3CharacterCount: '#facc_add_free_text_3 ~ .govuk-character-count__message.govuk-character-count__status', -}; diff --git a/cypress/shared/selectors/account-details/account.comments.details.locators.ts b/cypress/shared/selectors/account-details/account.comments.details.locators.ts index 5b80d7ebdf..68484ed80d 100644 --- a/cypress/shared/selectors/account-details/account.comments.details.locators.ts +++ b/cypress/shared/selectors/account-details/account.comments.details.locators.ts @@ -3,9 +3,8 @@ * @description * Stable, ID-first selectors for the **Comments** (Add comments) page. * - * Notes: - * - All selectors are scoped from
to avoid header/footer collisions. + * - Selectors prefer `
` scoping when available and include fallbacks for component mounts. * - Prefers explicit element IDs found in the provided DOM. */ export const AccountCommentsAddLocators = { @@ -16,15 +15,18 @@ export const AccountCommentsAddLocators = { // Header // ────────────────────────────── /** Page header element that contains "Comments". */ - header: 'main[role="main"] h1.govuk-heading-l', + header: 'main[role="main"] h1.govuk-heading-l, h1.govuk-heading-l', /** Caption beneath the header (e.g. "25000001E - Mr John ACCDETAILSURNAME"). */ - headerCaption: 'main[role="main"] h1.govuk-heading-l .govuk-caption-l', + headerCaption: 'main[role="main"] h1.govuk-heading-l .govuk-caption-l, h1.govuk-heading-l .govuk-caption-l', // ────────────────────────────── // Form + Fields // ────────────────────────────── /** Root form element for the Comments page. */ - form: 'main[role="main"] form', + form: 'main[role="main"] form, form', + + /** Top-level GOV.UK error summary shown when validation fails. */ + errorSummary: '.govuk-error-summary', fields: { /** Top comment field (30 char limit). */ @@ -37,6 +39,22 @@ export const AccountCommentsAddLocators = { line3: 'textarea#facc_add_free_text_3', }, + /** Inline validation errors for each text area. */ + errors: { + comment: '#facc_add_comment-error-message', + line1: '#facc_add_free_text_1-error-message', + line2: '#facc_add_free_text_2-error-message', + line3: '#facc_add_free_text_3-error-message', + }, + + /** Remaining-character status text shown beneath each text area. */ + characterCounts: { + comment: '#facc_add_comment ~ .govuk-character-count__message.govuk-character-count__status', + line1: '#facc_add_free_text_1 ~ .govuk-character-count__message.govuk-character-count__status', + line2: '#facc_add_free_text_2 ~ .govuk-character-count__message.govuk-character-count__status', + line3: '#facc_add_free_text_3 ~ .govuk-character-count__message.govuk-character-count__status', + }, + // ────────────────────────────── // Actions // ────────────────────────────── @@ -44,6 +62,6 @@ export const AccountCommentsAddLocators = { /** Primary submit button to save comments. */ saveButton: 'button#save-comments[type="submit"]', /** Cancel link beneath the form. */ - cancelLink: 'main[role="main"] a.govuk-link.button-link', + cancelLink: 'main[role="main"] a.govuk-link.button-link, a.govuk-link.button-link', }, } as const; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/defendant_details_elements.ts b/cypress/shared/selectors/account-enquiry/account.enquiry.defendant-details.locators.ts similarity index 89% rename from cypress/component/fineAccountEnquiry/accountEnquiry/constants/defendant_details_elements.ts rename to cypress/shared/selectors/account-enquiry/account.enquiry.defendant-details.locators.ts index aecbe7f2e5..15ceec5973 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/defendant_details_elements.ts +++ b/cypress/shared/selectors/account-enquiry/account.enquiry.defendant-details.locators.ts @@ -1,5 +1,12 @@ -// Stable selectors / visible text hooks for the Defendant Details page. - +/** + * @file account.enquiry.defendant-details.locators.ts + * @description + * Shared selector and text-hook map for Account Enquiry defendant and company details tabs. + * + * @remarks + * - Preserves the legacy export name used by component specs to keep migration mechanical. + * - Includes a small number of visible-text hooks that existing tests assert directly. + */ export const DEFENDANT_DETAILS = { // Defendant details table defendantTitle: '.govuk-summary-card__title', @@ -38,6 +45,7 @@ export const DEFENDANT_DETAILS = { labelDefendant: 'Defendant', labelPaymentTerms: 'Payment terms', labelEnforcementStatus: 'Enforcement status', + // Company details table companyTitle: '.govuk-summary-card__title', companyName: '#companyDetailsNameValue', @@ -63,10 +71,11 @@ export const DEFENDANT_DETAILS = { linkText: 'a[class="govuk-link govuk-link--no-visited-state"]', badgeBlue: 'span[class="govuk-!-margin-bottom-2 moj-badge moj-badge--blue"]', badgeRed: 'span[class="govuk-!-margin-bottom-2 moj-badge moj-badge--red"]', + // Language preferences details table documentLanguage: '#languagePreferencesDocument_languageValue', courtHearingLanguage: '#languagePreferencesHearing_languageValue', // Links defendantChange: 'a[class="govuk-!-margin-bottom-0 govuk-link"]', -}; +} as const; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_fixed_penalty_elements.ts b/cypress/shared/selectors/account-enquiry/account.enquiry.fixed-penalty.locators.ts similarity index 82% rename from cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_fixed_penalty_elements.ts rename to cypress/shared/selectors/account-enquiry/account.enquiry.fixed-penalty.locators.ts index f286cf65c1..3ce4ea10bf 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_fixed_penalty_elements.ts +++ b/cypress/shared/selectors/account-enquiry/account.enquiry.fixed-penalty.locators.ts @@ -1,5 +1,11 @@ -// Stable selectors / visible text hooks for the Defendant Details page. - +/** + * @file account.enquiry.fixed-penalty.locators.ts + * @description + * Shared selector map for the Account Enquiry fixed-penalty tab. + * + * @remarks + * - Preserves the legacy export name used by component specs to keep migration mechanical. + */ export const ACCOUNT_ENQUIRY_FIXED_PENALTY_ELEMENTS = { headingWithCaption: 'opal-lib-govuk-heading-with-caption', headingName: 'h1.govuk-heading-l', @@ -27,4 +33,4 @@ export const ACCOUNT_ENQUIRY_FIXED_PENALTY_ELEMENTS = { labelNoticeDate: '#fixedPenaltyDetailsIssued_dateValue', labelTimeOfOffence: '#fixedPenaltyDetailsTime_of_offenceValue', labelPlaceOfOffence: '#fixedPenaltyDetailsPlace_of_offenceValue', -}; +} as const; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_header_elements.ts b/cypress/shared/selectors/account-enquiry/account.enquiry.header.locators.ts similarity index 81% rename from cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_header_elements.ts rename to cypress/shared/selectors/account-enquiry/account.enquiry.header.locators.ts index a9bf42a925..9fa1e74e1b 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_header_elements.ts +++ b/cypress/shared/selectors/account-enquiry/account.enquiry.header.locators.ts @@ -1,5 +1,13 @@ -// Stable selectors / visible text hooks for Account Enquiry header pages. - +/** + * @file account.enquiry.header.locators.ts + * @description + * Shared selector and text-hook map for the Account Enquiry header shell and + * shared summary widgets. + * + * @remarks + * - Preserves the legacy export name used by component specs to keep migration mechanical. + * - Includes a small number of visible-text hooks that existing tests assert directly. + */ export const ACCOUNT_ENQUIRY_HEADER_ELEMENTS = { headingWithCaption: 'opal-lib-govuk-heading-with-caption', headingName: 'h1.govuk-heading-l', @@ -46,4 +54,4 @@ export const ACCOUNT_ENQUIRY_HEADER_ELEMENTS = { // Minor creditor info fields minorCreditorAccountType: '#minor-creditor-account-type', minorCreditorBusinessUnit: '#minor-creditor-business-unit', -}; +} as const; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/defendant_parent_or_guardian_elements.ts b/cypress/shared/selectors/account-enquiry/account.enquiry.parent-guardian-details.locators.ts similarity index 87% rename from cypress/component/fineAccountEnquiry/accountEnquiry/constants/defendant_parent_or_guardian_elements.ts rename to cypress/shared/selectors/account-enquiry/account.enquiry.parent-guardian-details.locators.ts index d84fb7a2d1..cea7606943 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/defendant_parent_or_guardian_elements.ts +++ b/cypress/shared/selectors/account-enquiry/account.enquiry.parent-guardian-details.locators.ts @@ -1,4 +1,11 @@ -// Element selectors for Parent or Guardian details +/** + * @file account.enquiry.parent-guardian-details.locators.ts + * @description + * Shared selector map for the Account Enquiry parent-or-guardian tab. + * + * @remarks + * - Preserves the legacy export name used by component specs to keep migration mechanical. + */ export const DOM_ELEMENTS = { // Personal Details parentOrGuardianDetailsName: '#parentOrGuardianDetailsNameValue', @@ -33,4 +40,4 @@ export const DOM_ELEMENTS = { // Account Comments accountCommentsNotesKey: '#accountCommentsNotesKey', -}; +} as const; diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_payment_terms_elements.ts b/cypress/shared/selectors/account-enquiry/account.enquiry.payment-terms.locators.ts similarity index 84% rename from cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_payment_terms_elements.ts rename to cypress/shared/selectors/account-enquiry/account.enquiry.payment-terms.locators.ts index 0a84b185db..71886b9d11 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/account_enquiry_payment_terms_elements.ts +++ b/cypress/shared/selectors/account-enquiry/account.enquiry.payment-terms.locators.ts @@ -1,5 +1,11 @@ -// Stable selectors / visible text hooks for the Defendant Details page. - +/** + * @file account.enquiry.payment-terms.locators.ts + * @description + * Shared selector map for the Account Enquiry payment-terms tab and related flows. + * + * @remarks + * - Preserves the legacy export name used by component specs to keep migration mechanical. + */ export const ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS = { headingWithCaption: 'opal-lib-govuk-heading-with-caption', headingName: 'h1.govuk-heading-l', @@ -35,4 +41,4 @@ export const ACCOUNT_ENQUIRY_PAYMENT_TERMS_ELEMENTS = { dateLastAmended: '#payment-terms-amendmentsDate-last-amendedValue', lastAmendedBy: '#payment-terms-amendmentsLast-amended-byValue', amendmentReason: '#payment-terms-amendmentsAmendement-reasonValue', -}; +} as const; diff --git a/cypress/shared/selectors/account-enquiry/account.enquiry.results.locators.ts b/cypress/shared/selectors/account-enquiry/account.enquiry.results.locators.ts index 721b89c4a5..7128c5b154 100644 --- a/cypress/shared/selectors/account-enquiry/account.enquiry.results.locators.ts +++ b/cypress/shared/selectors/account-enquiry/account.enquiry.results.locators.ts @@ -33,7 +33,10 @@ export const AccountEnquiryResultsLocators = { /** The main page heading (for example, "Search results"). */ heading: 'h1.govuk-heading-l', - /** Back link to return to the Account Search page. */ + /** Back-link component host rendered above the results heading. */ + backLinkHost: 'opal-lib-govuk-back-link', + + /** Back link anchor rendered inside the GOV.UK back-link component. */ backLink: 'a.govuk-back-link', }, @@ -46,8 +49,51 @@ export const AccountEnquiryResultsLocators = { /** Heading that appears when there are no matching results. */ noResultsHeading: 'h2.govuk-heading-m', + /** Paragraph text shown in the no-results state. */ + noResultsText: 'p.govuk-body-m', + /** "Check your search" link in the no-results paragraph. */ checkYourSearchLink: 'p.govuk-body-m a.govuk-link', + + /** Heading that appears when the results exceed the supported threshold. */ + tooManyResultsHeading: 'h2.govuk-heading-m', + + /** Paragraph text shown in the too-many-results state. */ + tooManyResultsText: 'p.govuk-body-m', + + /** "Try adding more information" link in the too-many-results paragraph. */ + addMoreInfoLink: 'p.govuk-body-m a.govuk-link', + }, + + // ────────────────────────────── + // Multi-result tabs + // ────────────────────────────── + + /** Tabs rendered when the search returns multiple result types. */ + tabs: { + /** Results tabset container. */ + container: 'opal-lib-govuk-tabs, #resultTypes', + + /** GOV.UK list wrapping all result-type tabs. */ + list: '.govuk-tabs__list', + + /** Individuals results tab. */ + individualsTab: '[tabitemid="tab-individuals"]', + + /** Companies results tab. */ + companiesTab: '[tabitemid="tab-companies"]', + + /** Minor creditors results tab. */ + minorCreditorsTab: '[tabitemid="tab-minor-creditors"]', + + /** Individuals tab panel. */ + individualsPanel: '#individuals', + + /** Companies tab panel. */ + companiesPanel: '#companies', + + /** Minor creditors tab panel. */ + minorCreditorsPanel: '#minorCreditors', }, // ────────────────────────────── @@ -87,15 +133,64 @@ export const AccountEnquiryResultsLocators = { ni: 'thead [columnkey="NI number"] button', pg: 'thead [columnkey="Parent or guardian"] button', bu: 'thead [columnkey="Business unit"] button', + defendant: 'thead [columnkey="Defendant"] button', ref: 'thead [columnkey="Ref"] button', enf: 'thead [columnkey="Enf"] button', balance: 'thead [columnkey="Balance"] button', }, + /** Header-cell selectors keyed by their visible column. */ + headerCells: { + account: 'th[columnkey="Account"]', + name: 'th[columnkey="Name"]', + aliases: 'th[columnkey="Aliases"]', + dob: 'th[columnkey="Date of birth"]', + addr1: 'th[columnkey="Address line 1"]', + postcode: 'th[columnkey="Postcode"]', + ni: 'th[columnkey="NI number"]', + pg: 'th[columnkey="Parent or guardian"]', + bu: 'th[columnkey="Business unit"]', + defendant: 'th[columnkey="Defendant"]', + ref: 'th[columnkey="Ref"]', + enf: 'th[columnkey="Enf"]', + balance: 'th[columnkey="Balance"]', + }, + // ────────────────────────────── // Pagination // ────────────────────────────── pagination: { + /** Pagination component root. */ + root: 'opal-lib-moj-pagination', + + /** Visible pagination results summary text. */ + resultsText: '.moj-pagination__results', + + /** Previous-page control. */ + previousButton: '.govuk-pagination__prev', + + /** Next-page control wrapper. */ + nextButton: '.govuk-pagination__next', + + /** List container for numbered pagination items. */ + list: '.govuk-pagination__list', + + /** Individual numbered pagination item. */ + listItem: '.govuk-pagination__item', + + /** Ellipsis item rendered in condensed pagination layouts. */ + listItemEllipses: '.govuk-pagination__item--ellipses', + + /** Currently selected page number. */ + currentPage: '.govuk-pagination__item--current', + + /** + * Dynamic selector for a visible page-number item. + * @param pageNum - Visible page number text. + * @returns Selector for the pagination item matching the provided page number. + */ + pageNumber: (pageNum: number | string) => `.govuk-pagination__item:contains("${pageNum}")`, + next: 'nav.govuk-pagination .govuk-pagination__next a.govuk-pagination__link', }, diff --git a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/global_version_control_elements.ts b/cypress/shared/selectors/account-enquiry/account.enquiry.version-control.locators.ts similarity index 80% rename from cypress/component/fineAccountEnquiry/accountEnquiry/constants/global_version_control_elements.ts rename to cypress/shared/selectors/account-enquiry/account.enquiry.version-control.locators.ts index ea3a61c8e3..6ca4e200bf 100644 --- a/cypress/component/fineAccountEnquiry/accountEnquiry/constants/global_version_control_elements.ts +++ b/cypress/shared/selectors/account-enquiry/account.enquiry.version-control.locators.ts @@ -1,3 +1,11 @@ +/** + * @file account.enquiry.version-control.locators.ts + * @description + * Shared selector map for account-enquiry version-control banners and shell tab navigation. + * + * @remarks + * - Preserves the legacy export name used by component specs to keep migration mechanical. + */ export const DOM_ELEMENTS = { // Warning Banner Elements warningBanner: '.moj-alert', @@ -20,4 +28,4 @@ export const DOM_ELEMENTS = { parentGuardianTab: '[subnavitemid="parent-or-guardian-tab"] > .moj-sub-navigation__link', paymentTermsTab: '[subnavitemid="payment-terms-tab"] > .moj-sub-navigation__link', enforcementTab: '[subnavitemid="enforcement-tab"] > .moj-sub-navigation__link', -}; +} as const; diff --git a/cypress/shared/selectors/account-search/account.search.common.locators.ts b/cypress/shared/selectors/account-search/account.search.common.locators.ts index dc77684697..64d5c37e1c 100644 --- a/cypress/shared/selectors/account-search/account.search.common.locators.ts +++ b/cypress/shared/selectors/account-search/account.search.common.locators.ts @@ -18,12 +18,36 @@ export const AccountSearchCommonLocators = { /** Root of the Search screen (any tab). Useful for scoping queries. */ root: 'app-fines-sa-search, [data-testid="fines-sa-search"]', + /** Top-level page heading for the account search form. */ + pageHeader: 'app-fines-sa-search-account-form > h1.govuk-heading-l', + + /** Global error summary shown above the search form. */ + errorSummary: 'opal-lib-govuk-error-summary, .govuk-error-summary', + + /** Summary list for the selected business unit filter. */ + businessUnitSummaryList: '[summaryListId="accountDetails"]', + + /** Optional business unit badge shown in the summary value. */ + businessUnitBadge: '.business-unit-badge', + + /** Label for the shared account number field. */ + accountNumberLabel: '[for="fsa_search_account_number"]', + /** Account number input present on all tabs. */ accountNumberInput: '#fsa_search_account_number', + /** Inline validation error for account number. */ + accountNumberError: '#fsa_search_account_number-error-message', + + /** Label for the shared reference or case number field. */ + referenceOrCaseNumberLabel: '[for="fsa_search_account_reference_case_number"]', + /** Reference or case number input present on all tabs. */ referenceOrCaseNumberInput: '#fsa_search_account_reference_case_number', + /** Inline validation error for reference or case number. */ + referenceOrCaseNumberError: '#fsa_search_account_reference_case_number-error-message', + /** Global filter: "Active accounts only" checkbox (outside tab panels). */ activeAccountsOnlyCheckbox: '#fsa_search_account_active_accounts_only', diff --git a/cypress/shared/selectors/account-search/account.search.companies.locators.ts b/cypress/shared/selectors/account-search/account.search.companies.locators.ts index b1fe939c27..d706ac7671 100644 --- a/cypress/shared/selectors/account-search/account.search.companies.locators.ts +++ b/cypress/shared/selectors/account-search/account.search.companies.locators.ts @@ -126,18 +126,36 @@ export const AccountSearchCompaniesLocators = { /** Company name input field. */ companyNameInput: '#fsa_search_account_companies_company_name', + /** Label for the company name input field. */ + companyNameLabel: '[for="fsa_search_account_companies_company_name"]', + /** Checkbox to enforce exact company name match. */ companyNameExactMatchCheckbox: '#fsa_search_account_companies_company_name_exact_match', + /** Inline validation error for company name. */ + companyNameError: '#fsa_search_account_companies_company_name-error-message', + /** Checkbox to include aliases in company search. */ includeAliasesCheckbox: '#fsa_search_account_companies_include_aliases', /** Address line 1 input field. */ addressLine1Input: '#fsa_search_account_companies_address_line_1', + /** Label for the address line 1 input field. */ + addressLine1Label: '[for="fsa_search_account_companies_address_line_1"]', + + /** Inline validation error for address line 1. */ + addressLine1Error: '#fsa_search_account_companies_address_line_1-error-message', + /** Postcode input field. */ postCodeInput: '#fsa_search_account_companies_post_code', + /** Label for the postcode input field. */ + postCodeLabel: '[for="fsa_search_account_companies_post_code"]', + + /** Inline validation error for postcode. */ + postCodeError: '#fsa_search_account_companies_post_code-error-message', + /** Root selector for the search form component. */ searchFormRoot: 'app-fines-sa-search, [data-testid="fines-sa-search"]', }; diff --git a/cypress/shared/selectors/account-search/account.search.filter-by-bu.common.locators.ts b/cypress/shared/selectors/account-search/account.search.filter-by-bu.common.locators.ts index cee129f961..64694028a2 100644 --- a/cypress/shared/selectors/account-search/account.search.filter-by-bu.common.locators.ts +++ b/cypress/shared/selectors/account-search/account.search.filter-by-bu.common.locators.ts @@ -30,4 +30,13 @@ export const SearchFilterByBUCommonLocators = { /** Cancel link at the bottom of the form. */ cancelLink: 'opal-lib-govuk-cancel-link a.govuk-link.button-link', + + /** Error summary wrapper rendered above the sub-navigation. */ + errorSummary: 'opal-lib-govuk-error-summary, .govuk-error-summary', + + /** Error summary title element. */ + errorSummaryTitle: '.govuk-error-summary__title', + + /** Error summary list containing validation messages. */ + errorSummaryList: '.govuk-error-summary__list', }; diff --git a/cypress/shared/selectors/account-search/account.search.individuals.locators.ts b/cypress/shared/selectors/account-search/account.search.individuals.locators.ts index 427d058efe..9673eb9706 100644 --- a/cypress/shared/selectors/account-search/account.search.individuals.locators.ts +++ b/cypress/shared/selectors/account-search/account.search.individuals.locators.ts @@ -52,6 +52,9 @@ export const AccountSearchIndividualsLocators = { /** Panel element containing all individual search input fields. */ individualsPanel: '#individuals .govuk-tabs__panel', + /** Inner Individuals panel heading. */ + individualsHeader: '#individuals h1.govuk-heading-l', + // ────────────────────────────── // Name fields // ────────────────────────────── @@ -59,15 +62,27 @@ export const AccountSearchIndividualsLocators = { /** Last name input field. */ lastNameInput: '#fsa_search_account_individuals_last_name', + /** Label for the last name input field. */ + lastNameLabel: '[for="fsa_search_account_individuals_last_name"]', + /** Checkbox to restrict last name search to exact matches only. */ lastNameExactMatchCheckbox: '#fsa_search_account_individuals_last_name_exact_match', + /** Inline validation error for last name. */ + lastNameError: '#fsa_search_account_individuals_last_name-error-message', + /** First name input field. */ firstNameInput: '#fsa_search_account_individuals_first_names', + /** Label for the first names input field. */ + firstNamesLabel: '[for="fsa_search_account_individuals_first_names"]', + /** Checkbox to restrict first name search to exact matches only. */ firstNamesExactMatchCheckbox: '#fsa_search_account_individuals_first_names_exact_match', + /** Inline validation error for first names. */ + firstNamesError: '#fsa_search_account_individuals_first_names-error-message', + /** Checkbox to include known aliases in search. */ includeAliasesCheckbox: '#fsa_search_account_individuals_include_aliases', @@ -78,12 +93,21 @@ export const AccountSearchIndividualsLocators = { /** Input for date of birth (uses MOJ date picker). */ dobInput: '#fsa_search_account_individuals_date_of_birth', + /** Label for the date of birth input. */ + dobLabel: '[for="fsa_search_account_individuals_date_of_birth"]', + + /** Inline validation error for date of birth. */ + dobError: '#fsa_search_account_individuals_date_of_birth-error-message', + /** Date picker modal dialog container. */ dobCalendarDialog: '#datepicker-fsa_search_account_individuals_date_of_birth', /** Button to open the date picker modal. */ dobOpenButton: '.moj-js-datepicker-toggle', + /** Button to move the date picker to the previous month. */ + dobPreviousMonthButton: '.moj-datepicker__button.moj-js-datepicker-prev-month', + /** Button to confirm selected date in date picker. */ dobSelectButton: '.moj-datepicker__button.moj-js-datepicker-ok', @@ -97,12 +121,30 @@ export const AccountSearchIndividualsLocators = { /** National Insurance Number input field. */ niNumberInput: '#fsa_search_account_individuals_national_insurance_number', + /** Label for the National Insurance number input field. */ + niNumberLabel: '[for="fsa_search_account_individuals_national_insurance_number"]', + + /** Inline validation error for National Insurance number. */ + niNumberError: '#fsa_search_account_individuals_national_insurance_number-error-message', + /** Address Line 1 input field. */ addressLine1Input: '#fsa_search_account_individuals_address_line_1', + /** Label for the Address Line 1 input field. */ + addressLine1Label: '[for="fsa_search_account_individuals_address_line_1"]', + + /** Inline validation error for Address Line 1. */ + addressLine1Error: '#fsa_search_account_individuals_address_line_1-error-message', + /** Postcode input field. */ postcodeInput: '#fsa_search_account_individuals_post_code', + /** Label for the postcode input field. */ + postcodeLabel: '[for="fsa_search_account_individuals_post_code"]', + + /** Inline validation error for postcode. */ + postcodeError: '#fsa_search_account_individuals_post_code-error-message', + // ────────────────────────────── // Dashboard navigation // ────────────────────────────── diff --git a/cypress/shared/selectors/account-search/account.search.major-creditors.locators.ts b/cypress/shared/selectors/account-search/account.search.major-creditors.locators.ts index 6100648d38..daf3cdc90b 100644 --- a/cypress/shared/selectors/account-search/account.search.major-creditors.locators.ts +++ b/cypress/shared/selectors/account-search/account.search.major-creditors.locators.ts @@ -22,4 +22,31 @@ export const AccountSearchMajorCreditorsLocators = { /** Optional heading within panel, if needed. */ heading: '#majorCreditors h1.govuk-heading-l', }, + + autocomplete: { + /** Hint text rendered above the autocomplete input. */ + hint: '#fsa_search_account_major_creditors_major_creditor_id-hint', + /** Accessible autocomplete text input. */ + input: '#fsa_search_account_major_creditors_major_creditor_id-autocomplete', + /** Listbox shown when autocomplete suggestions are expanded. */ + listbox: '#fsa_search_account_major_creditors_major_creditor_id-autocomplete__listbox', + /** Inline validation error rendered against the autocomplete input. */ + error: '#fsa_search_account_major_creditors_major_creditor_id-autocomplete-error-message', + }, + + businessUnitRequirement: { + /** Message shown when more than one business unit is selected. */ + message: '#majorCreditors .govuk-body', + /** Inline link back to the business-unit filter page. */ + link: '#majorCreditors .govuk-body > .govuk-link', + }, + + selectFallback: { + /** Label for the underlying select element, when present. */ + label: '[for="fsa_search_account_major_creditors_major_creditor_id"]', + /** Backing select used by the accessible autocomplete component. */ + input: '#fsa_search_account_major_creditors_major_creditor_id', + /** Inline validation error rendered against the backing select. */ + error: '#fsa_search_account_major_creditors_major_creditor_id-error-message', + }, }; diff --git a/cypress/shared/selectors/account-search/account.search.minor-creditors.locators.ts b/cypress/shared/selectors/account-search/account.search.minor-creditors.locators.ts index 73f5f4d926..d6aa6f9a7c 100644 --- a/cypress/shared/selectors/account-search/account.search.minor-creditors.locators.ts +++ b/cypress/shared/selectors/account-search/account.search.minor-creditors.locators.ts @@ -51,25 +51,41 @@ export const AccountSearchMinorCreditorsLocators = { // Individual sub-form fields (within conditional) // ────────────────────────────── individual: { + lastNameLabel: '[for="fsa_search_account_minor_creditors_last_name"]', lastNameInput: '#fsa_search_account_minor_creditors_last_name', lastNameExactMatchCheckbox: '#fsa_search_account_minor_creditors_last_name_exact_match', + lastNameError: '#fsa_search_account_minor_creditors_last_name-error-message', + firstNamesLabel: '[for="fsa_search_account_minor_creditors_first_names"]', firstNamesInput: '#fsa_search_account_minor_creditors_first_names', firstNamesExactMatchCheckbox: '#fsa_search_account_minor_creditors_first_names_exact_match', + firstNamesError: '#fsa_search_account_minor_creditors_first_names-error-message', + addressLine1Label: '[for="fsa_search_account_minor_creditors_individual_address_line_1"]', addressLine1Input: '#fsa_search_account_minor_creditors_individual_address_line_1', + addressLine1Error: '#fsa_search_account_minor_creditors_individual_address_line_1-error-message', + + postcodeLabel: '[for="fsa_search_account_minor_creditors_individual_post_code"]', postcodeInput: '#fsa_search_account_minor_creditors_individual_post_code', + postcodeError: '#fsa_search_account_minor_creditors_individual_post_code-error-message', }, // ────────────────────────────── // Company sub-form fields (within conditional) // ────────────────────────────── company: { + companyNameLabel: '[for="fsa_search_account_minor_creditors_company_name"]', companyNameInput: '#fsa_search_account_minor_creditors_company_name', companyNameExactMatchCheckbox: '#fsa_search_account_minor_creditors_company_name_exact_match', + companyNameError: '#fsa_search_account_minor_creditors_company_name-error-message', + companyAddressLine1Label: '[for="fsa_search_account_minor_creditors_company_address_line_1"]', companyAddressLine1Input: '#fsa_search_account_minor_creditors_company_address_line_1', + companyAddressLine1Error: '#fsa_search_account_minor_creditors_company_address_line_1-error-message', + + companyPostcodeLabel: '[for="fsa_search_account_minor_creditors_company_post_code"]', companyPostcodeInput: '#fsa_search_account_minor_creditors_company_post_code', + companyPostcodeError: '#fsa_search_account_minor_creditors_company_post_code-error-message', }, } as const; diff --git a/cypress/shared/selectors/account-search/account.search.nav.locators.ts b/cypress/shared/selectors/account-search/account.search.nav.locators.ts index 96df830a48..d17140b582 100644 --- a/cypress/shared/selectors/account-search/account.search.nav.locators.ts +++ b/cypress/shared/selectors/account-search/account.search.nav.locators.ts @@ -16,6 +16,12 @@ */ export const AccountSearchNavLocators = { + /** Tabs component wrapping the account-search tab set. */ + tabsContainer: 'opal-lib-govuk-tabs, #defendantTabs', + + /** GOV.UK tab list rendered within the tabs component. */ + tabsList: '.govuk-tabs__list', + /** Individuals tab toggle */ individualsTab: '[tabitemid="tab-individuals"]',