@ministryofjustice/hmpps-probation-integration-e2e-tests 1.117.0 → 1.119.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.117.0",
4
+ "version": "1.119.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ministryofjustice/hmpps-probation-integration-e2e-tests#readme",
7
7
  "bugs": {
@@ -17,7 +17,7 @@
17
17
  "dependencies": {
18
18
  "@faker-js/faker": "^10.0.0",
19
19
  "@kubernetes/client-node": "^1.0.0",
20
- "@playwright/test": "1.56.0",
20
+ "@playwright/test": "1.56.1",
21
21
  "dotenv": "^17.0.0",
22
22
  "luxon": "^3.5.0",
23
23
  "node-stream-zip": "^1.15.0",
@@ -97,6 +97,7 @@
97
97
  "./steps/cvl-licences/application": "./steps/cvl-licences/application.mjs",
98
98
  "./steps/cvl-licences/login": "./steps/cvl-licences/login.mjs",
99
99
  "./steps/delius/address/create-address": "./steps/delius/address/create-address.mjs",
100
+ "./steps/delius/address/delete-addresses": "./steps/delius/address/delete-addresses.mjs",
100
101
  "./steps/delius/contact/create-contact": "./steps/delius/contact/create-contact.mjs",
101
102
  "./steps/delius/contact/find-contacts": "./steps/delius/contact/find-contacts.mjs",
102
103
  "./steps/delius/court-report/find-court-report": "./steps/delius/court-report/find-court-report.mjs",
@@ -53,8 +53,7 @@ async function clickOnOffenderLink(page, linkName, fullName) {
53
53
  await nameLink.click();
54
54
  }
55
55
  async function verifyAssessmentDateTextToBe(page, expectedText) {
56
- const actualText = await page.locator(oasysImportDateText).first().evaluate((el) => el.textContent?.trim().replace(/\s+/g, " "));
57
- expect(actualText).toBe(expectedText);
56
+ expect(await page.locator(oasysImportDateText).first().evaluate((el) => el.textContent?.trim().replace(/\s+/g, " "))).toBe(expectedText);
58
57
  }
59
58
  async function assertRoSHRiskTable(page, assertions) {
60
59
  const selectors = {
@@ -3,14 +3,13 @@ import { expect, request } from "@playwright/test";
3
3
 
4
4
  //#region steps/api/prison-identifier-and-delius/prison-identifier-and-delius.ts
5
5
  async function triggerMatching(nomsNumber) {
6
- const response = await (await request.newContext({ baseURL: process.env.PRISON_IDENTIFIER_AND_DELIUS_URL })).post(`/person/match-by-noms?dryRun=false`, {
6
+ expect((await (await request.newContext({ baseURL: process.env.PRISON_IDENTIFIER_AND_DELIUS_URL })).post(`/person/match-by-noms?dryRun=false`, {
7
7
  headers: {
8
8
  Authorization: `Bearer ${await getToken()}`,
9
9
  "Content-Type": "application/json"
10
10
  },
11
11
  data: JSON.stringify([nomsNumber])
12
- });
13
- expect(response.ok()).toBeTruthy();
12
+ })).ok()).toBeTruthy();
14
13
  }
15
14
 
16
15
  //#endregion
@@ -1,6 +1,6 @@
1
1
  //#region steps/api/utils/api-utils.d.ts
2
2
  declare const sanitiseError: <T>(fn: AsyncFunction<T>) => AsyncFunction<T>;
3
3
  declare const retry: <T>(fn: AsyncFunction<T>, retryCount?: number) => AsyncFunction<T>;
4
- type AsyncFunction<T> = (...args: unknown[]) => Promise<T>;
4
+ type AsyncFunction<T$1> = (...args: unknown[]) => Promise<T$1>;
5
5
  //#endregion
6
6
  export { retry, sanitiseError };
@@ -45,9 +45,7 @@ async function confirmEligibilityAndConsent(page) {
45
45
  await fillDateInput(page, "When did they give consent?");
46
46
  await page.getByRole("button", { name: "Save and continue" }).click();
47
47
  await expect(page).toHaveTitle("The person's Home Detention Curfew (HDC) licence dates - Short-Term Accommodation (CAS-2)");
48
- const hdcEligibilityDate = await fillDateInput(page, "HDC eligibility date", 1);
49
- const conditionalReleaseDate = await fillDateInput(page, "conditional release date", 2);
50
- if (hdcEligibilityDate >= conditionalReleaseDate) throw new Error("HDC eligibility date must be before the conditional release date.");
48
+ if (await fillDateInput(page, "HDC eligibility date", 1) >= await fillDateInput(page, "conditional release date", 2)) throw new Error("HDC eligibility date must be before the conditional release date.");
51
49
  await page.getByRole("button", { name: "Save and continue" }).click();
52
50
  await expect(page).toHaveTitle(/Task list/);
53
51
  }
@@ -54,11 +54,9 @@ async function extractRegistrationDetails(page) {
54
54
  async function extractProbationRecordDetails(page) {
55
55
  await page.getByRole("link", { name: "Probation record" }).click();
56
56
  await expect(page).toHaveTitle("Probation record - Prepare a case for sentence");
57
- const outcome = await page.locator(".govuk-summary-card__title").innerText();
58
- const offence = await page.locator("dd p.govuk-body").first().innerText();
59
57
  return {
60
- outcome,
61
- offence
58
+ outcome: await page.locator(".govuk-summary-card__title").innerText(),
59
+ offence: await page.locator("dd p.govuk-body").first().innerText()
62
60
  };
63
61
  }
64
62
 
@@ -58,9 +58,7 @@ const approveLicence = async (page, crn, nomsNumber, establishment) => {
58
58
  await page.getByRole("link", { name: /Sign out/ }).click();
59
59
  };
60
60
  const cvlFormattedPhoneNumber = () => {
61
- const areaCode = "01" + Math.floor(Math.random() * 1e3).toString().padStart(2, "0");
62
- const cityNumber = Math.floor(Math.random() * 1e6).toString().padStart(6, "0");
63
- return `${areaCode} ${cityNumber}`;
61
+ return `${"01" + Math.floor(Math.random() * 1e3).toString().padStart(2, "0")} ${Math.floor(Math.random() * 1e6).toString().padStart(6, "0")}`;
64
62
  };
65
63
 
66
64
  //#endregion
@@ -0,0 +1,6 @@
1
+ import { Page } from "@playwright/test";
2
+
3
+ //#region steps/delius/address/delete-addresses.d.ts
4
+ declare const deleteAddresses: (page: Page, crn: string) => Promise<void>;
5
+ //#endregion
6
+ export { deleteAddresses };
@@ -0,0 +1,19 @@
1
+ import { findOffenderByCRN } from "../offender/find-offender.mjs";
2
+ import { expect } from "@playwright/test";
3
+
4
+ //#region steps/delius/address/delete-addresses.ts
5
+ const deleteAddresses = async (page, crn) => {
6
+ await findOffenderByCRN(page, crn);
7
+ await page.getByRole("link", { name: "Personal Details" }).click();
8
+ await page.getByRole("link", { name: "Addresses" }).click();
9
+ await expect(page.locator("h1")).toContainText("Addresses and Accommodation");
10
+ while (await page.locator("#otherAddressTable tbody tr").count() > 1) {
11
+ await page.locator("#otherAddressTable tbody tr").first().locator("a[title=\"Link to Delete this Address\"]").click();
12
+ await expect(page.locator("h1")).toContainText("Delete Address");
13
+ await page.locator("input", { hasText: "Confirm" }).click();
14
+ await expect(page.locator("h1")).toContainText("Addresses and Accommodation");
15
+ }
16
+ };
17
+
18
+ //#endregion
19
+ export { deleteAddresses };
@@ -107,13 +107,11 @@ const updateSAAppointmentLocation = async (page, referralRef, appointmentMethod,
107
107
  await page.waitForURL(/service-provider\/referrals\/.*\/supplier-assessment\/rescheduled-confirmation/);
108
108
  await page.locator(".govuk-button", { hasText: "Return to progress" }).click();
109
109
  await page.getByRole("link", { name: "View details or reschedule" }).click();
110
- const appointmentDL = await page.locator(".govuk-summary-list");
111
- await expect(await appointmentDL.locator("p").nth(4).textContent()).toContain(NPSLocationToBeVerifiedInRAndM);
110
+ await expect(await (await page.locator(".govuk-summary-list")).locator("p").nth(4).textContent()).toContain(NPSLocationToBeVerifiedInRAndM);
112
111
  };
113
112
  const verifySAApptmntLocationInDelius = async (page, appointmentType, NPSOfficeLocationToBeVerified) => {
114
113
  await (await page.locator("tr", { hasText: appointmentType })).locator("[title=\"Link to view the contact details.\"]").click();
115
- const location = await page.locator("#location\\:outputText").textContent();
116
- await expect(location).toBe(NPSOfficeLocationToBeVerified);
114
+ await expect(await page.locator("#location\\:outputText").textContent()).toBe(NPSOfficeLocationToBeVerified);
117
115
  };
118
116
  const fillAndSaveIfTextBoxIsAvailable = async (page, textBoxLocator, textToBeEnteredInTextBox, saveButtonLocator, radioButtonLocator) => {
119
117
  const textBox = page.locator(textBoxLocator);
@@ -36,8 +36,7 @@ const verifyDate = async (page, label, date) => {
36
36
  await expect(page.locator(`[id="${id}"]`)).toHaveText(DeliusDateFormatter(date));
37
37
  };
38
38
  const verifyTableDate = async (page, label, date) => {
39
- const matchingRecord = page.locator("tr", { hasText: label });
40
- await expect(matchingRecord).toContainText(DeliusDateFormatter(date));
39
+ await expect(page.locator("tr", { hasText: label })).toContainText(DeliusDateFormatter(date));
41
40
  };
42
41
 
43
42
  //#endregion
@@ -23,7 +23,7 @@ async function findOffenderByCRN(page, crn) {
23
23
  await page.locator("tr", { hasText: crn }).locator("a", { hasText: "View" }).click();
24
24
  await dismissModals(page);
25
25
  }
26
- await expect(page).toHaveTitle(/Case Summary/);
26
+ await expect(page.getByRole("heading", { name: "Case Summary" })).toBeVisible({ timeout: 1e4 });
27
27
  }
28
28
  async function findOffenderByCRNNoContextCheck(page, crn) {
29
29
  await page.locator("#navigation-include\\:linkNavigation1Search", { hasText: "National search" }).click();
@@ -81,8 +81,7 @@ const verifyRecallOffendersAddress = async (page, street, city, postcode) => {
81
81
  };
82
82
  const verifyLicenceCondition = async (page, licenceCondition) => {
83
83
  await page.getByRole("link", { name: "Licence conditions" }).click();
84
- const recallLicenseDesc = await page.locator("#accordion-with-summary-sections-content-2 p, [data-qa=\"condition-description\"]").first().textContent();
85
- await expect(recallLicenseDesc).toMatch(licenceCondition.replace(/(.*)-/, "").trim());
84
+ await expect(await page.locator("#accordion-with-summary-sections-content-2 p, [data-qa=\"condition-description\"]").first().textContent()).toMatch(licenceCondition.replace(/(.*)-/, "").trim());
86
85
  };
87
86
  const verifyContact = async (page, contactDetails) => {
88
87
  await page.getByRole("link", { name: "Contact history" }).click();
@@ -15,10 +15,7 @@ const months = [
15
15
  ];
16
16
  const WorkforceDateFormat = (date) => {
17
17
  if (!date.isValid) throw new Error("Invalid DateTime object provided");
18
- const day = date.day;
19
- const month = months[date.month - 1];
20
- const year = date.year;
21
- return `${day} ${month} ${year}`;
18
+ return `${date.day} ${months[date.month - 1]} ${date.year}`;
22
19
  };
23
20
 
24
21
  //#endregion