Skip to content

Commit 75e8680

Browse files
Fee and Pay and case linking fixes for nightly pipeline failures (#2121)
Co-authored-by: Gautham059 <gautham.bhikkumalla@hmcts.net>
1 parent 5a0d604 commit 75e8680

4 files changed

Lines changed: 45 additions & 14 deletions

File tree

src/e2eTest/tests/CommonComponent/caseLinking.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ import { beforeYouStart } from '@data/page-data/beforeYouStart.page.data';
1313
import { selectCasesToLink } from '@data/page-data/selectCaseToLink.page.data';
1414
import { selectCasesToUnLink } from '@data/page-data/selectCasesToUnLink.page.data';
1515
import { checkYourAnswersCaseLinking } from '@data/page-data/checkYourAnswersCaseLinking.page.data';
16+
import {dismissCookieBanner} from '@config/cookie-banner';
17+
import {staff} from '@data/user-data/staff.user.data';
1618

1719
let caseNumbers: string[] = [];
1820

19-
test.beforeEach(async ({ page }) => {
21+
test.use({ storageState: undefined });
22+
23+
test.beforeEach(async ({ page, context }) => {
2024
initializeExecutor(page);
2125
for (let i = 0; i < 5; i++) {
2226
await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload });
@@ -26,9 +30,13 @@ test.beforeEach(async ({ page }) => {
2630
throw new Error('CASE_NUMBER not set');
2731
}
2832
caseNumbers.push(caseNumber);
29-
// 🔹 log each case number immediately
3033
console.log(`Created Case ${i + 1}: ${caseNumber}`);
3134
}
35+
await context.clearCookies();
36+
await performAction('navigateToUrl', process.env.MANAGE_CASE_BASE_URL);
37+
await dismissCookieBanner(page, 'additional');
38+
await performAction('login', {email: staff.pcs_ctsc_team_leader_email, password: process.env.IDAM_PCS_USER_PASSWORD});
39+
await dismissCookieBanner(page, 'analytics');
3240
await performAction('navigateToUrl', `${process.env.MANAGE_CASE_BASE_URL}/cases/case-details/PCS/${getCaseTypeId()}/${process.env.CASE_NUMBER}#Summary`);
3341
await expect(async () => {
3442
await page.waitForURL(`${process.env.MANAGE_CASE_BASE_URL}/**/**/**/**/**#Summary`);

src/e2eTest/tests/CommonComponent/feeAndPay.spec.ts

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ import {
1212
cancelPayment,
1313
caseSummary,
1414
confirmYourPayment,
15-
enterPaymentDetails, home,
16-
serviceRequest
15+
enterPaymentDetails,
16+
home,
17+
serviceRequest,
18+
user
1719
} from '@data/page-data';
1820
import { history } from '@data/page-data/history.page.data';
1921
import {BrowserContext, Page} from "@playwright/test";
2022
import {refundAndRemission} from "@data/user-data/staff.user.data";
23+
import {dismissCookieBanner} from '@config/cookie-banner';
24+
25+
test.use({ storageState: undefined });
2126

2227
async function clearBrowserSession(page: Page, context: BrowserContext): Promise<void> {
2328
await context.clearCookies();
@@ -31,13 +36,19 @@ async function clearBrowserSession(page: Page, context: BrowserContext): Promise
3136
});
3237
}
3338

34-
test.beforeEach(async ({ page }) => {
39+
test.beforeEach(async ({ page, context }) => {
3540
initializeExecutor(page);
3641
await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload });
3742
await performAction('submitCaseAPI', { data: submitCaseApiData.submitCasePayloadNoDefendants });
38-
await performAction('navigateToUrl', `${process.env.MANAGE_CASE_BASE_URL}/cases/case-details/PCS/${getCaseTypeId()}/${process.env.CASE_NUMBER}#Summary`);
43+
await performAction('navigateToUrl', process.env.MANAGE_CASE_BASE_URL);
44+
await clearBrowserSession(page, context);
45+
await dismissCookieBanner(page, 'additional');
46+
await performAction('login', user.claimantSolicitor);
47+
await dismissCookieBanner(page, 'analytics');
48+
const url = `${process.env.MANAGE_CASE_BASE_URL}/cases/case-details/PCS/${getCaseTypeId()}/${process.env.CASE_NUMBER}#Service%20Request`;
49+
await performAction('navigateToUrl', url );
3950
await expect(async () => {
40-
await page.waitForURL(`${process.env.MANAGE_CASE_BASE_URL}/**/**/**/**/**#Summary`);
51+
await page.waitForURL(`${process.env.MANAGE_CASE_BASE_URL}/**/**/**/**/**#Service%20Request`);
4152
}).toPass({
4253
timeout: VERY_LONG_TIMEOUT,
4354
});
@@ -50,7 +61,7 @@ test.afterEach(async () => {
5061
});
5162

5263
test.describe('[Common Component Fee And Pay] @nightly @CC @feeAndPay' , async () => {
53-
test('Fee And Pay - Pay by account PBA', async () => {
64+
test('Fee And Pay - Pay by account PBA', async ({ page, context }) => {
5465
await performAction('clickPayNowLink', serviceRequest.payNowLink);
5566
await performAction('selectPaymentTypePBA', {
5667
amountLabel: serviceRequest.amountToPayLabel,
@@ -63,8 +74,10 @@ test.describe('[Common Component Fee And Pay] @nightly @CC @feeAndPay' , async (
6374
confirmButton: serviceRequest.confirmPaymentButton,
6475
});
6576
await performValidation('mainHeader', serviceRequest.paymentSuccessMainHeader);
77+
await performAction('clickButton', serviceRequest.viewServiceRequestsLink);
78+
await clearBrowserSession(page, context);
79+
await performAction('login', { email: refundAndRemission.requesterEmail, password: process.env.IDAM_PCS_USER_PASSWORD });
6680
await performAction('verifyStatusInHistoryAndSummaryTab', {
67-
serviceReqLink: serviceRequest.viewServiceRequestsLink,
6881
serviceReqTab: caseSummary.serviceRequestTab,
6982
historyTab: caseSummary.HistoryTab,
7083
status: serviceRequest.paidStatus,
@@ -73,7 +86,7 @@ test.describe('[Common Component Fee And Pay] @nightly @CC @feeAndPay' , async (
7386
});
7487
});
7588

76-
test('Fee And Pay - Pay by Card', async () => {
89+
test('Fee And Pay - Pay by Card', async ({ page, context }) => {
7790
await performAction('clickPayNowLink', serviceRequest.payNowLink);
7891
await performAction('selectPaymentByCard', {
7992
amountLabel: serviceRequest.amountToPayLabel,
@@ -97,6 +110,9 @@ test.describe('[Common Component Fee And Pay] @nightly @CC @feeAndPay' , async (
97110
await performValidation('mainHeader', confirmYourPayment.mainHeader);
98111
await performAction('clickButton', confirmYourPayment.confirmButton);
99112
await performValidation('mainHeader', serviceRequest.paymentSuccessMainHeader);
113+
await performAction('clickButton', serviceRequest.returnToServiceRequestLink);
114+
await clearBrowserSession(page, context);
115+
await performAction('login', { email: refundAndRemission.requesterEmail, password: process.env.IDAM_PCS_USER_PASSWORD });
100116
await performAction('verifyStatusInHistoryAndSummaryTab', {
101117
serviceReqLink: serviceRequest.returnToServiceRequestLink,
102118
serviceReqTab: caseSummary.serviceRequestTab,
@@ -107,7 +123,7 @@ test.describe('[Common Component Fee And Pay] @nightly @CC @feeAndPay' , async (
107123
});
108124
});
109125

110-
test('Fee And Pay - Cancel Payment from You Card Details Page', async () => {
126+
test('Fee And Pay - Cancel Payment from You Card Details Page', async ({ page, context }) => {
111127
await performAction('clickPayNowLink', serviceRequest.payNowLink);
112128
await performAction('selectPaymentByCard', {
113129
amountLabel: serviceRequest.amountToPayLabel,
@@ -118,6 +134,9 @@ test.describe('[Common Component Fee And Pay] @nightly @CC @feeAndPay' , async (
118134
await performAction('clickButton', enterPaymentDetails.cancelPaymentButton);
119135
await performValidation('mainHeader', cancelPayment.mainHeader);
120136
await performAction('clickButton', cancelPayment.continueButton);
137+
await performAction('clickButton', serviceRequest.returnToServiceRequestLink);
138+
await clearBrowserSession(page, context);
139+
await performAction('login', { email: refundAndRemission.requesterEmail, password: process.env.IDAM_PCS_USER_PASSWORD });
121140
await performAction('verifyStatusInHistoryAndSummaryTab', {
122141
serviceReqLink: cancelPayment.returnServiceReqLink,
123142
serviceReqTab: caseSummary.serviceRequestTab,
@@ -128,7 +147,7 @@ test.describe('[Common Component Fee And Pay] @nightly @CC @feeAndPay' , async (
128147
});
129148
});
130149

131-
test('Fee And Pay - Cancel Payment from Confirm Card Details Page', async () => {
150+
test('Fee And Pay - Cancel Payment from Confirm Card Details Page', async ({ page, context }) => {
132151
await performAction('clickPayNowLink', serviceRequest.payNowLink);
133152
await performAction('selectPaymentByCard', {
134153
amountLabel: serviceRequest.amountToPayLabel,
@@ -153,6 +172,9 @@ test.describe('[Common Component Fee And Pay] @nightly @CC @feeAndPay' , async (
153172
await performAction('clickButton', confirmYourPayment.cancelPaymentButton);
154173
await performValidation('mainHeader', cancelPayment.mainHeader);
155174
await performAction('clickButton', cancelPayment.continueButton);
175+
await performAction('clickButton', serviceRequest.returnToServiceRequestLink);
176+
await clearBrowserSession(page, context);
177+
await performAction('login', { email: refundAndRemission.requesterEmail, password: process.env.IDAM_PCS_USER_PASSWORD });
156178
await performAction('verifyStatusInHistoryAndSummaryTab', {
157179
serviceReqLink: cancelPayment.returnServiceReqLink,
158180
serviceReqTab: caseSummary.serviceRequestTab,

src/e2eTest/tests/CommonComponent/globalSearch.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const setupGlobalSearchUser = async (
5555
formattedClaimantContactAddress: `${globalSearchTestData.addressLine1}<br>${propertyAddress.PostTown}<br>${globalSearchTestData.postcode}`
5656
}
5757
});
58+
5859
await performAction('navigateToUrl', process.env.MANAGE_CASE_BASE_URL);
5960

6061
await dismissCookieBanner(page, 'additional');

src/e2eTest/utils/actions/custom-actions/commonComponent/feeAndPay.action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { caseSummary, serviceRequest } from '@data/page-data';
66
import { backDateTheCasePaymentApiData } from '@data/api-data/backDateTheCasePayment.api.data';
77
import { refundAndRemission } from '@data/user-data/staff.user.data';
88
import Axios from "axios";
9+
import {getCaseTypeId} from '@utils/common/caseType.utils';
910

1011
export class FeeAndPayAction implements IAction {
1112
async execute(page: Page, action: string, fieldName: actionData | actionRecord, data?: actionData): Promise<void> {
@@ -114,8 +115,7 @@ export class FeeAndPayAction implements IAction {
114115
console.log('Verification steps skipped as this is NOT working in PREVIEW env. POFCC-229');
115116
} else {
116117
console.log('Verifying payment status');
117-
await performAction('clickButton', statusDetails.serviceReqLink);
118-
await performAction('clickTab', statusDetails.historyTab);
118+
await performAction('navigateToUrl', `${process.env.MANAGE_CASE_BASE_URL}/cases/case-details/PCS/${getCaseTypeId()}/${process.env.CASE_NUMBER}#History`);
119119
//Implementing retry login because POFCC-238
120120
const maxRetries = 10;
121121
let isStatusUpdated = false;

0 commit comments

Comments
 (0)