@ministryofjustice/hmpps-probation-integration-e2e-tests 1.213.0 → 1.215.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 +2 -1
- package/steps/accredited-programmes/application.d.mts +10 -2
- package/steps/accredited-programmes/application.mjs +82 -6
- package/steps/accredited-programmes/manageAndDeliverLogin.d.mts +6 -0
- package/steps/accredited-programmes/manageAndDeliverLogin.mjs +12 -0
- package/steps/api/dps/prison-api.mjs +1 -1
- package/steps/community-payback/record-outcome.d.mts +3 -2
- package/steps/community-payback/record-outcome.mjs +17 -6
- package/steps/manage-a-supervision/check-in.mjs +1 -1
- package/test-data/environments/common.mjs +4 -0
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.215.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ministryofjustice/hmpps-probation-integration-e2e-tests#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"exports": {
|
|
37
37
|
"./steps/accredited-programmes/application": "./steps/accredited-programmes/application.mjs",
|
|
38
38
|
"./steps/accredited-programmes/login": "./steps/accredited-programmes/login.mjs",
|
|
39
|
+
"./steps/accredited-programmes/manageAndDeliverLogin": "./steps/accredited-programmes/manageAndDeliverLogin.mjs",
|
|
39
40
|
"./steps/api/arns/arns-api": "./steps/api/arns/arns-api.mjs",
|
|
40
41
|
"./steps/api/auth/get-token": "./steps/api/auth/get-token.mjs",
|
|
41
42
|
"./steps/api/court-case/court-case-api": "./steps/api/court-case/court-case-api.mjs",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { Person } from "../delius/utils/person.mjs";
|
|
2
|
+
import { CreatedEvent } from "../delius/event/create-event.mjs";
|
|
1
3
|
import { Page } from "@playwright/test";
|
|
2
4
|
|
|
3
5
|
//#region steps/accredited-programmes/application.d.ts
|
|
4
|
-
declare function findProgrammeAndMakeReferral(page: Page, nomisId: string): Promise<void>;
|
|
6
|
+
declare function findProgrammeAndMakeReferral(page: Page, nomisId: string, programmeName?: string): Promise<void>;
|
|
5
7
|
declare function clickOnOffenderLink(page: Page, linkName: string, fullName: string): Promise<void>;
|
|
6
8
|
declare function verifyAssessmentDateTextToBe(page: Page, expectedText: string): Promise<void>;
|
|
7
9
|
interface RoSHRiskAssertion {
|
|
@@ -12,8 +14,14 @@ interface RoSHRiskAssertion {
|
|
|
12
14
|
riskToPrisoners: string;
|
|
13
15
|
}
|
|
14
16
|
declare function assertRoSHRiskTable(page: Page, assertions: RoSHRiskAssertion): Promise<void>;
|
|
17
|
+
declare function findCase(page: Page, person: Person, crn: string): Promise<void>;
|
|
18
|
+
declare function addCaseToGroup(page: Page, person: Person): Promise<void>;
|
|
19
|
+
declare function updateReferralStatusToAwaitingAllocation(page: Page, person: Person, crn: string, event: CreatedEvent, date: Date): Promise<void>;
|
|
20
|
+
declare function updateReferralStatus(page: Page): Promise<void>;
|
|
21
|
+
declare function updateReferralStatusToOnProgramme(page: Page, person: Person, crn: string): Promise<void>;
|
|
22
|
+
declare function updateReferralStatusToComplete(page: Page, person: Person): Promise<void>;
|
|
15
23
|
declare const oasysImportDateText = "[data-testid=\"last-assessment-date-text\"]";
|
|
16
24
|
declare const apFormattedTodayDate: string;
|
|
17
25
|
declare const briefOffenceDetailsSummaryCard = "[data-testid=\"brief-offence-details-summary-card\"]";
|
|
18
26
|
//#endregion
|
|
19
|
-
export { apFormattedTodayDate, assertRoSHRiskTable, briefOffenceDetailsSummaryCard, clickOnOffenderLink, findProgrammeAndMakeReferral, oasysImportDateText, verifyAssessmentDateTextToBe };
|
|
27
|
+
export { addCaseToGroup, apFormattedTodayDate, assertRoSHRiskTable, briefOffenceDetailsSummaryCard, clickOnOffenderLink, findCase, findProgrammeAndMakeReferral, oasysImportDateText, updateReferralStatus, updateReferralStatusToAwaitingAllocation, updateReferralStatusToComplete, updateReferralStatusToOnProgramme, verifyAssessmentDateTextToBe };
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import { formatDate } from "../delius/utils/date-time.mjs";
|
|
2
2
|
import { expect } from "@playwright/test";
|
|
3
3
|
import { DateTime } from "luxon";
|
|
4
|
+
import { faker } from "@faker-js/faker";
|
|
4
5
|
//#region steps/accredited-programmes/application.ts
|
|
5
|
-
async function findProgrammeAndMakeReferral(page, nomisId) {
|
|
6
|
+
async function findProgrammeAndMakeReferral(page, nomisId, programmeName) {
|
|
6
7
|
await page.getByRole("link", { name: "Find a programme and make a referral" }).click();
|
|
7
8
|
await expect(page).toHaveTitle(/Find recommended programmes - Accredited Programmes - DPS/);
|
|
8
9
|
await page.getByLabel("Enter a prison number to check what programmes are recommended based on the person's risks and needs.").fill(nomisId);
|
|
9
10
|
await page.getByRole("button", { name: /Continue/ }).click();
|
|
10
11
|
await expect(page).toHaveTitle(/Accredited Programmes - DPS/);
|
|
11
12
|
await page.getByRole("button", { name: /See all programmes/ }).click();
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (programmeName == "Accredited Programme") {
|
|
14
|
+
await page.getByRole("link", { name: "Building Choices: moderate" }).click();
|
|
15
|
+
await expect(page).toHaveTitle(/Accredited Programmes - DPS/);
|
|
16
|
+
await page.getByRole("radio", { name: "No" }).click();
|
|
17
|
+
await page.getByRole("button", { name: "Continue" }).click();
|
|
18
|
+
await page.getByRole("cell", { name: "Hindley (HMP & YOI)" }).getByRole("link").click();
|
|
19
|
+
await expect(page).toHaveTitle(/Building Choices: moderate intensity/);
|
|
20
|
+
} else {
|
|
21
|
+
await page.getByRole("link", { name: "Becoming New Me Plus: general violence offence" }).click();
|
|
22
|
+
await expect(page).toHaveTitle(/Becoming New Me Plus: general violence offence programme description - DPS/);
|
|
23
|
+
await page.getByRole("cell", { name: "Moorland (HMP & YOI)" }).getByRole("link").click();
|
|
24
|
+
await expect(page).toHaveTitle(/Becoming New Me Plus: general violence offence programme/);
|
|
25
|
+
}
|
|
16
26
|
await page.getByRole("button", { name: /Make a referral/ }).click();
|
|
17
27
|
await expect(page).toHaveTitle(/Start referral - Accredited Programmes/);
|
|
18
28
|
await page.getByRole("button", { name: "Start now" }).click();
|
|
@@ -70,8 +80,74 @@ async function assertRoSHRiskTable(page, assertions) {
|
|
|
70
80
|
if (actualValue?.trim() !== expectedValue) throw new Error(`Expected "${expectedValue}" but found "${actualValue?.trim()}" for "${key}"`);
|
|
71
81
|
}
|
|
72
82
|
}
|
|
83
|
+
async function findCase(page, person, crn) {
|
|
84
|
+
await page.getByLabel("Primary navigation").getByRole("link", { name: "Case list" }).click();
|
|
85
|
+
await expect(page.locator(".govuk-heading-xl")).toContainText("Case list");
|
|
86
|
+
await page.locator("#crnOrPersonName").fill(crn);
|
|
87
|
+
await page.getByRole("button", { name: "Apply filters" }).click();
|
|
88
|
+
await page.locator("a", { hasText: `${person.firstName} ${person.lastName}` }).click();
|
|
89
|
+
await expect(page.locator(".govuk-heading-xl")).toContainText(`Referral details: ${person.firstName} ${person.lastName}`);
|
|
90
|
+
}
|
|
91
|
+
async function addCaseToGroup(page, person) {
|
|
92
|
+
await page.getByRole("link", { name: "Groups" }).click();
|
|
93
|
+
await page.getByRole("link", { name: "AutoTestGroup" }).click();
|
|
94
|
+
await page.getByRole("link", { name: "Allocations and waitlist" }).click();
|
|
95
|
+
await page.getByRole("link", { name: "Waitlist (1)" }).click();
|
|
96
|
+
await page.locator("input[name=\"add-to-group\"]").click();
|
|
97
|
+
await page.getByRole("button", { name: "Add to group" }).click();
|
|
98
|
+
await expect(page.locator("h1.govuk-fieldset__heading")).toContainText(`Add ${person.firstName} ${person.lastName} to this group?`);
|
|
99
|
+
await page.locator("input[name=\"add-to-group\"][value=\"yes\"]").click();
|
|
100
|
+
await page.getByRole("button", { name: "Continue" }).click();
|
|
101
|
+
await expect(page.locator("h1.govuk-heading-l")).toContainText(`${person.firstName} ${person.lastName}'s referral status will change to Scheduled`);
|
|
102
|
+
await page.locator("#additional-details").fill(faker.lorem.sentence());
|
|
103
|
+
await page.getByRole("button", { name: "Submit" }).click();
|
|
104
|
+
await expect(page.locator(".moj-alert__content")).toContainText(`${person.firstName} ${person.lastName} was added to this group. Their referral status is now Scheduled.`);
|
|
105
|
+
}
|
|
106
|
+
async function updateReferralStatusToAwaitingAllocation(page, person, crn, event, date) {
|
|
107
|
+
await expect(page.locator("p:right-of(:text(\"Programme Name\"))").first()).toContainText("Building Choices");
|
|
108
|
+
await expect(page.locator("p:right-of(:text(\"Name\"))").first()).toContainText(person.firstName + " " + person.lastName);
|
|
109
|
+
await expect(page.locator("p:right-of(:text(\"CRN\"))").first()).toContainText(crn);
|
|
110
|
+
await expect(page.locator("p:right-of(:text(\"Date of birth\"))").first()).toContainText(DateTime.fromJSDate(person.dob).setLocale("en-gb").toLocaleString(DateTime.DATE_FULL));
|
|
111
|
+
await expect(page.locator("p:right-of(:text(\"Sex\"))").first()).toContainText(person.sex);
|
|
112
|
+
await page.locator("a", { hasText: "Offence History" }).click();
|
|
113
|
+
await expect(page.locator("p:right-of(:text(\"Offence date\"))").first()).toContainText(date.toLocaleString("en-GB", {
|
|
114
|
+
day: "numeric",
|
|
115
|
+
month: "long",
|
|
116
|
+
year: "numeric"
|
|
117
|
+
}));
|
|
118
|
+
await page.locator("a", { hasText: "Sentence Information" }).click();
|
|
119
|
+
await expect(page.locator("p:right-of(:text(\"Sentence type\"))").first()).toContainText(event.outcome);
|
|
120
|
+
await page.getByRole("button", { name: "Update referral" }).click();
|
|
121
|
+
await page.getByRole("button", { name: "Update status" }).click();
|
|
122
|
+
await page.getByRole("radio", { name: "Awaiting allocation" }).click();
|
|
123
|
+
await page.locator("#more-details").fill(faker.lorem.sentence());
|
|
124
|
+
await page.getByRole("button", { name: "Submit" }).click();
|
|
125
|
+
await expect(page.locator(".moj-alert__content")).toContainText(`${person.firstName} ${person.lastName}'s referral status is now Awaiting allocation.`);
|
|
126
|
+
await expect(page.getByRole("heading", { name: "Awaiting allocation" })).toBeVisible();
|
|
127
|
+
}
|
|
128
|
+
async function updateReferralStatus(page) {
|
|
129
|
+
await page.getByRole("button", { name: "Update referral" }).click();
|
|
130
|
+
await page.getByRole("button", { name: "Update status" }).click();
|
|
131
|
+
await page.locator("#started-or-completed").click();
|
|
132
|
+
await page.getByRole("button", { name: "Continue" }).click();
|
|
133
|
+
await page.locator("#more-details").fill(faker.lorem.sentence());
|
|
134
|
+
await page.getByRole("button", { name: "Submit" }).click();
|
|
135
|
+
}
|
|
136
|
+
async function updateReferralStatusToOnProgramme(page, person, crn) {
|
|
137
|
+
await findCase(page, person, crn);
|
|
138
|
+
await updateReferralStatus(page);
|
|
139
|
+
await expect(page.locator(".moj-alert__content h2")).toContainText("Referral status updated");
|
|
140
|
+
await expect(page.locator(".moj-alert__content")).toContainText(`${person.firstName} ${person.lastName}'s referral status is now On programme.`);
|
|
141
|
+
await expect(page.getByRole("heading", { name: "On programme" })).toBeVisible();
|
|
142
|
+
}
|
|
143
|
+
async function updateReferralStatusToComplete(page, person) {
|
|
144
|
+
await updateReferralStatus(page);
|
|
145
|
+
await expect(page.locator(".moj-alert__content h2")).toContainText("Referral status updated");
|
|
146
|
+
await expect(page.locator(".moj-alert__content")).toContainText(`${person.firstName} ${person.lastName}'s referral status is now Programme complete.`);
|
|
147
|
+
await expect(page.getByRole("heading", { name: "Programme complete" })).toBeVisible();
|
|
148
|
+
}
|
|
73
149
|
const oasysImportDateText = "[data-testid=\"last-assessment-date-text\"]";
|
|
74
150
|
const apFormattedTodayDate = formatDate(DateTime.now(), "d MMMM yyyy");
|
|
75
151
|
const briefOffenceDetailsSummaryCard = "[data-testid=\"brief-offence-details-summary-card\"]";
|
|
76
152
|
//#endregion
|
|
77
|
-
export { apFormattedTodayDate, assertRoSHRiskTable, briefOffenceDetailsSummaryCard, clickOnOffenderLink, findProgrammeAndMakeReferral, oasysImportDateText, verifyAssessmentDateTextToBe };
|
|
153
|
+
export { addCaseToGroup, apFormattedTodayDate, assertRoSHRiskTable, briefOffenceDetailsSummaryCard, clickOnOffenderLink, findCase, findProgrammeAndMakeReferral, oasysImportDateText, updateReferralStatus, updateReferralStatusToAwaitingAllocation, updateReferralStatusToComplete, updateReferralStatusToOnProgramme, verifyAssessmentDateTextToBe };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { expect } from "@playwright/test";
|
|
2
|
+
//#region steps/accredited-programmes/manageAndDeliverLogin.ts
|
|
3
|
+
const login = async (page) => {
|
|
4
|
+
await page.goto(process.env.ACCREDITED_PROGRAMMES_MANAGE_AND_DELIVER_URL);
|
|
5
|
+
await expect(page).toHaveTitle(/HMPPS Digital Services - Sign in/);
|
|
6
|
+
await page.fill("#username", process.env.DELIUS_USERNAME);
|
|
7
|
+
await page.fill("#password", process.env.DELIUS_PASSWORD);
|
|
8
|
+
await page.click("#submit");
|
|
9
|
+
await expect(page).toHaveTitle(/Accredited Programmes/);
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { login };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Yesterday } from "../../delius/utils/date-time.mjs";
|
|
2
2
|
import { getToken } from "../auth/get-token.mjs";
|
|
3
|
-
import { setNomisId } from "../../delius/offender/update-offender.mjs";
|
|
4
3
|
import { retry, sanitiseError } from "../utils/api-utils.mjs";
|
|
4
|
+
import { setNomisId } from "../../delius/offender/update-offender.mjs";
|
|
5
5
|
import { request } from "@playwright/test";
|
|
6
6
|
import { DateTime } from "luxon";
|
|
7
7
|
import { faker } from "@faker-js/faker";
|
|
@@ -6,7 +6,8 @@ declare function recordAttendanceCompliedOutcome(page: Page, startTime?: string,
|
|
|
6
6
|
declare function recordUnacceptableAbsenceOutcome(page: Page): Promise<void>;
|
|
7
7
|
declare function adjustTravelTime(page: Page, hours: string, minutes: string): Promise<void>;
|
|
8
8
|
declare function findGroupSession(page: Page, crn: string, person: Person, projectName: string, provider: string, teamName: string): Promise<void>;
|
|
9
|
-
declare function
|
|
9
|
+
declare function findAnIndividualPlacement(page: Page, provider: string, teamName: string): Promise<string | null>;
|
|
10
|
+
declare function findAnAppointment(page: Page, provider: string): Promise<string | null>;
|
|
10
11
|
declare function recordSessionAttendance(page: Page, startTime: string, endTime: string): Promise<string | null>;
|
|
11
12
|
//#endregion
|
|
12
|
-
export { adjustTravelTime,
|
|
13
|
+
export { adjustTravelTime, findAnAppointment, findAnIndividualPlacement, findGroupSession, recordAttendanceCompliedOutcome, recordSessionAttendance, recordUnacceptableAbsenceOutcome };
|
|
@@ -64,14 +64,14 @@ async function findGroupSession(page, crn, person, projectName, provider, teamNa
|
|
|
64
64
|
await expect(page.locator("h1.govuk-heading-l")).toContainText(projectName);
|
|
65
65
|
await page.getByRole("cell", { name: person.firstName + person.lastName }).isVisible();
|
|
66
66
|
await page.getByRole("cell", { name: crn }).isVisible();
|
|
67
|
-
await page.getByRole("link", { name: "Update" }).click();
|
|
67
|
+
await page.getByRole("link", { name: "Update" }).first().click();
|
|
68
68
|
await expect(page.locator(".govuk-caption-l")).toContainText(crn);
|
|
69
|
-
await page.getByRole("button", { name: "
|
|
69
|
+
await page.getByRole("button", { name: "Update appointment" }).click();
|
|
70
70
|
await expect(page.getByRole("heading", { name: "Add supervisor details" })).toBeVisible();
|
|
71
71
|
await selectOption(page, "#supervisor", supervisor);
|
|
72
72
|
await page.getByRole("button", { name: "Continue" }).click();
|
|
73
73
|
}
|
|
74
|
-
async function
|
|
74
|
+
async function findAnIndividualPlacement(page, provider, teamName) {
|
|
75
75
|
const supervisor = "Unallocated Staff";
|
|
76
76
|
await page.getByRole("link", { name: "Record attendance with host" }).click();
|
|
77
77
|
await selectOption(page, "#provider", provider);
|
|
@@ -81,12 +81,20 @@ async function findPlacementsWithHostPartner(page, provider, teamName) {
|
|
|
81
81
|
await page.getByRole("link", { name: "Update" }).first().click();
|
|
82
82
|
const crn = await page.locator(".govuk-caption-l").textContent();
|
|
83
83
|
await expect(page.locator("h2.govuk-heading-m")).toContainText("Appointment details");
|
|
84
|
-
await page.getByRole("button", { name: "
|
|
84
|
+
await page.getByRole("button", { name: "Update appointment" }).click();
|
|
85
85
|
await expect(page.getByRole("heading", { name: "Add supervisor details" })).toBeVisible();
|
|
86
86
|
await selectOption(page, "#supervisor", supervisor);
|
|
87
87
|
await page.getByRole("button", { name: "Continue" }).click();
|
|
88
88
|
return crn;
|
|
89
89
|
}
|
|
90
|
+
async function findAnAppointment(page, provider) {
|
|
91
|
+
await page.getByRole("link", { name: "Adjust travel time hours" }).click();
|
|
92
|
+
await selectOption(page, "#provider", provider);
|
|
93
|
+
await page.getByRole("button", { name: "Apply filters" }).click();
|
|
94
|
+
const crn = await page.locator("//tbody/tr[1]/td[2]").textContent();
|
|
95
|
+
await page.getByRole("link", { name: "Update" }).first().click();
|
|
96
|
+
return crn;
|
|
97
|
+
}
|
|
90
98
|
async function recordSessionAttendance(page, startTime, endTime) {
|
|
91
99
|
await expect(page).toHaveTitle(/Record group session attendance/);
|
|
92
100
|
await page.getByRole("button", { name: "View details" }).first().click();
|
|
@@ -94,7 +102,10 @@ async function recordSessionAttendance(page, startTime, endTime) {
|
|
|
94
102
|
await page.getByRole("heading", { name: "Automated UI Tests" }).isVisible();
|
|
95
103
|
await page.getByRole("link", { name: "View and update" }).click();
|
|
96
104
|
const crn = await page.locator(".govuk-caption-l").textContent();
|
|
97
|
-
await page.getByRole("button", {
|
|
105
|
+
await page.getByRole("button", {
|
|
106
|
+
name: "Arrived",
|
|
107
|
+
exact: true
|
|
108
|
+
}).click();
|
|
98
109
|
await page.locator("#time").fill(startTime);
|
|
99
110
|
await page.getByRole("button", { name: "Confirm and continue" }).click();
|
|
100
111
|
await page.locator("input[name=\"ableToWork\"][value=\"yes\"]").click();
|
|
@@ -104,4 +115,4 @@ async function recordSessionAttendance(page, startTime, endTime) {
|
|
|
104
115
|
return crn;
|
|
105
116
|
}
|
|
106
117
|
//#endregion
|
|
107
|
-
export { adjustTravelTime,
|
|
118
|
+
export { adjustTravelTime, findAnAppointment, findAnIndividualPlacement, findGroupSession, recordAttendanceCompliedOutcome, recordSessionAttendance, recordUnacceptableAbsenceOutcome };
|
|
@@ -65,7 +65,7 @@ async function createCheckin(page, uuid, person) {
|
|
|
65
65
|
await page.getByRole("checkbox", { name: "No, I do not need any support" }).check();
|
|
66
66
|
await page.getByRole("button", { name: "Continue" }).click();
|
|
67
67
|
await page.getByRole("button", { name: "Continue" }).click();
|
|
68
|
-
await page.getByRole("button", { name: "Start
|
|
68
|
+
await page.getByRole("button", { name: "Start identity check" }).click();
|
|
69
69
|
await page.getByRole("button", { name: /Submit video anyway/ }).click();
|
|
70
70
|
await page.getByRole("checkbox", { name: /I confirm/ }).check();
|
|
71
71
|
await page.getByRole("button", { name: "Complete check in" }).click();
|