Files
Termix/src/ui/tests/shell/SafeModeNotice.test.tsx
T
96b8520fb4 v26.10.5 (#1710)
* feat: add an auto or fixed columns picker to card grids

* feat: add safe mode that only runs layout and theme plugins

* docs: add simple layout to plugin table

* fix: ask for local network access in the macOS app

* feat: allow plugin registries on listed private hosts (#1705)

* chore: add private registry hosts to the changelog

* feat: use the proxy for plugin registry downloads

* fix: allow changing connection origin on shared hosts

* chore: update translations and plugin pins

* chore: lint, format, and bump version to 26.10.5

---------

Co-authored-by: Lukas <80832688+0skater0@users.noreply.github.com>
2026-10-22 13:30:48 -05:00

46 lines
1.2 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { cleanup, render } from "@testing-library/react";
const toast = vi.hoisted(() => ({ warning: vi.fn() }));
vi.mock("sonner", () => ({ toast }));
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (key: string) => key }),
}));
const look = vi.hoisted(() => ({ safeMode: false }));
vi.mock("@/look/look-store", () => ({
useLookState: () => ({
loaded: true,
response: { safeMode: look.safeMode },
}),
}));
const { SafeModeNotice } = await import("@/shell/SafeModeNotice");
afterEach(() => {
cleanup();
toast.warning.mockReset();
});
describe("SafeModeNotice", () => {
it("shows nothing when safe mode is off", () => {
look.safeMode = false;
render(<SafeModeNotice />);
expect(toast.warning).not.toHaveBeenCalled();
});
it("shows a lasting warning when the server runs in safe mode", () => {
look.safeMode = true;
render(<SafeModeNotice />);
expect(toast.warning).toHaveBeenCalledWith(
"safeMode.title",
expect.objectContaining({
id: "safe-mode",
description: "safeMode.description",
duration: Infinity,
}),
);
});
});