The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { DEFAULT_UNIFIED_SETTINGS } from "@t3tools/contracts/settings"; |
| 2 | import * as Schema from "effect/Schema"; |
| 3 | import { describe, expect, it, vi } from "vite-plus/test"; |
| 4 | |
| 5 | import "~/index.css"; |
| 6 | import { render } from "../../../test/render"; |
| 7 | import { TYPOGRAPHY_ADVANCED_STORAGE_KEY } from "../../appearanceFonts"; |
| 8 | import { getLocalStorageItem, removeLocalStorageItem } from "../../hooks/useLocalStorage"; |
| 9 | import { TypographySection } from "./TypographySettings"; |
| 10 | |
| 11 | const state = vi.hoisted(() => ({ searchTargetId: null as string | null })); |
| 12 | |
| 13 | vi.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. |
| 19 | vi.mock(import("./SettingsFontPreviews"), () => ({ |
| 20 | CodeFontPreview: () => <div />, |
| 21 | PromptFontPreview: () => <div />, |
| 22 | TerminalFontPreview: () => <div />, |
| 23 | })); |
| 24 | vi.mock(import("./settingsLayout"), async (original) => ({ |
| 25 | ...(await original()), |
| 26 | useSettingsSearchTargetId: () => state.searchTargetId, |
| 27 | })); |
| 28 | |
| 29 | function 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 | |
| 35 | describe("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 | }); |