mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
feat: port the demo redesign with Manage and Settings tabs
This commit is contained in:
1 parent
f8151cb885
commit
35c954b79a
128 files changed
+13262
-8143
No files matched your search
@@ -0,0 +1,66 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
import { TOTPDialog } from "@/ssh/dialogs/TOTPDialog";
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
describe("TOTPDialog", () => {
|
||||
it("submits the code", () => {
|
||||
const onSubmit = vi.fn();
|
||||
render(
|
||||
<TOTPDialog isOpen prompt="" onSubmit={onSubmit} onCancel={vi.fn()} />,
|
||||
);
|
||||
expect(
|
||||
screen.getByRole("dialog", { name: "sshAuth.totpRequired" }),
|
||||
).toBeTruthy();
|
||||
fireEvent.change(screen.getByPlaceholderText("000000"), {
|
||||
target: { value: "123456" },
|
||||
});
|
||||
fireEvent.click(screen.getByRole("button", { name: "sshAuth.totpVerify" }));
|
||||
expect(onSubmit).toHaveBeenCalledWith("123456");
|
||||
});
|
||||
|
||||
it("sends an empty answer for a push prompt and then waits", () => {
|
||||
const onSubmit = vi.fn();
|
||||
render(
|
||||
<TOTPDialog
|
||||
isOpen
|
||||
prompt=""
|
||||
mode="push"
|
||||
onSubmit={onSubmit}
|
||||
onCancel={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
fireEvent.click(
|
||||
screen.getByRole("button", { name: "sshAuth.mfaSendRequest" }),
|
||||
);
|
||||
expect(onSubmit).toHaveBeenCalledWith("");
|
||||
expect(screen.getByText("sshAuth.mfaWaitingApproval")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("cancels", () => {
|
||||
const onCancel = vi.fn();
|
||||
render(
|
||||
<TOTPDialog isOpen prompt="" onSubmit={vi.fn()} onCancel={onCancel} />,
|
||||
);
|
||||
fireEvent.click(screen.getByRole("button", { name: "common.cancel" }));
|
||||
expect(onCancel).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("renders nothing when closed", () => {
|
||||
render(
|
||||
<TOTPDialog
|
||||
isOpen={false}
|
||||
prompt=""
|
||||
onSubmit={vi.fn()}
|
||||
onCancel={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
expect(screen.queryByRole("dialog")).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user