@ministryofjustice/hmpps-probation-integration-e2e-tests 1.212.0 → 1.214.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 +3 -2
- 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/community-payback/record-outcome.d.mts +2 -2
- package/steps/community-payback/record-outcome.mjs +4 -1
- package/steps/court-case/hearing-data.d.mts +2 -2
- package/steps/delius/offender/find-offender.d.mts +1 -1
- package/steps/referandmonitor/referral.d.mts +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.214.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/ministryofjustice/hmpps-probation-integration-e2e-tests#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -31,11 +31,12 @@
|
|
|
31
31
|
"eslint-config-prettier": "^10.0.1",
|
|
32
32
|
"eslint-plugin-prettier": "^5.2.1",
|
|
33
33
|
"prettier": "3.8.3",
|
|
34
|
-
"tsdown": "^0.
|
|
34
|
+
"tsdown": "^0.22.0"
|
|
35
35
|
},
|
|
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 };
|
|
@@ -6,7 +6,7 @@ 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 findPlacementsWithHostPartner(page: Page, provider: string, teamName: string): Promise<string>;
|
|
10
|
-
declare function recordSessionAttendance(page: Page, startTime: string, endTime: string): Promise<string>;
|
|
9
|
+
declare function findPlacementsWithHostPartner(page: Page, provider: string, teamName: string): Promise<string | null>;
|
|
10
|
+
declare function recordSessionAttendance(page: Page, startTime: string, endTime: string): Promise<string | null>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { adjustTravelTime, findGroupSession, findPlacementsWithHostPartner, recordAttendanceCompliedOutcome, recordSessionAttendance, recordUnacceptableAbsenceOutcome };
|
|
@@ -94,7 +94,10 @@ async function recordSessionAttendance(page, startTime, endTime) {
|
|
|
94
94
|
await page.getByRole("heading", { name: "Automated UI Tests" }).isVisible();
|
|
95
95
|
await page.getByRole("link", { name: "View and update" }).click();
|
|
96
96
|
const crn = await page.locator(".govuk-caption-l").textContent();
|
|
97
|
-
await page.getByRole("button", {
|
|
97
|
+
await page.getByRole("button", {
|
|
98
|
+
name: "Arrived",
|
|
99
|
+
exact: true
|
|
100
|
+
}).click();
|
|
98
101
|
await page.locator("#time").fill(startTime);
|
|
99
102
|
await page.getByRole("button", { name: "Confirm and continue" }).click();
|
|
100
103
|
await page.locator("input[name=\"ableToWork\"][value=\"yes\"]").click();
|
|
@@ -32,7 +32,7 @@ declare const hearingData: (person: Person, address?: Address, court?: {
|
|
|
32
32
|
id: string;
|
|
33
33
|
defendants: {
|
|
34
34
|
id: `${string}-${string}-${string}-${string}-${string}`;
|
|
35
|
-
pncId: string;
|
|
35
|
+
pncId: string | undefined;
|
|
36
36
|
prosecutionCaseId: string;
|
|
37
37
|
personDefendant: {
|
|
38
38
|
personDetails: {
|
|
@@ -49,7 +49,7 @@ declare const hearingData: (person: Person, address?: Address, court?: {
|
|
|
49
49
|
work: string;
|
|
50
50
|
mobile: string;
|
|
51
51
|
};
|
|
52
|
-
dateOfBirth: string;
|
|
52
|
+
dateOfBirth: string | null;
|
|
53
53
|
firstName: string;
|
|
54
54
|
gender: string;
|
|
55
55
|
lastName: string;
|
|
@@ -6,7 +6,7 @@ import { Page } from "@playwright/test";
|
|
|
6
6
|
declare function findOffenderByName(page: Page, forename: string, surname: string): Promise<void>;
|
|
7
7
|
declare function findOffenderByCRN(page: Page, crn: string): Promise<void>;
|
|
8
8
|
declare function findOffenderByCRNNoContextCheck(page: Page, crn: string): Promise<void>;
|
|
9
|
-
declare function findFirstOffender(page: Page, person: Person, provider: string): Promise<string>;
|
|
9
|
+
declare function findFirstOffender(page: Page, person: Person, provider: string): Promise<string | null | undefined>;
|
|
10
10
|
declare function findOffenderByNomisId(page: Page, nomisId: string): Promise<string>;
|
|
11
11
|
declare function verifyAllocation(page: Page, args: {
|
|
12
12
|
allocation: Allocation;
|
|
@@ -2,7 +2,7 @@ import { Page } from "@playwright/test";
|
|
|
2
2
|
|
|
3
3
|
//#region steps/referandmonitor/referral.d.ts
|
|
4
4
|
declare const referralProgress: (page: Page, referralRef: string) => Promise<void>;
|
|
5
|
-
declare const makeReferral: (page: Page, crn: string) => Promise<string>;
|
|
5
|
+
declare const makeReferral: (page: Page, crn: string) => Promise<string | null>;
|
|
6
6
|
declare const assignReferral: (page: Page, referralRef: string) => Promise<void>;
|
|
7
7
|
declare const withdrawReferral: (page: Page, referralRef: string) => Promise<void>;
|
|
8
8
|
//#endregion
|