save error from async call (#32618)
* save error from async call fixes: #32609 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed test Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> --------- Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
97c032d220
commit
022ab4d263
4 changed files with 21 additions and 16 deletions
|
@ -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<T>(
|
|||
callback: PromiseResolvedFn<T>,
|
||||
deps: DependencyList = [],
|
||||
) {
|
||||
const [error, setError] = useState<unknown>();
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
const { signal } = controller;
|
||||
|
@ -61,8 +62,7 @@ export function usePromise<T>(
|
|||
return;
|
||||
}
|
||||
|
||||
// Rethrow other errors.
|
||||
throw error;
|
||||
setError(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,4 +71,9 @@ export function usePromise<T>(
|
|||
// Abort the Promise when the component unmounts, or the dependencies change.
|
||||
return () => controller.abort();
|
||||
}, deps);
|
||||
|
||||
// Rethrow other errors.
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
"enabled": true,
|
||||
"realmRoles": [],
|
||||
"clientRoles": {
|
||||
"account": ["view-groups"]
|
||||
"account": ["view-groups", "manage-account"]
|
||||
},
|
||||
"credentials": [
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue