Open History to see the last commit
1import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings";
2import * as Schema from "effect/Schema";
3import { describe, expect, it, vi } from "vite-plus/test";
4
5import "~/index.css";
6import { render } from "../../../test/render";
7import { TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "../../appearanceFonts";
8import { getLocalStorageItem, removeLocalStorageItem } from "../../hooks/useLocalStorage";
9import { TypographySection } from "./TypographySettings";
10
11const state = vi.hoisted(() => ({ searchTargetId: null as string | null }));
12
13vi.mock(import("./useScopedSettings"), async (original) => ({
14 ...(await original()),
15 useScopedSettings: (() => DEFAULT_UNIFIED_SETTINGS) as never,
16 useUpdateScopedSettings: (() => vi.fn()) as never,
17}));
18// The previews mount Ghostty and Shiki, which this test does not exercise.
19vi.mock(import("./SettingsFontPreviews"), () => ({
20 CodeFontPreview: () => <div />,
21 PromptFontPreview: () => <div />,
22 TerminalFontPreview: () => <div />,
23}));
24vi.mock(import("./settingsLayout"), async (original) => ({
25 ...(await original()),
26 useSettingsSearchTargetId: () => state.searchTargetId,
27}));
28
29function setup(searchTargetId: string | null) {
30 state.searchTargetId = searchTargetId;
31 removeLocalStorageItem(TYPOGRAPHY_ADVANCED_STORAGE_KEY);
32 return { [Symbol.dispose]: () => removeLocalStorageItem(TYPOGRAPHY_ADVANCED_STORAGE_KEY) };
33}
34
35describe("TypographySection", () => {
36 it("persists the advanced flag the terminal reads when a deep link targets an advanced row", async () => {
37 using _storage = setup("terminal-font");
38 await using screen = await render(<TypographySection />);
39
40 await expect.element(screen.getByRole("heading", { name: "Terminal font" })).toBeVisible();
41 expect(getLocalStorageItem(TYPOGRAPHY_ADVANCED_STORAGE_KEY, Schema.Boolean)).toBe(true);
42 });
43});