Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
e5e5d82
HPDI-4063 Adding caseManagementCategory as top level field
spnaik77 Mar 31, 2026
90cf6e1
HDPI-4063 Change caseManagementCategory to Dynamic List
toby-plunkett Apr 1, 2026
c7109b9
HDPI-4063 Change caseManagementLocation to CaseLocation type
toby-plunkett Apr 1, 2026
78e1234
Merge branch 'master' into HPDI-4063-caseManagementCategory-b
toby-plunkett Apr 7, 2026
c8ffc49
HDPI-4063 Styling and tests
toby-plunkett Apr 7, 2026
a2ae320
HDPI-4063 Styling and tests
toby-plunkett Apr 7, 2026
1df1fa6
Merge branch 'master' into HPDI-4063-caseManagementCategory-b
toby-plunkett Apr 8, 2026
c69133d
HDPI-4063 Set case location in test to final field
toby-plunkett Apr 8, 2026
3e1939f
Merge remote-tracking branch 'origin/HPDI-4063-caseManagementCategory…
toby-plunkett Apr 8, 2026
773aa20
Merge branch 'master' into debugglobalsearch
adusumillipraveen Apr 10, 2026
01d2cf4
Merge branch 'master' into HPDI-4063-caseManagementCategory-b
toby-plunkett Apr 10, 2026
9823795
HDPI-4161 Create and grant GS roles.
toby-plunkett Apr 10, 2026
76610f7
HDPI-4161 adjust so role assignments to allow for internal and extern…
toby-plunkett Apr 10, 2026
d905605
Merge branch 'master' into debugglobalsearch
adusumillipraveen Apr 13, 2026
30fcc91
try overriding env vars
adusumillipraveen Apr 13, 2026
2479362
Merge branch 'debugglobalsearch' of github.com:hmcts/pcs-api into deb…
adusumillipraveen Apr 13, 2026
c00584d
try
adusumillipraveen Apr 13, 2026
7eacfa9
add tests
adusumillipraveen Apr 13, 2026
db7ef83
fix
adusumillipraveen Apr 13, 2026
196268a
fix
adusumillipraveen Apr 13, 2026
1971be3
revert
adusumillipraveen Apr 13, 2026
25250ca
try
adusumillipraveen Apr 14, 2026
67a3066
Merge branch 'debugglobalsearch' of github.com:hmcts/pcs-api into deb…
adusumillipraveen Apr 14, 2026
df0a43c
try with pcs
adusumillipraveen Apr 14, 2026
4f231af
revert
adusumillipraveen Apr 14, 2026
c3be642
fix try
adusumillipraveen Apr 14, 2026
a958716
fix
adusumillipraveen Apr 14, 2026
aaf0226
Merge branch 'master' into debugglobalsearch
toby-plunkett Apr 20, 2026
10c4367
testing
toby-plunkett Apr 21, 2026
1575542
HDPI-6150 Whitelist pcs-api
toby-plunkett Apr 22, 2026
ba03bb6
HDPI-6150 Whitelist pcs-api
toby-plunkett Apr 22, 2026
eb1f171
HDPI-6150 Whitelist pcs-api typo
toby-plunkett Apr 23, 2026
664ea45
HDPI-6150 Adjust Helm chart to whitelist pcs
toby-plunkett Apr 23, 2026
503ea8e
HDPI-6150 remove autoindex
toby-plunkett Apr 23, 2026
0936ad1
HDPI-6150 update pipeline to make the api call
toby-plunkett Apr 23, 2026
4c0b41d
HDPI-6150 check env vars are set
toby-plunkett Apr 23, 2026
3efafd2
HDPI-6150 check env vars are set
toby-plunkett Apr 23, 2026
7c45241
HDPI-6150 pull in vars from keyvault
toby-plunkett Apr 23, 2026
8c4a32a
HDPI-6150 remove ccd definition store var from local
toby-plunkett Apr 23, 2026
4899673
HDPI-6150 remove whitespace
toby-plunkett Apr 24, 2026
546031e
Merge branch 'master' into HDPI-6150-Call-ElasticSearch-endpoint-via-…
toby-plunkett Apr 24, 2026
58ce009
HDPI-6150 only trigger GS indexing on PR
toby-plunkett Apr 24, 2026
f074b27
HDPI-6150 Move ES Index to before smoke tests to access secrets
toby-plunkett Apr 24, 2026
17fa2fe
HDPI-6150 Move ES Index to it's own script
toby-plunkett Apr 24, 2026
d943827
HDPI-6150 Make script executable
toby-plunkett Apr 24, 2026
6608255
Merge branch 'debugglobalsearch' into HDPI-6150-Call-ElasticSearch-en…
toby-plunkett Apr 24, 2026
ed7adb0
HDPI-6150 Fix merge conflict
toby-plunkett Apr 24, 2026
f27b9fa
HDPI-6150 Reverting SearchCritera change to see if GS still works
toby-plunkett Apr 24, 2026
e8c35b5
HDPI-6150 Reverting Uneeded changes
toby-plunkett Apr 24, 2026
56dd3f7
HDPI-6150 Reverting Uneeded changes
toby-plunkett Apr 24, 2026
48e914a
HDPI-6150 Check if env.CASE_TYPE_SUFFIX is needed
toby-plunkett Apr 24, 2026
ee5f22c
HDPI-6150 Confirm removal is needed
toby-plunkett Apr 27, 2026
96a99cb
Merge branch 'master' into HDPI-6150-Call-ElasticSearch-endpoint-via-…
toby-plunkett Apr 27, 2026
878ead9
Merge remote-tracking branch 'origin/master' into HPDI-4161-Global-Se…
toby-plunkett Apr 27, 2026
f64b2af
HDPI-4161 merge conflicts
toby-plunkett Apr 27, 2026
74aa952
HDPI-4161 Update tests to handle internal and external roles differing
toby-plunkett Apr 28, 2026
ce7a25d
HDPI-4161 Switch to better naming scheme
toby-plunkett Apr 28, 2026
9c40a32
Merge branch 'master' into HPDI-4161-Global-Search-entries-RoleToAcce…
toby-plunkett Apr 28, 2026
d181dea
HDPI-4161 Make adjustment to role config
toby-plunkett Apr 28, 2026
0b4bac0
Merge remote-tracking branch 'origin/HPDI-4161-Global-Search-entries-…
toby-plunkett Apr 28, 2026
b57ae2b
Merge remote-tracking branch 'refs/remotes/origin/master' into HPDI-4…
toby-plunkett Apr 29, 2026
f09c17d
Merge branch 'master' into HPDI-4161-Global-Search-entries-RoleToAcce…
toby-plunkett Apr 29, 2026
2fd8d59
HDPI-4161 Make adjustment to role tests
toby-plunkett Apr 29, 2026
69557c0
HDPI-4161 add gs_profile access profile to config
toby-plunkett Apr 30, 2026
d61d679
Merge branch 'master' into HPDI-4161-Global-Search-entries-RoleToAcce…
toby-plunkett Apr 30, 2026
684169a
Merge branch 'master' into HDPI-6150-Call-ElasticSearch-endpoint-via-…
Ankita-Kumbhare Apr 30, 2026
640630c
HDPI-4161 add gs_profile access profile to config
toby-plunkett Apr 30, 2026
5bc345f
HDPI-4161 revert renaming
toby-plunkett Apr 30, 2026
e75b417
Merge branch 'master' into HPDI-4161-Global-Search-entries-RoleToAcce…
toby-plunkett May 1, 2026
251b9d4
HDPI-4161 add test
toby-plunkett May 1, 2026
461be8f
HDPI-4161 remove unnecessary stubbing
toby-plunkett May 1, 2026
cccb807
HDPI-4172 Add GS_profile to Auth state and case type
toby-plunkett May 5, 2026
b1d1f5f
Merge branch 'master' into HPDI-4172-GS-Auth-Updates
toby-plunkett May 5, 2026
2fc1779
Merge branch 'master' into HPDI-4161-Global-Search-entries-RoleToAcce…
toby-plunkett May 5, 2026
bb21159
Merge branch 'master' into HPDI-4172-GS-Auth-Updates
toby-plunkett May 5, 2026
131046f
Merge remote-tracking branch 'origin/HPDI-4172-GS-Auth-Updates' into …
toby-plunkett May 5, 2026
db6cc09
Merge branch 'HPDI-4161-Global-Search-entries-RoleToAccessprofiles' i…
toby-plunkett May 5, 2026
29d8bed
Merge branch 'HDPI-6150-Call-ElasticSearch-endpoint-via-pipeline' int…
toby-plunkett May 18, 2026
7a7f502
Merge branch 'HPDI-4161-Global-Search-entries-RoleToAccessprofiles' i…
toby-plunkett May 18, 2026
c91e0b3
Merge branch 'HPDI-4172-GS-Auth-Updates' into HDPI-5335-enable-access…
toby-plunkett May 18, 2026
30fc5d8
HDPI-5335: add roles to globalSearch access profile
benouaer May 18, 2026
e3f2689
HDPI-5335: add claimant searchParty fields
benouaer May 18, 2026
f7e74a4
HDPI-5335: fix failing test
benouaer May 18, 2026
1d98450
HDPI-5335: add GS roles to HighLevelDataSetupApp
benouaer May 18, 2026
ab3a795
HDPI-5335: fix failing test
benouaer May 18, 2026
91629e7
Revert "HDPI-5335: fix failing test"
toby-plunkett May 18, 2026
95b1f74
Revert "HDPI-5335: add GS roles to HighLevelDataSetupApp"
toby-plunkett May 18, 2026
8bd2f08
Revert "HDPI-5335: fix failing test"
toby-plunkett May 18, 2026
69108b6
Revert "HDPI-5335: add claimant searchParty fields"
toby-plunkett May 18, 2026
5366bb5
Revert "HDPI-5335: add roles to globalSearch access profile"
toby-plunkett May 18, 2026
e05ac25
HDPI-5335 Testing revert of Role changes
toby-plunkett May 18, 2026
3492145
HDPI-5335 Add tab only shown to GS profile
toby-plunkett May 19, 2026
0979654
HDPI-5335 Add tab only shown to GS profile
toby-plunkett May 19, 2026
291508a
HDPI-5335 update staff supported juridictions
toby-plunkett May 19, 2026
2219262
HDPI-5335:n update jurisdictions
benouaer May 19, 2026
033c8e7
HDPI-5335 Add roles for HLD from sscs to test globalsearch
toby-plunkett May 20, 2026
261ee6a
Merge branch 'HDPI-5335-enable-access-to-globalsearch-without-parties…
toby-plunkett May 20, 2026
ae34499
HDPI-5335 Cleanup code
toby-plunkett May 20, 2026
dbe80b3
Merge branch 'master' into HDPI-5335-enable-access-to-globalsearch-wi…
toby-plunkett May 20, 2026
47e1d25
HDPI-5335 Remove testing code
toby-plunkett May 20, 2026
a9de490
HDPI-5335 Remove testing code
toby-plunkett May 20, 2026
af808a9
HDPI-5335: add support for multi access profiles
benouaer May 19, 2026
d5b98ee
Merge branch 'master' into HDPI-5335-enable-access-to-globalsearch-wi…
toby-plunkett May 21, 2026
cc97154
HDPI-5335 Only GS access for Case Issued state
toby-plunkett May 21, 2026
b4cb47d
Merge branch 'HDPI-5335-enable-access-to-globalsearch-without-parties…
toby-plunkett May 21, 2026
b582d0a
HDPI-5335 Add back GS access for Pending case issued
toby-plunkett May 21, 2026
4e1606e
Merge branch 'master' into HDPI-5335-enable-access-to-globalsearch-wi…
toby-plunkett May 22, 2026
acc998a
HDPI-5335 merge conflict
toby-plunkett May 22, 2026
08df69d
HDPI-4009 Index Search Parties
toby-plunkett May 26, 2026
5e03da5
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
toby-plunkett May 26, 2026
fa9137f
HDPI-4009 Test changing Jurisdiction_name
toby-plunkett May 28, 2026
bd7b738
Merge remote-tracking branch 'origin/HDPI-4009-enable-search-parties-…
toby-plunkett May 28, 2026
6e8f0db
Merge branch 'refs/heads/master' into HDPI-4009-enable-search-parties…
toby-plunkett May 28, 2026
94b9efc
HDPI-4009 Merge updates
toby-plunkett May 28, 2026
16a2bc6
HDPI-4009 checkstyle
toby-plunkett May 28, 2026
e72be78
HDPI-4009 Update case-flags to enrich partylist data rather than repl…
toby-plunkett Jun 1, 2026
9c68853
HDPI-4009 Check if underlesse / mortgagees are individuals or orgs so…
toby-plunkett Jun 1, 2026
fcc9085
HDPI-4009 remove debugging
toby-plunkett Jun 1, 2026
4794a87
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
toby-plunkett Jun 1, 2026
801d2b1
HDPI-4009 add enum to differentiate between individual and organisation
toby-plunkett Jun 1, 2026
926984a
HDPI-4009 add enum to differentiate between individual and organisation
toby-plunkett Jun 1, 2026
398058a
HDPI-4009 Remove SearchParty.java
toby-plunkett Jun 1, 2026
e2f6c54
HDPI-4009 Allow searching for property claimant is repossessing
toby-plunkett Jun 1, 2026
7b45d1a
HDPI-4009 remove 'parties' field
toby-plunkett Jun 1, 2026
fa1d884
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
toby-plunkett Jun 3, 2026
f33bc62
HDPI-4009 Add testing for new branches
toby-plunkett Jun 3, 2026
0732e9b
HDPI-4009 serach criteria separated out
toby-plunkett Jun 3, 2026
ab1c8d0
HDPI-4009 serach criteria separated out
toby-plunkett Jun 4, 2026
d4e35d5
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
toby-plunkett Jun 4, 2026
931130e
HDPI-4009 merge conflcit
toby-plunkett Jun 4, 2026
e91dfac
HDPI-4009 merge conflcit
toby-plunkett Jun 4, 2026
d88ec31
HDPI-4009 also index org name
toby-plunkett Jun 4, 2026
fef455b
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
toby-plunkett Jun 9, 2026
8e4e645
HDPI-5335 remove out of scope changes
toby-plunkett Jun 9, 2026
bb8fc94
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 9, 2026
45a94e2
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
toby-plunkett Jun 9, 2026
9eab21f
HDPI-5335 remove out of scope changes
toby-plunkett Jun 9, 2026
f6169c4
Merge remote-tracking branch 'origin/HDPI-4009-enable-search-parties-…
toby-plunkett Jun 9, 2026
742416f
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 9, 2026
e84387d
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 9, 2026
966329f
Add global search functionality and enhance validation with retry logic
Jun 10, 2026
272f13a
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 10, 2026
e504bcb
Merge branch 'HDPI-4009-enable-search-parties-Global-search' into HDP…
ankitakunchhal Jun 10, 2026
718e67b
Add PR tag
Jun 10, 2026
f7948d5
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 10, 2026
7753d21
Merge branch 'HDPI-4009-enable-search-parties-Global-search' into HDP…
ankitakunchhal Jun 10, 2026
75b8729
Revert "Add PR tag"
Jun 10, 2026
6b9d66e
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 10, 2026
a8fd551
Merge branch 'HDPI-4009-enable-search-parties-Global-search' into HDP…
ankitakunchhal Jun 11, 2026
12782d8
HDPI-5335 update searchparties to include address for all parties whe…
toby-plunkett Jun 11, 2026
293f314
Merge remote-tracking branch 'origin/HDPI-4009-enable-search-parties-…
toby-plunkett Jun 11, 2026
0077f6e
Refactor global search tests to use submitGlobalSearch action for for…
Jun 11, 2026
d55e8bb
HDPI-5335 allow searching of unknown names
toby-plunkett Jun 11, 2026
2f39a1b
Merge branch 'HDPI-4009-enable-search-parties-Global-search' into HDP…
ankitakunchhal Jun 11, 2026
f83f3a9
Revert "HDPI-5335 allow searching of unknown names"
toby-plunkett Jun 11, 2026
0d1de29
Enhance global search functionality by updating input values, refacto…
Jun 11, 2026
572dd27
Refactor global search actions to streamline search execution and enh…
Jun 11, 2026
0bfdc8d
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 11, 2026
3431edd
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 11, 2026
e9ede5d
Merge branch 'HDPI-4009-enable-search-parties-Global-search' into HDP…
ankitakunchhal Jun 12, 2026
e05b1b3
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 12, 2026
3d922d6
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 12, 2026
cdc3f7c
Give access to allDeendants for internalCAseFlags
toby-plunkett Jun 12, 2026
d911118
Merge branch 'HDPI-4009-enable-search-parties-Global-search' into HDP…
ankitakunchhal Jun 12, 2026
632916e
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 15, 2026
513035e
fix case flags not applying
toby-plunkett Jun 15, 2026
ae391b7
Merge remote-tracking branch 'origin/HDPI-4009-enable-search-parties-…
toby-plunkett Jun 15, 2026
c9d9526
revert test change
toby-plunkett Jun 15, 2026
366d5d8
Merge branch 'HDPI-4009-enable-search-parties-Global-search' into HDP…
ankitakunchhal Jun 15, 2026
dd1e314
Refactor global search test description for clarity
Jun 15, 2026
73c4715
Merge branch 'master' into HDPI-4009-enable-search-parties-Global-search
ankitakunchhal Jun 15, 2026
7aa2283
Merge branch 'HDPI-4009-enable-search-parties-Global-search' into HDP…
ankitakunchhal Jun 16, 2026
e037a6a
Merge branch 'master' into HDPI-5336-Automation
ankitakunchhal Jun 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export const globalSearch =
otherReferenceInputText: 'Test reference',
otherReferenceParagraph:'Any other reference to identify a case, for example National Insurance number, or system reference',
nameLabel:'Name',
nameInputText: 'Smith',
nameInputText: 'Possession Claims Solicitor Org',
nameParagraph: 'For example, name of a party or solicitor',
firstLineOfAddressLabel: 'First line of address',
firstLineOfAddressInputText: '2 Second Avenue',
postCodeLabel: 'Postcode',
postcodeInputText: 'W3 7RX',
emailAddressLabel: 'Email address',
emailAddressInputText: 'test@test.com',
emailAddressInputText: 'pcs-solicitor1@test.com',
dateOfBirthLabel: 'Date of birth',
dateOfBirthDayLabel: 'Day',
dateOfBirthMonthLabel: 'Month',
Expand All @@ -46,5 +46,6 @@ export const globalSearch =
searchButton: 'Search',
invalidCaseReferenceInputText: '0000000000000000',
invalidPostcodeInputText: 'ZZ99 9ZZ',
invalidNameInputText: 'XYZ_NonExistent_Name_ABC'
invalidNameInputText: 'XYZ_NonExistent_Name_ABC',
nextLink: 'Next page'
}
37 changes: 31 additions & 6 deletions src/e2eTest/tests/CommonComponent/globalSearch.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test } from '@utils/test-fixtures';
import { expect, Page, BrowserContext } from '@playwright/test';
import { initializeExecutor, performAction, performValidation } from '@utils/controller';
import { globalSearch} from '@data/page-data-figma';
import { dismissCookieBanner } from '@config/cookie-banner';
Expand All @@ -9,8 +10,8 @@ import { user} from '@data/page-data';
test.use({ storageState: undefined });

const setupGlobalSearchUser = async (
page: any,
context: any,
page: Page,
context: BrowserContext,
loggedInUser: typeof user.ctscAdministrator
) => {
await context.clearCookies();
Expand Down Expand Up @@ -43,6 +44,14 @@ test.afterEach(async () => {
}
});

const runFieldSearch = async (label: string, value: string) => {
await performAction('accessingTheSearch');
await performAction('inputText', label, value);
await performAction('select', globalSearch.servicesLabel, globalSearch.servicesDropdownOption2);
await performAction('executeSearch');
await performAction('validateResultsWithRetry');
};

const runGlobalSearchScenarios = () => {
test('Global search menu @smoke', async () => {
await performAction('accessingTheSearch');
Expand All @@ -51,16 +60,32 @@ const runGlobalSearchScenarios = () => {

test('Valid case reference using Mortgage and Landlord Possession Claim Service', async () => {
await performAction('accessingTheSearch');
await performAction('searchByCaseReference', process.env.CASE_NUMBER);
await performAction('searchByCaseReference', process.env.CASE_NUMBER, globalSearch.servicesDropdownOption2);
await performAction('validateResults');
});

test('Valid case reference using All Services', async () => {
await performAction('accessingTheSearch');
await performAction('searchByCaseReference', process.env.CASE_NUMBER);
await performAction('searchByCaseReference', process.env.CASE_NUMBER, globalSearch.servicesDropdownOption1);
await performAction('validateResults');
});

test('Search by postcode', async () => {
await runFieldSearch(globalSearch.postCodeLabel, globalSearch.postcodeInputText);
});

test('Search by email address', async () => {
await runFieldSearch(globalSearch.emailAddressLabel, globalSearch.emailAddressInputText);
});

test('first line of address', async () => {
await runFieldSearch(globalSearch.firstLineOfAddressLabel, globalSearch.firstLineOfAddressInputText);
});
Comment thread
ankitakunchhal marked this conversation as resolved.

test('Search by party name', async () => {
await runFieldSearch(globalSearch.nameLabel, globalSearch.nameInputText);
});

test('Invalid case reference', async () => {
await performAction('accessingTheSearch');
await performAction('invalidCaseReferenceSearch', globalSearch.invalidCaseReferenceInputText);
Expand All @@ -75,9 +100,9 @@ const runGlobalSearchScenarios = () => {

[
{ roleName: 'CTSC User', account: user.ctscAdministrator },
{ roleName: 'Judge', account: user.judge }
{ roleName: 'Judge User', account: user.judge }
].forEach(({ roleName, account }) => {
test.describe(`[Global Search - ${roleName} - @nightly @CC @caseFlags]`, () => {
test.describe(`[Common Component Global Search] - ${roleName} - @nightly @CC @caseFlags`, () => {
test.beforeEach(async ({ page, context }) => {
await setupGlobalSearchUser(page, context, account);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { expect, Page } from '@playwright/test';
import { expect, Locator, Page } from '@playwright/test';
import { performAction, performValidation } from '../../../controller';
import { actionRecord, IAction } from '@utils/interfaces';
import { globalSearch, noResultFound, searchResults, workAccess } from '@data/page-data-figma';
import { caseList, home } from '@data/page-data';

export class GlobalSearchCaseAction implements IAction {
async execute(page: Page, action: string, fieldName: string | actionRecord): Promise<void> {
async execute(page: Page, action: string, fieldName: string | actionRecord, value?: string | actionRecord): Promise<void> {
const actionsMap = new Map<string, () => Promise<void>>([
['accessingTheSearch', () => this.accessingTheSearch(page)],
['searchByCaseReference', () => this.searchByCaseReference(fieldName as string, page)],
['invalidCaseReferenceSearch', () => this.invalidCaseReferenceSearch(fieldName as string, page)],
['changeSearchLink', () => this.changeSearchLink(fieldName as string, page)],
['searchByCaseReference', () => this.searchByCaseReference(fieldName as string, page, value as string | undefined)],
['invalidCaseReferenceSearch', () => this.invalidCaseReferenceSearch(page)],
['changeSearchLink', () => this.changeSearchLink(page)],
['handleJudgeBookingPage', () => this.handleJudgeBookingPage(page)],
['validateResults', () => this.validateResults(page)]
['submitGlobalSearch', () => this.submitGlobalSearch(page)],
['executeSearch', () => this.executeSearch(page)],
['validateResults', () => this.validateResults(page)],
['validateResultsWithRetry', () => this.validateResultsWithRetry(page)]
]);

const actionToPerform = actionsMap.get(action);
Expand All @@ -24,23 +27,21 @@ export class GlobalSearchCaseAction implements IAction {
await performAction('clickButton', home.globalSearchTab);
}

private async searchByCaseReference(caseReference: string, page: Page): Promise<void> {
private async searchByCaseReference(caseReference: string, page: Page, serviceOption?: string): Promise<void> {
await performAction('inputText', globalSearch.DigitCaseReferenceLabel, caseReference);
await performAction('select', globalSearch.servicesLabel, globalSearch.servicesDropdownOption2);
await performAction('clickButton', globalSearch.searchButton);
await page.locator('button[type="submit"]').click();
await performAction('select', globalSearch.servicesLabel, serviceOption ?? globalSearch.servicesDropdownOption2);
await this.executeSearch(page);
await performValidation('mainHeader', searchResults.mainHeader);
}

private async invalidCaseReferenceSearch(invalidCaseReference: string, page: Page): Promise<void> {
private async invalidCaseReferenceSearch(page: Page): Promise<void> {
await performAction('inputText', globalSearch.DigitCaseReferenceLabel, globalSearch.invalidCaseReferenceInputText);
await performAction('select', globalSearch.servicesLabel, globalSearch.servicesDropdownOption1);
await performAction('clickButton', globalSearch.searchButton);
await page.locator('button[type="submit"]').click();
await this.executeSearch(page);
await performValidation('mainHeader', noResultFound.mainHeader);
}

private async changeSearchLink(changeSearch: string, page: Page): Promise<void> {
private async changeSearchLink(page: Page): Promise<void> {
await performAction('clickLink', searchResults.changeSearchLink);
await performValidation('mainHeader', globalSearch.mainHeader);
}
Expand All @@ -53,15 +54,27 @@ export class GlobalSearchCaseAction implements IAction {
await performValidation('mainHeader', caseList.mainHeader);
}

private async submitGlobalSearch(page: Page): Promise<void> {
await page.locator('button[type="submit"]').click();
}

private async executeSearch(page: Page): Promise<void> {
await performAction('clickButton', globalSearch.searchButton);
await this.submitGlobalSearch(page);
}

private async validateResults(page: Page): Promise<void> {
const caseReference = String(process.env.CASE_NUMBER ?? '');
const resultRow = page.locator('tr').filter({ hasText: caseReference });
const caseCell = resultRow.locator('td').first();
const normalizedCaseReference = caseReference.replace(/\D/g, '');
await expect(page.getByRole('heading', { name: searchResults.mainHeader })).toBeVisible();
await expect(resultRow).toContainText(caseReference);
await expect(caseCell).toContainText(caseReference);

const resultRow = await this.findCaseReferenceRowAcrossPages(page, normalizedCaseReference);
const caseCell = resultRow.locator('td').first();
const caseCellText = (await caseCell.innerText()).trim();
const caseNameText = caseCellText.replace(caseReference, '').trim();
const normalizedCellText = caseCellText.replace(/\D/g, '');
const formattedCaseReference = caseReference.replace(/(\d{4})(?=\d)/g, '$1-');
expect(normalizedCellText).toContain(normalizedCaseReference);
const caseNameText = caseCellText.replace(caseReference, '').replace(formattedCaseReference, '').trim();
expect(caseNameText.length).toBeGreaterThan(0);
await expect(resultRow).toContainText(searchResults.serviceLabel);
await expect(resultRow).toContainText(searchResults.stateLabel);
Expand All @@ -71,4 +84,60 @@ export class GlobalSearchCaseAction implements IAction {
await performAction('clickTab', home.caseSummary);
await performValidation('mainHeader', home.caseSummary);
}

private async validateResultsWithRetry(page: Page): Promise<void> {
const maxRetries = 6;

for (let retryCount = 0; retryCount < maxRetries; retryCount++) {
try {
await this.validateResults(page);
return;
} catch (error: any) {
const shouldRetry = String(error?.message ?? '').includes(
'was not found on any paginated search result page'
);

if (!shouldRetry || retryCount === maxRetries - 1) {
throw error;
}

await page.reload({ waitUntil: 'domcontentloaded' });
await expect(
page.getByRole('heading', { name: searchResults.mainHeader })
).toBeVisible();
}
}
}

private async findCaseReferenceRowAcrossPages(page: Page, normalizedCaseReference: string): Promise<Locator> {
const maxPagesToScan = 50;
const rows = page.locator('tbody tr');

for (let pageIndex = 0; pageIndex < maxPagesToScan; pageIndex++) {
const rowCount = await rows.count();
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
const row = rows.nth(rowIndex);
const firstCellText = (await row.locator('td').first().innerText()).trim();
const normalizedRowCaseReference = firstCellText.replace(/\D/g, '');
if (normalizedRowCaseReference.includes(normalizedCaseReference)) {
return row;
}
}

const nextPageLink = page.getByRole('link', { name: globalSearch.nextLink, exact: true });
if ((await nextPageLink.count()) === 0 || !(await nextPageLink.isVisible())) {
break;
}

const currentPageMarker = page.locator('.hmcts-pagination__item--current').first();
const previousMarkerText = (await currentPageMarker.count()) > 0 ? (await currentPageMarker.innerText()).trim() : '';
await nextPageLink.click();
if (previousMarkerText) {
await expect(currentPageMarker).not.toHaveText(previousMarkerText, { timeout: 10000 });
}
await expect(rows.first()).toBeVisible({ timeout: 10000 });
}

throw new Error(`Case reference '${normalizedCaseReference}' was not found on any paginated search result page.`);
}
}
4 changes: 3 additions & 1 deletion src/e2eTest/utils/registry/action.registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ export class ActionRegistry {
['searchByCaseReference', new GlobalSearchCaseAction()],
['invalidCaseReferenceSearch', new GlobalSearchCaseAction()],
['changeSearchLink', new GlobalSearchCaseAction()],
['handleJudgeBookingPage', new GlobalSearchCaseAction()],
['submitGlobalSearch', new GlobalSearchCaseAction()],
['executeSearch', new GlobalSearchCaseAction()],
['validateResults', new GlobalSearchCaseAction()],
['validateResultsWithRetry', new GlobalSearchCaseAction()],
['selectClaimingCosts', new CreateCaseAction()],
['wantToUploadDocuments', new CreateCaseAction()],
['uploadAdditionalDocs', new CreateCaseAction()],
Expand Down
Loading