test(web): focus command palette tests on search behavior (#10302)
This commit is contained in:
1 parent
f93aafcc2c
commit
a9fc4dc2b0
2 files changed
+26
-36
No files matched your search
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in new issue
Block a user