Secure Sakani portal and show full album titles
This commit is contained in:
1 parent
c40ccf77cf
commit
69264ce165
49 files changed
+1362
-601
No files matched your search
@@ -3,9 +3,11 @@
|
||||
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { afterEach, expect, test, vi } from "vitest";
|
||||
|
||||
const { resetPassword, signInEmail } = vi.hoisted(() => ({ resetPassword: vi.fn(), signInEmail: vi.fn() }));
|
||||
const { resetPassword, signInEmail, enableTwoFactor } = vi.hoisted(() => ({
|
||||
resetPassword: vi.fn(), signInEmail: vi.fn(), enableTwoFactor: vi.fn(),
|
||||
}));
|
||||
vi.mock("./client", () => ({
|
||||
authClient: { resetPassword, signIn: { email: signInEmail } },
|
||||
authClient: { resetPassword, signIn: { email: signInEmail }, twoFactor: { enable: enableTwoFactor } },
|
||||
}));
|
||||
|
||||
import { LoginForm, PasswordResetForm, RegistrationForm } from "./public-forms";
|
||||
@@ -58,6 +60,7 @@ test("confirms a successful password reset and links directly to login", async (
|
||||
fireEvent.submit(screen.getByRole("button", { name: /passwort aktualisieren/i }).closest("form")!);
|
||||
|
||||
expect(await screen.findByText(/passwort wurde erfolgreich aktualisiert/i)).toBeTruthy();
|
||||
expect(resetPassword).toHaveBeenCalledWith({ newPassword: "neues-passwort-123", token: "valid-token" });
|
||||
expect(screen.getByRole("link", { name: /jetzt anmelden/i }).getAttribute("href")).toBe(
|
||||
"/anmelden",
|
||||
);
|
||||
@@ -87,5 +90,36 @@ test("the two-factor step starts with an empty code field, never the typed passw
|
||||
fireEvent.submit(screen.getByLabelText("Passwort").closest("form")!);
|
||||
|
||||
const code = (await screen.findByLabelText("Zwei-Faktor-Code")) as HTMLInputElement;
|
||||
expect(signInEmail).toHaveBeenCalledWith({
|
||||
email: "admin@example.test", password: "geheim-passwort", callbackURL: "/",
|
||||
});
|
||||
expect(code.value).toBe("");
|
||||
expect(code.form?.method).toBe("post");
|
||||
});
|
||||
|
||||
test("server-rendered login and reset forms use POST for native submissions", async () => {
|
||||
const { renderToString } = await import("react-dom/server");
|
||||
const { TwoFactorWizard } = await import("@/app/zwei-faktor/wizard");
|
||||
for (const markup of [
|
||||
renderToString(<LoginForm />),
|
||||
renderToString(<PasswordResetForm token="dummy-token" />),
|
||||
renderToString(<TwoFactorWizard initiallyEnabled={false} />),
|
||||
renderToString(<TwoFactorWizard initiallyEnabled />),
|
||||
]) {
|
||||
const document = new DOMParser().parseFromString(markup, "text/html");
|
||||
const password = document.querySelector<HTMLInputElement>("input[type=password]");
|
||||
const form = password?.form;
|
||||
expect(form?.method).toBe("post");
|
||||
expect([...new FormData(form!).keys()]).toEqual([]);
|
||||
}
|
||||
});
|
||||
|
||||
test("the enrollment confirmation code form uses POST", async () => {
|
||||
const { TwoFactorWizard } = await import("@/app/zwei-faktor/wizard");
|
||||
enableTwoFactor.mockResolvedValueOnce({ data: { totpURI: "otpauth://totp/dummy?secret=DUMMY", backupCodes: [] } });
|
||||
render(<TwoFactorWizard initiallyEnabled={false} />);
|
||||
fireEvent.submit(screen.getByRole("button", { name: "Einrichtung starten" }).closest("form")!);
|
||||
const field = await screen.findByLabelText<HTMLInputElement>("Code aus der App");
|
||||
expect(field.form?.method).toBe("post");
|
||||
expect([...new FormData(field.form!).keys()]).toEqual([]);
|
||||
});
|
||||
Reference in new issue
Block a user