From 1b6e77c52ca1543562897d42dadbe3e9bc8f2acb Mon Sep 17 00:00:00 2001 From: abigailflorence97 Date: Fri, 25 Jul 2025 14:29:10 +0100 Subject: [PATCH 1/3] add test for update user --- package.json | 2 +- playwright-e2e/tests/user-tests.spec.ts | 42 +++++++++++++++++++++++++ playwright-e2e/utils/config.utils.ts | 2 +- yarn.lock | 10 +++--- 4 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 playwright-e2e/tests/user-tests.spec.ts diff --git a/package.json b/package.json index 3a080b4..9afd151 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "devDependencies": { "@axe-core/playwright": "^4.10.0", "@eslint/js": "^9.11.1", - "@hmcts/playwright-common": "^1.0.30", + "@hmcts/playwright-common": "/Users/abigailsmith/HMCTS/playwright-common/package.tgz", "@playwright/test": "^1.48.2", "@types/node": "^22.15.34", "@typescript-eslint/eslint-plugin": "^8.8.0", diff --git a/playwright-e2e/tests/user-tests.spec.ts b/playwright-e2e/tests/user-tests.spec.ts new file mode 100644 index 0000000..ad15cff --- /dev/null +++ b/playwright-e2e/tests/user-tests.spec.ts @@ -0,0 +1,42 @@ +import { expect, test } from "../fixtures"; + +test.describe("User tests using idam utils", () => { + test("Update user", async ({ + page, + config, + citizenUserUtils, + idamPage, + idamUtils, + }) => { + //create citizen user + const token = process.env.CREATE_USER_BEARER_TOKEN as string; + const user = await citizenUserUtils.createUser(); + await page.goto(config.urls.citizenUrl); + + //login citizen user + await idamPage.login({ + username: user.email, + password: user.password, + }); + + //get user id for citizen user + const userInfo = await idamUtils.getUserInfo({ + email: user.email, + bearerToken: token, + }); + console.log(userInfo); + + //update user with new forename and surname + await idamUtils.updateUser({ + id: userInfo.id, + bearerToken: token, + password: user.password, + user: { + email: user.email, + forename: "changed forename", + surname: "changed surname", + roleNames: ["citizen"], + }, + }); + }); +}); diff --git a/playwright-e2e/utils/config.utils.ts b/playwright-e2e/utils/config.utils.ts index 7c894f7..b4b32c3 100644 --- a/playwright-e2e/utils/config.utils.ts +++ b/playwright-e2e/utils/config.utils.ts @@ -3,7 +3,7 @@ import path from "path"; import { fileURLToPath } from "url"; // This needs to be placed somewhere before attempting to access any environment variables -dotenv.config({ quiet: true }); +dotenv.config(); export interface UserCredentials { username: string; diff --git a/yarn.lock b/yarn.lock index 9a0dd15..f5768a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -153,9 +153,9 @@ __metadata: languageName: node linkType: hard -"@hmcts/playwright-common@npm:^1.0.30": - version: 1.0.32 - resolution: "@hmcts/playwright-common@npm:1.0.32" +"@hmcts/playwright-common@file:/Users/abigailsmith/HMCTS/playwright-common/package.tgz::locator=tcoe-playwright-example%40workspace%3A.": + version: 1.0.33 + resolution: "@hmcts/playwright-common@file:/Users/abigailsmith/HMCTS/playwright-common/package.tgz#/Users/abigailsmith/HMCTS/playwright-common/package.tgz::hash=14fd99&locator=tcoe-playwright-example%40workspace%3A." dependencies: "@axe-core/playwright": "npm:^4.10.0" "@eslint/js": "npm:^9.11.1" @@ -170,7 +170,7 @@ __metadata: typescript-eslint: "npm:^8.8.0" peerDependencies: "@playwright/test": ^1.53.0 - checksum: 10/cec3a079d220c2402e9621693d3b0581b3e6bac8e33304c93d418ae8de73f05f18611413d9d26697a5c5a55d31610d75381388e79ed2eabd7bc6d21764163496 + checksum: 10/d21c46b171ea023544905540b9c8f266c2d6e487f44588547e4a6657d89245e168b3a5a281aef7a94b2103f42c796db829ac36a1d18b6d0e63b7553d0aee393b languageName: node linkType: hard @@ -3388,7 +3388,7 @@ __metadata: dependencies: "@axe-core/playwright": "npm:^4.10.0" "@eslint/js": "npm:^9.11.1" - "@hmcts/playwright-common": "npm:^1.0.30" + "@hmcts/playwright-common": /Users/abigailsmith/HMCTS/playwright-common/package.tgz "@playwright/test": "npm:^1.48.2" "@types/node": "npm:^22.15.34" "@typescript-eslint/eslint-plugin": "npm:^8.8.0" From 68f2439dfa879c659c151f80729df2548191c503 Mon Sep 17 00:00:00 2001 From: abigailflorence97 Date: Fri, 25 Jul 2025 16:30:32 +0100 Subject: [PATCH 2/3] fix --- package.json | 2 +- playwright-e2e/tests/user-tests.spec.ts | 5 +++-- yarn.lock | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9afd151..e8a03a4 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "devDependencies": { "@axe-core/playwright": "^4.10.0", "@eslint/js": "^9.11.1", - "@hmcts/playwright-common": "/Users/abigailsmith/HMCTS/playwright-common/package.tgz", + "@hmcts/playwright-common": "^1.0.33", "@playwright/test": "^1.48.2", "@types/node": "^22.15.34", "@typescript-eslint/eslint-plugin": "^8.8.0", diff --git a/playwright-e2e/tests/user-tests.spec.ts b/playwright-e2e/tests/user-tests.spec.ts index ad15cff..712bd3e 100644 --- a/playwright-e2e/tests/user-tests.spec.ts +++ b/playwright-e2e/tests/user-tests.spec.ts @@ -1,4 +1,4 @@ -import { expect, test } from "../fixtures"; +import { test } from "../fixtures"; test.describe("User tests using idam utils", () => { test("Update user", async ({ @@ -27,7 +27,7 @@ test.describe("User tests using idam utils", () => { console.log(userInfo); //update user with new forename and surname - await idamUtils.updateUser({ + const userUpdate = await idamUtils.updateUser({ id: userInfo.id, bearerToken: token, password: user.password, @@ -38,5 +38,6 @@ test.describe("User tests using idam utils", () => { roleNames: ["citizen"], }, }); + console.log(userUpdate); }); }); diff --git a/yarn.lock b/yarn.lock index f5768a5..bdc7ff7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -155,7 +155,7 @@ __metadata: "@hmcts/playwright-common@file:/Users/abigailsmith/HMCTS/playwright-common/package.tgz::locator=tcoe-playwright-example%40workspace%3A.": version: 1.0.33 - resolution: "@hmcts/playwright-common@file:/Users/abigailsmith/HMCTS/playwright-common/package.tgz#/Users/abigailsmith/HMCTS/playwright-common/package.tgz::hash=14fd99&locator=tcoe-playwright-example%40workspace%3A." + resolution: "@hmcts/playwright-common@file:/Users/abigailsmith/HMCTS/playwright-common/package.tgz#/Users/abigailsmith/HMCTS/playwright-common/package.tgz::hash=4d1c17&locator=tcoe-playwright-example%40workspace%3A." dependencies: "@axe-core/playwright": "npm:^4.10.0" "@eslint/js": "npm:^9.11.1" @@ -170,7 +170,7 @@ __metadata: typescript-eslint: "npm:^8.8.0" peerDependencies: "@playwright/test": ^1.53.0 - checksum: 10/d21c46b171ea023544905540b9c8f266c2d6e487f44588547e4a6657d89245e168b3a5a281aef7a94b2103f42c796db829ac36a1d18b6d0e63b7553d0aee393b + checksum: 10/287351f1c58d09f131bf15bb6acfc01ec3a1013f4ef25c9992ae2b372ffb2294a5114291da7721b3aaa7b884339b844daefcbfaa0ad11a079bef210942fd553a languageName: node linkType: hard From 9c916348458cdd2c0aa773da0da67abc0b03651e Mon Sep 17 00:00:00 2001 From: abigailflorence97 Date: Wed, 30 Jul 2025 10:46:26 +0100 Subject: [PATCH 3/3] use new pw common lib version and revert mistake --- playwright-e2e/utils/config.utils.ts | 2 +- yarn.lock | 34 +++++----------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/playwright-e2e/utils/config.utils.ts b/playwright-e2e/utils/config.utils.ts index b4b32c3..7c894f7 100644 --- a/playwright-e2e/utils/config.utils.ts +++ b/playwright-e2e/utils/config.utils.ts @@ -3,7 +3,7 @@ import path from "path"; import { fileURLToPath } from "url"; // This needs to be placed somewhere before attempting to access any environment variables -dotenv.config(); +dotenv.config({ quiet: true }); export interface UserCredentials { username: string; diff --git a/yarn.lock b/yarn.lock index bdc7ff7..df0a988 100644 --- a/yarn.lock +++ b/yarn.lock @@ -153,24 +153,24 @@ __metadata: languageName: node linkType: hard -"@hmcts/playwright-common@file:/Users/abigailsmith/HMCTS/playwright-common/package.tgz::locator=tcoe-playwright-example%40workspace%3A.": +"@hmcts/playwright-common@npm:^1.0.33": version: 1.0.33 - resolution: "@hmcts/playwright-common@file:/Users/abigailsmith/HMCTS/playwright-common/package.tgz#/Users/abigailsmith/HMCTS/playwright-common/package.tgz::hash=4d1c17&locator=tcoe-playwright-example%40workspace%3A." + resolution: "@hmcts/playwright-common@npm:1.0.33" dependencies: "@axe-core/playwright": "npm:^4.10.0" "@eslint/js": "npm:^9.11.1" "@typescript-eslint/eslint-plugin": "npm:^8.8.0" eslint: "npm:^9.11.1" - eslint-plugin-playwright: "npm:^1.6.2" + eslint-plugin-playwright: "npm:^2.0.0" get-port: "npm:^7.1.0" - globals: "npm:^15.10.0" + globals: "npm:^16.0.0" lighthouse: "npm:^12.2.1" playwright-lighthouse: "npm:^4.0.0" typescript: "npm:^5.6.2" typescript-eslint: "npm:^8.8.0" peerDependencies: "@playwright/test": ^1.53.0 - checksum: 10/287351f1c58d09f131bf15bb6acfc01ec3a1013f4ef25c9992ae2b372ffb2294a5114291da7721b3aaa7b884339b844daefcbfaa0ad11a079bef210942fd553a + checksum: 10/bcdde79e4dfd16635614493c234ed49fc6ecd7d8c0d33d649c8b368e262d37a986fbfcaf9ea99d30b00899304986ede7626ab02626dc5b8ea6e5fd4b53953052 languageName: node linkType: hard @@ -1624,21 +1624,6 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-playwright@npm:^1.6.2": - version: 1.8.3 - resolution: "eslint-plugin-playwright@npm:1.8.3" - dependencies: - globals: "npm:^13.23.0" - peerDependencies: - eslint: ">=8.40.0" - eslint-plugin-jest: ">=25" - peerDependenciesMeta: - eslint-plugin-jest: - optional: true - checksum: 10/8a0b9f51ba1eb09e64e15452cc78ab7fc82a68e45a432185acc2851eb0ad67b683e9bb2ca9ac9791267608ca0ceb0fca2b551868d494831e1ed62b2c566c099e - languageName: node - linkType: hard - "eslint-plugin-playwright@npm:^2.0.0": version: 2.2.0 resolution: "eslint-plugin-playwright@npm:2.2.0" @@ -2053,13 +2038,6 @@ __metadata: languageName: node linkType: hard -"globals@npm:^15.10.0": - version: 15.15.0 - resolution: "globals@npm:15.15.0" - checksum: 10/7f561c87b2fd381b27fc2db7df8a4ea7a9bb378667b8a7193e61fd2ca3a876479174e2a303a74345fbea6e1242e16db48915c1fd3bf35adcf4060a795b425e18 - languageName: node - linkType: hard - "globals@npm:^16.0.0": version: 16.3.0 resolution: "globals@npm:16.3.0" @@ -3388,7 +3366,7 @@ __metadata: dependencies: "@axe-core/playwright": "npm:^4.10.0" "@eslint/js": "npm:^9.11.1" - "@hmcts/playwright-common": /Users/abigailsmith/HMCTS/playwright-common/package.tgz + "@hmcts/playwright-common": "npm:^1.0.33" "@playwright/test": "npm:^1.48.2" "@types/node": "npm:^22.15.34" "@typescript-eslint/eslint-plugin": "npm:^8.8.0"