@ministryofjustice/hmpps-probation-integration-e2e-tests 1.213.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 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.213.0",
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": {
@@ -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
- await page.getByRole("link", { name: "Becoming New Me Plus: general violence offence" }).click();
13
- await expect(page).toHaveTitle(/Becoming New Me Plus: general violence offence programme description - DPS/);
14
- await page.getByRole("cell", { name: "Moorland (HMP & YOI)" }).getByRole("link").click();
15
- await expect(page).toHaveTitle(/Becoming New Me Plus: general violence offence programme/);
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,6 @@
1
+ import { Page } from "@playwright/test";
2
+
3
+ //#region steps/accredited-programmes/manageAndDeliverLogin.d.ts
4
+ declare const login: (page: Page) => Promise<void>;
5
+ //#endregion
6
+ export { login };
@@ -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";
@@ -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", { name: "Arrived" }).click();
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();
@@ -44,6 +44,10 @@ const commonData = {
44
44
  category: "Unpaid Work",
45
45
  subCategory: "Regular",
46
46
  length: "120"
47
+ },
48
+ accreditedProgramme: {
49
+ category: "Court - Accredited Programme",
50
+ subCategory: "Building Choices"
47
51
  }
48
52
  },
49
53
  staff: { unallocated: {