36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import "@testing-library/jest-dom";
|
|
import { render, screen } from "@testing-library/react";
|
|
import { MemoryRouter } from "react-router";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import * as TotpRoute from "./auth.totp";
|
|
|
|
vi.mock("i18next", () => ({
|
|
t: (key: string) =>
|
|
({
|
|
"auth:totp.title": "Authenticator challenge",
|
|
"auth:totp.description": "Use the admin MFA challenge to complete sign-in.",
|
|
"account.forgot.backToLogin": "Back to login",
|
|
})[key] ?? key,
|
|
}));
|
|
|
|
describe("auth TOTP route", () => {
|
|
it("renders only the no-secret placeholder and login link", () => {
|
|
render(
|
|
<MemoryRouter>
|
|
<TotpRoute.default />
|
|
</MemoryRouter>
|
|
);
|
|
|
|
expect(screen.getByRole("heading", { name: "Authenticator challenge" })).toBeInTheDocument();
|
|
expect(screen.getByText("Use the admin MFA challenge to complete sign-in.")).toBeInTheDocument();
|
|
expect(screen.getByRole("link", { name: "Back to login" })).toHaveAttribute("href", "/login");
|
|
expect(document.body.textContent).not.toMatch(/secret|otpauth|recovery code|encrypted/i);
|
|
});
|
|
|
|
it("does not expose loader or action handlers for token or method input", () => {
|
|
expect("loader" in TotpRoute).toBe(false);
|
|
expect("action" in TotpRoute).toBe(false);
|
|
});
|
|
});
|