Stabilize personal info tests in account console (#42007)

Closes #42006

Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Jon Koops 2025-08-21 16:37:56 +02:00 committed by GitHub
parent 2f2265435c
commit 1173ced9f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 8 deletions

View File

@ -1,7 +1,7 @@
import { type Page, expect, test } from "@playwright/test";
import groupsIdPClient from "../realms/groups-idp.json" with { type: "json" };
import userProfileRealm from "../realms/user-profile-realm.json" with { type: "json" };
import { login } from "../support/actions.ts";
import { assertLastAlert, login } from "../support/actions.ts";
import { adminClient } from "../support/admin-client.ts";
import { DEFAULT_USER, getAccountUrl, SERVER_URL } from "../support/common.ts";
import { createTestBed } from "../support/testbed.ts";
@ -92,8 +92,9 @@ test.describe("Linked accounts", () => {
.click();
// Expect an error shown that the account cannot be unlinked
await expect(page.getByTestId("last-alert")).toContainText(
"You can not remove last federated identity as you do not have a password.",
await assertLastAlert(
page,
"Could not unlink due to: You can not remove last federated identity as you do not have a password.",
);
});
});

View File

@ -1,5 +1,5 @@
import { expect, test } from "@playwright/test";
import { login } from "../support/actions.ts";
import { assertLastAlert, login } from "../support/actions.ts";
import { createTestBed } from "../support/testbed.ts";
import userProfile from "./user-profile.json" with { type: "json" };
import { adminClient } from "../support/admin-client.ts";
@ -16,8 +16,7 @@ test.describe("Personal info", () => {
await page.getByTestId("lastName").fill("de Wit");
await page.getByTestId("save").click();
const alerts = page.getByTestId("last-alert");
await expect(alerts).toHaveText("Your account has been updated.");
await assertLastAlert(page, "Your account has been updated.");
});
});
@ -80,7 +79,8 @@ test.describe("Personal info (user profile enabled)", () => {
await page.getByRole("option", { name: "two" }).click();
await page.getByTestId("email2").fill("non-valid");
await page.getByTestId("save").click();
await expect(page.getByTestId("last-alert")).toHaveText(
await assertLastAlert(
page,
"Could not update account due to validation errors",
);
@ -91,6 +91,7 @@ test.describe("Personal info (user profile enabled)", () => {
await page.getByTestId("email2").clear();
await page.getByTestId("email2").fill("valid@email.com");
await page.getByTestId("save").click();
await assertLastAlert(page, "Your account has been updated.");
await page.reload();
await page.locator("delete-account").isVisible();
@ -110,6 +111,8 @@ test.describe("Realm localization", () => {
page.getByRole("option").filter({ hasText: "Deutsch" });
await page.getByRole("option", { name: "English" }).click();
await page.getByTestId("save").click();
await assertLastAlert(page, "Your account has been updated.");
await page.reload();
expect(

View File

@ -1,4 +1,4 @@
import type { Page } from "@playwright/test";
import { expect, type Page } from "@playwright/test";
import { DEFAULT_PASSWORD, DEFAULT_USERNAME, getAccountUrl } from "./common.ts";
export async function login(
@ -25,3 +25,14 @@ export async function login(
.fill(password);
await page.getByRole("button", { name: "Sign In", exact: true }).click();
}
export async function assertLastAlert(
page: Page,
message: string,
): Promise<void> {
await expect(page.getByTestId("last-alert")).toHaveText(message);
await page
.getByTestId("last-alert")
.getByRole("button", { name: "Close alert", exact: false })
.click();
}