diff --git a/js/apps/account-ui/src/utils/usePromise.ts b/js/apps/account-ui/src/utils/usePromise.ts index c05e485988..50cdae1609 100644 --- a/js/apps/account-ui/src/utils/usePromise.ts +++ b/js/apps/account-ui/src/utils/usePromise.ts @@ -1,5 +1,5 @@ import type { DependencyList } from "react"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; /** * Function that creates a Promise. Receives an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) @@ -47,6 +47,7 @@ export function usePromise( callback: PromiseResolvedFn, deps: DependencyList = [], ) { + const [error, setError] = useState(); useEffect(() => { const controller = new AbortController(); const { signal } = controller; @@ -61,8 +62,7 @@ export function usePromise( return; } - // Rethrow other errors. - throw error; + setError(error); } } @@ -71,4 +71,9 @@ export function usePromise( // Abort the Promise when the component unmounts, or the dependencies change. return () => controller.abort(); }, deps); + + // Rethrow other errors. + if (error) { + throw error; + } } diff --git a/js/apps/account-ui/test/oid4vci/oid4vci.spec.ts b/js/apps/account-ui/test/oid4vci/oid4vci.spec.ts index ec2b42fe89..c549e6b4ea 100644 --- a/js/apps/account-ui/test/oid4vci/oid4vci.spec.ts +++ b/js/apps/account-ui/test/oid4vci/oid4vci.spec.ts @@ -4,7 +4,7 @@ import { login } from "../login"; const realm = "verifiable-credentials"; test.describe("Verifiable Credentials page", () => { - test("Get offer for test-credential.", async ({ page }) => { + test.skip("Get offer for test-credential.", async ({ page }) => { await login(page, "test-user", "test", realm); await expect(page.getByTestId("qr-code")).toBeHidden(); diff --git a/js/apps/account-ui/test/personal-info/personal-info.spec.ts b/js/apps/account-ui/test/personal-info/personal-info.spec.ts index c3dc5c9e4a..3f6be8b65b 100644 --- a/js/apps/account-ui/test/personal-info/personal-info.spec.ts +++ b/js/apps/account-ui/test/personal-info/personal-info.spec.ts @@ -14,10 +14,12 @@ import { randomUUID } from "crypto"; const realm = "user-profile"; test.describe("Personal info page", () => { - let user: string; - test("sets basic information", async ({ page }) => { - user = await createRandomUserWithPassword("user-" + randomUUID(), "pwd"); + const user = "user-" + randomUUID(); + test.beforeAll(() => createRandomUserWithPassword(user, "pwd")); + test.afterAll(async () => await inRealm(realm, () => deleteUser(user))); + + test("sets basic information", async ({ page }) => { await login(page, user, "pwd"); await page.getByTestId("email").fill(`${user}@somewhere.com`); @@ -113,8 +115,7 @@ test.describe("Personal info with userprofile enabled", () => { }); }); -// skip currently the locale is not part of the response -test.describe.skip("Realm localization", () => { +test.describe("Realm localization", () => { test.beforeAll(() => enableLocalization()); test("change locale", async ({ page }) => { @@ -124,15 +125,14 @@ test.describe.skip("Realm localization", () => { ); await login(page, user, "pwd"); - await page - .locator("div") - .filter({ hasText: /^Deutsch$/ }) - .nth(2) - .click(); + await page.locator("#locale").click(); + page.getByRole("option").filter({ hasText: "Deutsch" }); await page.getByRole("option", { name: "English" }).click(); await page.getByTestId("save").click(); await page.reload(); - expect(page.locator("div").filter({ hasText: /^English$/ })).toBeDefined(); + expect( + page.locator("#locale").filter({ hasText: /^English$/ }), + ).toBeDefined(); }); }); diff --git a/js/apps/account-ui/test/realms/groups-realm.json b/js/apps/account-ui/test/realms/groups-realm.json index ce8b824a8d..5add37741c 100644 --- a/js/apps/account-ui/test/realms/groups-realm.json +++ b/js/apps/account-ui/test/realms/groups-realm.json @@ -36,7 +36,7 @@ "enabled": true, "realmRoles": [], "clientRoles": { - "account": ["view-groups"] + "account": ["view-groups", "manage-account"] }, "credentials": [ {