The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { filterSettingsSections } from "./settings-search"; |
| 4 | |
| 5 | const SECTIONS = [ |
| 6 | { rows: [{ id: "usage", label: "Usage" }] }, |
| 7 | { |
| 8 | title: "Connections", |
| 9 | rows: [ |
| 10 | { id: "account", label: "T3 Account" }, |
| 11 | { id: "SettingsEnvironments", label: "Environments" }, |
| 12 | ], |
| 13 | }, |
| 14 | { |
| 15 | title: "Interface", |
| 16 | rows: [ |
| 17 | { id: "SettingsAppearance", label: "Appearance" }, |
| 18 | { id: "SettingsKeyboard", label: "Keyboard" }, |
| 19 | { id: "SettingsVoice", label: "Voice" }, |
| 20 | ], |
| 21 | }, |
| 22 | { |
| 23 | title: "Server settings", |
| 24 | rows: [ |
| 25 | { id: "SettingsProviderAccounts", label: "Provider accounts" }, |
| 26 | { id: "SettingsEnvironmentSourceControl", label: "Source control & issues" }, |
| 27 | ], |
| 28 | }, |
| 29 | ]; |
| 30 | |
| 31 | function visible(query: string) { |
| 32 | return filterSettingsSections(SECTIONS, query).map((section) => [ |
| 33 | section.title ?? null, |
| 34 | section.rows.map((row) => row.label), |
| 35 | ]); |
| 36 | } |
| 37 | |
| 38 | describe("filterSettingsSections", () => { |
| 39 | it.each([ |
| 40 | { |
| 41 | query: "", |
| 42 | expected: SECTIONS.map((section) => [ |
| 43 | section.title ?? null, |
| 44 | section.rows.map((row) => row.label), |
| 45 | ]), |
| 46 | }, |
| 47 | { query: " ", expected: visible("") }, |
| 48 | { query: "appear", expected: [["Interface", ["Appearance"]]] }, |
| 49 | { query: "KEYBOARD", expected: [["Interface", ["Keyboard"]]] }, |
| 50 | { query: "dark mode", expected: [["Interface", ["Appearance"]]] }, |
| 51 | { query: "microphone", expected: [["Interface", ["Voice"]]] }, |
| 52 | { query: "agent credits", expected: [["Server settings", ["Source control & issues"]]] }, |
| 53 | { |
| 54 | query: "server settings", |
| 55 | expected: [["Server settings", ["Provider accounts", "Source control & issues"]]], |
| 56 | }, |
| 57 | { |
| 58 | query: "accounts", |
| 59 | expected: [["Server settings", ["Provider accounts"]]], |
| 60 | }, |
| 61 | { query: "usage", expected: [[null, ["Usage"]]] }, |
| 62 | { query: "zzzz", expected: [] }, |
| 63 | ])("$query", ({ query, expected }) => { |
| 64 | expect(visible(query)).toEqual(expected); |
| 65 | }); |
| 66 | |
| 67 | it("drops sections that start empty", () => { |
| 68 | expect(filterSettingsSections([{ rows: [] }, ...SECTIONS], "").length).toBe(SECTIONS.length); |
| 69 | }); |
| 70 | }); |