Skip to content

Commit bca7e17

Browse files
DFPL-2956AddGatekeepingUITest (#6171)
* AddGatekeepingTest * ChangeFunctionName * Remove.only tag
1 parent 1932a42 commit bca7e17

File tree

5 files changed

+89
-8
lines changed

5 files changed

+89
-8
lines changed

playwright-e2e/fixtures/create-fixture.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import {ExpertReport} from "../pages/expert-report";
6161
import {Extend26WeekTimeline} from "../pages/extend-26week-timeline";
6262
import { RecordFinalDecision} from "../pages/record-final-decision";
6363
import {SendOrderRemainder} from "../pages/send-order-remainder";
64-
import {AddFamilymanCaseNumberPage} from "../pages/gatekeeping/add-familyman-case-numner";
64+
import { FamilymanCaseNumberPage} from "../pages/gatekeeping/familyman-case-number";
6565
import {SendToGatekeeperPage} from "../pages/gatekeeping/send-to-gatekeeper";
6666
import {HistoryPage} from "../pages/case-details/history";
6767
import {EnvironmentConfig, getEnvironmentSpecificTestData} from "../settings/environment-data-config"
@@ -126,7 +126,7 @@ type CreateFixtures = {
126126
uploadAdditionalApplicationsSuppliedDocuments: SuppliedDocuments;
127127
submit: Submit;
128128
caseNote: CaseNote;
129-
addFamilymanCaseNumberPage: AddFamilymanCaseNumberPage;
129+
familymanCaseNumber: FamilymanCaseNumberPage;
130130
sendToGatekepperPage: SendToGatekeeperPage;
131131
historyPage: HistoryPage;
132132
expertReport: ExpertReport;
@@ -370,8 +370,8 @@ othersToBeGivenNotice: async ({ page }, use) => {
370370
caseNote: async ({ page }, use) => {
371371
await use(new CaseNote(page));
372372
},
373-
addFamilymanCaseNumberPage: async({ page }, use) => {
374-
await use(new AddFamilymanCaseNumberPage(page));
373+
familymanCaseNumber: async({ page }, use) => {
374+
await use(new FamilymanCaseNumberPage(page));
375375
},
376376
sendToGatekepperPage: async({ page }, use) => {
377377
await use(new SendToGatekeeperPage(page));

playwright-e2e/pages/base-page.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,32 @@ export class BasePage {
175175
await page.getByRole('textbox', {name: 'Second'}).fill(sec);
176176
}
177177
async enterDate(date: Date){
178-
await this.dateOfHearing.getByText('Day').fill(date.getDay().toString());
178+
await this.dateOfHearing.getByText('Day').fill(date.getDay().toString());
179179
await this.dateOfHearing.getByText('Month').fill(date.getMonth().toString());
180180
await this.dateOfHearing.getByText('Year').fill(date.getFullYear().toString())
181181

182182

183183
}
184+
185+
async getCellValueInTable(tableName: string, cellHeading: string): Promise<string> {
186+
const table = this.page.getByRole('table', { name: tableName });
187+
let cellValue = '';
188+
189+
try {
190+
const rows = await table.locator('tr').all();
191+
for (const row of rows) {
192+
const heading = await row.locator('th').textContent() || '';
193+
if (heading === cellHeading) {
194+
cellValue = await row.locator('td').textContent() || '';
195+
break;
196+
}
197+
}
198+
199+
return cellValue;
200+
} catch (error) {
201+
console.error(`Error getting table value: ${error}`);
202+
throw new Error(`Failed to get value for heading "${cellHeading}" in table "${tableName}"`);
203+
}
204+
}
184205
}
206+
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import {BasePage} from "../base-page";
22
import {Page, Locator} from "@playwright/test";
33

4-
export class AddFamilymanCaseNumberPage extends BasePage {
4+
export class FamilymanCaseNumberPage extends BasePage {
55
readonly caseNumberTextbox: Locator;
66

77
public constructor(page: Page) {
88
super(page);
99
this.caseNumberTextbox = page.getByRole('textbox', { name: 'FamilyMan case number' });
1010
}
1111

12-
public async fillCaseNumberTextbox(familymanCaseNumber: string): Promise<void> {
12+
public async fillfamilyManCaseNumber(familymanCaseNumber: string): Promise<void> {
1313
await this.caseNumberTextbox.fill(familymanCaseNumber);
1414
}
1515
}

playwright-e2e/pages/gatekeeping/send-to-gatekeeper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class SendToGatekeeperPage extends BasePage {
99
this.emailAddressTextbox = page.getByRole('textbox', { name: 'Email address' });
1010
}
1111

12-
public async fillAddressTextbox(address: string): Promise<void> {
12+
public async fillGateKeeperEmail(address: string): Promise<void> {
1313
await this.emailAddressTextbox.fill(address);
1414
}
1515
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import {test} from '../fixtures/create-fixture';
2+
import {createCase, updateCase} from "../utils/api-helper";
3+
import submittedCase from '../caseData/mandatorySubmissionFields.json' assert {type: "json"};
4+
import {
5+
newSwanseaLocalAuthorityUserOne,
6+
CTSCUser
7+
} from "../settings/user-credentials";
8+
import {expect} from "@playwright/test";
9+
10+
11+
test.describe('Adding gatekeeping details', () => {
12+
const dateTime = new Date().toISOString();
13+
let caseNumber: string;
14+
let caseName: string;
15+
test.beforeEach(async () => {
16+
caseNumber = await createCase('e2e case', newSwanseaLocalAuthorityUserOne);
17+
expect(caseNumber).toBeDefined();
18+
});
19+
20+
test('CTSC user add gatekeeping details @xbrowser',
21+
async ({
22+
signInPage, familymanCaseNumber, sendToGatekepperPage,
23+
caseFileView
24+
}) => {
25+
caseName = 'Gatekeeping details ' + dateTime.slice(0, 10);
26+
expect(await updateCase(caseName, caseNumber, submittedCase)).toBeTruthy();
27+
await signInPage.visit();
28+
await signInPage.login(CTSCUser.email, CTSCUser.password);
29+
await signInPage.navigateToCaseDetails(caseNumber);
30+
31+
await test.step('Add family man reference number', async () => {
32+
await familymanCaseNumber.gotoNextStep('Add case number');
33+
await familymanCaseNumber.fillfamilyManCaseNumber('TN24C51337');
34+
await familymanCaseNumber.clickSubmit();
35+
36+
await expect(familymanCaseNumber.page.getByText('has been updated with event: Add case number')).toBeVisible();
37+
await expect(familymanCaseNumber.page.getByRole('heading', {
38+
level: 2,
39+
name: 'TN24C51337'
40+
})).toBeVisible();
41+
42+
await sendToGatekepperPage.tabNavigation('History');
43+
expect(await sendToGatekepperPage.page.getByRole('table', {name: 'History'}).locator('tr').nth(1).innerText()).toContain('Add case number');
44+
45+
});
46+
await test.step('Send to gatekeeper', async () => {
47+
await signInPage.gotoNextStep('Send to gatekeeper');
48+
await sendToGatekepperPage.fillGateKeeperEmail('[email protected]');
49+
await sendToGatekepperPage.clickSubmit();
50+
await sendToGatekepperPage.clickSaveAndContinue();
51+
52+
await sendToGatekepperPage.tabNavigation('History');
53+
const endState = await sendToGatekepperPage.getCellValueInTable('Details', 'End state');
54+
expect(endState).toBe('Gatekeeping')
55+
expect(await sendToGatekepperPage.page.getByRole('table', {name: 'History'}).locator('tr').nth(1).innerText()).toContain('Send to gatekeeper');
56+
57+
});
58+
});
59+
});

0 commit comments

Comments
 (0)