@ministryofjustice/hmpps-probation-integration-e2e-tests 1.199.0 → 1.200.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ministryofjustice/hmpps-probation-integration-e2e-tests",
|
|
3
3
|
"description": "Playwright end to end tests for hmpps-probation-integration-services.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.200.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ministryofjustice/hmpps-probation-integration-e2e-tests#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -138,12 +138,14 @@
|
|
|
138
138
|
"./steps/delius/upw/checkAppointmentDetails": "./steps/delius/upw/checkAppointmentDetails.mjs",
|
|
139
139
|
"./steps/delius/upw/create-upw-project": "./steps/delius/upw/create-upw-project.mjs",
|
|
140
140
|
"./steps/delius/upw/start-upw-assessment": "./steps/delius/upw/start-upw-assessment.mjs",
|
|
141
|
+
"./steps/delius/upw/verify-time-credited": "./steps/delius/upw/verify-time-credited.mjs",
|
|
141
142
|
"./steps/delius/utils/contact": "./steps/delius/utils/contact.mjs",
|
|
142
143
|
"./steps/delius/utils/date-time": "./steps/delius/utils/date-time.mjs",
|
|
143
144
|
"./steps/delius/utils/inputs": "./steps/delius/utils/inputs.mjs",
|
|
144
145
|
"./steps/delius/utils/pdf-utils": "./steps/delius/utils/pdf-utils.mjs",
|
|
145
146
|
"./steps/delius/utils/person": "./steps/delius/utils/person.mjs",
|
|
146
147
|
"./steps/delius/utils/refresh": "./steps/delius/utils/refresh.mjs",
|
|
148
|
+
"./steps/delius/utils/table": "./steps/delius/utils/table.mjs",
|
|
147
149
|
"./steps/dps/caseload": "./steps/dps/caseload.mjs",
|
|
148
150
|
"./steps/dps/login": "./steps/dps/login.mjs",
|
|
149
151
|
"./steps/hdc-licences/login": "./steps/hdc-licences/login.mjs",
|
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
import { waitForAjax } from "../utils/refresh.mjs";
|
|
2
|
+
import { getRowByContent, getRowCellsByContent } from "../utils/table.mjs";
|
|
2
3
|
import { expect } from "@playwright/test";
|
|
3
4
|
//#region steps/delius/upw/checkAppointmentDetails.ts
|
|
4
|
-
async function clickNextButton(page) {
|
|
5
|
-
const nextButtonSelector = "a.page-link[title=\"Next\"]:not(.disabled)";
|
|
6
|
-
await page.waitForSelector(nextButtonSelector, { state: "visible" });
|
|
7
|
-
await page.click(nextButtonSelector);
|
|
8
|
-
await waitForAjax(page);
|
|
9
|
-
await page.waitForSelector("#searchResultsTable tbody");
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
async function getRowByContent(page, content) {
|
|
13
|
-
const row = page.locator(`#searchResultsTable tbody tr:has-text("${content}")`).first();
|
|
14
|
-
if (await row.isVisible().catch(() => false)) return row;
|
|
15
|
-
if (await page.locator("a.page-link[title=\"Next\"]:not(.disabled)").count() > 0) {
|
|
16
|
-
await clickNextButton(page);
|
|
17
|
-
return getRowByContent(page, content);
|
|
18
|
-
}
|
|
19
|
-
throw new Error(`Row with content "${content}" not found`);
|
|
20
|
-
}
|
|
21
|
-
async function getCellContents(row) {
|
|
22
|
-
const cellElements = await row.locator("td").all();
|
|
23
|
-
return await Promise.all(cellElements.map(async (td) => {
|
|
24
|
-
return (await td.innerText()).trim();
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
5
|
async function checkAppointmentOnDelius(page, checkAppointmentOptions) {
|
|
28
6
|
const { teamProvider, teamName, projectName, popCrn, popName, startTime, endTime, penalty, outcome, enforcementAction, hoursCredited, outStanding } = checkAppointmentOptions;
|
|
29
7
|
await page.getByRole("combobox", { name: "Provider:" }).selectOption(teamProvider);
|
|
@@ -31,10 +9,10 @@ async function checkAppointmentOnDelius(page, checkAppointmentOptions) {
|
|
|
31
9
|
await page.getByRole("button", { name: "Search" }).click();
|
|
32
10
|
await waitForAjax(page);
|
|
33
11
|
await page.waitForSelector("h2:text-is(\"Project List\")");
|
|
34
|
-
await (await getRowByContent(page, projectName)).getByRole("link", { name: "manage" }).click();
|
|
12
|
+
await (await getRowByContent(page, "searchResultsTable", projectName)).getByRole("link", { name: "manage" }).click();
|
|
35
13
|
await page.waitForSelector("h2:text-is(\"Allocated To Attend\")");
|
|
36
|
-
const cells = await
|
|
37
|
-
expect(cells[0]).
|
|
14
|
+
const cells = await getRowCellsByContent(page, "allocatedOffendersTable", popCrn);
|
|
15
|
+
expect(cells[0]).toContain(popCrn);
|
|
38
16
|
expect(cells[1]).toBe(popName);
|
|
39
17
|
expect(cells[2]).toBe(startTime);
|
|
40
18
|
expect(cells[3]).toBe(endTime);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Page } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
//#region steps/delius/upw/verify-time-credited.d.ts
|
|
4
|
+
interface Options {
|
|
5
|
+
crn: string;
|
|
6
|
+
eventNumber?: number;
|
|
7
|
+
projectName: string;
|
|
8
|
+
date: Date;
|
|
9
|
+
hoursCredited: string;
|
|
10
|
+
outcome: string;
|
|
11
|
+
}
|
|
12
|
+
declare function verifyTimeCredited(page: Page, {
|
|
13
|
+
crn,
|
|
14
|
+
eventNumber,
|
|
15
|
+
projectName,
|
|
16
|
+
hoursCredited,
|
|
17
|
+
outcome
|
|
18
|
+
}: Options): Promise<void>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { verifyTimeCredited as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { waitForAjax } from "../utils/refresh.mjs";
|
|
2
|
+
import { findEventByCRN } from "../event/find-events.mjs";
|
|
3
|
+
import { verifyTableRowByContent } from "../utils/table.mjs";
|
|
4
|
+
//#region steps/delius/upw/verify-time-credited.ts
|
|
5
|
+
async function verifyTimeCredited(page, { crn, eventNumber = 1, projectName, hoursCredited, outcome }) {
|
|
6
|
+
await findEventByCRN(page, crn, eventNumber);
|
|
7
|
+
await page.click("#navigation-include\\:linkNavigation3UnpaidWork");
|
|
8
|
+
await page.getByRole("button", { name: "Worksheet summary" }).click();
|
|
9
|
+
await waitForAjax(page);
|
|
10
|
+
await verifyTableRowByContent(page, "appointmentsTable", projectName, [{
|
|
11
|
+
columnName: "Hrs Credited",
|
|
12
|
+
cellContent: hoursCredited
|
|
13
|
+
}, {
|
|
14
|
+
columnName: "Outcome",
|
|
15
|
+
cellContent: outcome
|
|
16
|
+
}]);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { verifyTimeCredited as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Locator, Page } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
//#region steps/delius/utils/table.d.ts
|
|
4
|
+
declare function getRowByContent(page: Page, tableId: string, content: string): Promise<Locator>;
|
|
5
|
+
declare function getRowCellsByContent(page: Page, tableId: string, content: string): Promise<string[]>;
|
|
6
|
+
declare function verifyTableRowByContent(page: Page, tableId: string, rowIdentifyingContent: string, toVerify: Array<{
|
|
7
|
+
columnName: string;
|
|
8
|
+
cellContent: string;
|
|
9
|
+
}>): Promise<void>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { getRowByContent, getRowCellsByContent, verifyTableRowByContent };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { waitForAjax } from "./refresh.mjs";
|
|
2
|
+
import { expect } from "@playwright/test";
|
|
3
|
+
//#region steps/delius/utils/table.ts
|
|
4
|
+
async function getRowByContent(page, tableId, content) {
|
|
5
|
+
const tableLocator = page.locator(`#${tableId}`);
|
|
6
|
+
await expect(tableLocator).toBeVisible();
|
|
7
|
+
const row = tableLocator.getByRole("row").filter({ hasText: content });
|
|
8
|
+
try {
|
|
9
|
+
await expect(row).toBeVisible();
|
|
10
|
+
return row;
|
|
11
|
+
} catch {
|
|
12
|
+
const nextPageButtonLocator = page.getByRole("link", { name: "Next" });
|
|
13
|
+
await expect(nextPageButtonLocator, `Expected - ${content} - not found, try next page`).toBeVisible();
|
|
14
|
+
await nextPageButtonLocator.click();
|
|
15
|
+
await waitForAjax(page);
|
|
16
|
+
return getRowByContent(page, tableId, content);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function getRowCellsByContent(page, tableId, content) {
|
|
20
|
+
return await (await getRowByContent(page, tableId, content)).getByRole("cell").allTextContents();
|
|
21
|
+
}
|
|
22
|
+
async function verifyTableRowByContent(page, tableId, rowIdentifyingContent, toVerify) {
|
|
23
|
+
const tableLocator = page.locator(`#${tableId}`);
|
|
24
|
+
const rowCellsByContent = await getRowCellsByContent(page, tableId, rowIdentifyingContent);
|
|
25
|
+
const headerRowCells = await tableLocator.getByRole("columnheader").allTextContents();
|
|
26
|
+
toVerify.forEach((verification) => {
|
|
27
|
+
expect(rowCellsByContent[headerRowCells.findIndex((cell) => cell.includes(verification.columnName))]).toContain(verification.cellContent);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { getRowByContent, getRowCellsByContent, verifyTableRowByContent };
|