Skip to content
TypeScript

test(web): focus command palette tests on search behavior (#10302)

Julius Marmingea9fc4dc2b010
diff --git a/apps/web/src/components/CommandPalette.logic.test.ts b/apps/web/src/components/CommandPalette.logic.test.ts
index 65f18394001..b11d88b764b 100644
--- a/apps/web/src/components/CommandPalette.logic.test.ts
+++ b/apps/web/src/components/CommandPalette.logic.test.ts
@@ -2,46 +2,15 @@ import { describe, expect, it, vi } from "vite-plus/test";
import { EnvironmentId, ProjectId, ProviderInstanceId, ThreadId } from "@t3tools/contracts";
import type { Thread } from "../types";
import {
- browseInputEndPaddingClass,
buildBrowseGroups,
buildThreadActionItems,
enumerateCommandPaletteItems,
filterPinnedBrowseEntries,
filterCommandPaletteGroups,
- normalizeSearchText,
reduceCommandPaletteUiState,
type CommandPaletteGroup,
} from "./CommandPalette.logic";
-describe("browseInputEndPaddingClass", () => {
- it("reserves the widest space for the create action", () => {
- expect(
- browseInputEndPaddingClass({
- willCreateProjectPath: true,
- hasHighlightedBrowseItem: false,
- }),
- ).toContain("pe-38");
- });
-
- it("reserves space for the wider highlighted-item shortcut", () => {
- expect(
- browseInputEndPaddingClass({
- willCreateProjectPath: false,
- hasHighlightedBrowseItem: true,
- }),
- ).toContain("pe-30");
- });
-
- it("keeps the compact reserve for the normal add action", () => {
- expect(
- browseInputEndPaddingClass({
- willCreateProjectPath: false,
- hasHighlightedBrowseItem: false,
- }),
- ).toContain("pe-24");
- });
-});
-
describe("reduceCommandPaletteUiState", () => {
const closedState = { open: false, mode: "command", openIntent: null } as const;
@@ -333,10 +302,33 @@ describe("buildThreadActionItems", () => {
});
it("normalizes case independently of the host locale", () => {
- const localeLowerCase = vi.spyOn(String.prototype, "toLocaleLowerCase").mockReturnValue("gıt");
+ const toLocaleLowerCase = String.prototype.toLocaleLowerCase;
+ const localeLowerCase = vi
+ .spyOn(String.prototype, "toLocaleLowerCase")
+ .mockImplementation(function (this: string) {
+ return toLocaleLowerCase.call(this, "tr");
+ });
try {
- expect(normalizeSearchText("GIT")).toBe("git");
- expect(localeLowerCase).not.toHaveBeenCalled();
+ const groups = filterCommandPaletteGroups({
+ activeGroups: [],
+ query: "GIT",
+ isInSubmenu: false,
+ projectSearchItems: [],
+ threadSearchItems: [],
+ settingsSearchItems: [
+ {
+ kind: "action",
+ value: "setting:version-control",
+ title: "Version control",
+ searchTerms: ["git"],
+ icon: null,
+ run: async () => undefined,
+ },
+ ],
+ });
+ expect(groups.flatMap((group) => group.items.map((item) => item.value))).toEqual([
+ "setting:version-control",
+ ]);
} finally {
localeLowerCase.mockRestore();
}
diff --git a/apps/web/src/components/CommandPalette.logic.ts b/apps/web/src/components/CommandPalette.logic.ts
index a0af1be0450..2492ca0cf98 100644
--- a/apps/web/src/components/CommandPalette.logic.ts
+++ b/apps/web/src/components/CommandPalette.logic.ts
@@ -13,8 +13,6 @@ import { normalizeSearchText } from "../lib/utils";
import { formatRelativeTimeLabel } from "../timestampFormat";
import { type Project, type SidebarThreadSummary, type Thread } from "../types";
-export { normalizeSearchText } from "../lib/utils";
-
export const RECENT_THREAD_LIMIT = 12;
export const ITEM_ICON_CLASS = "size-4 text-icon-muted";
export const ADDON_ICON_CLASS = "size-4";