The best way to control Claude Code, Codex and more from any computer or phone

main
ts 52 lines 1.85 KB
Raw
1 import { describe, expect, it } from "vite-plus/test";
2
3 import * as Schema from "effect/Schema";
4
5 import { EnvironmentId, ProjectId } from "@t3tools/contracts";
6
7 import { issueListPreferences, IssueListPreferencesSchema } from "./issueListPreferences";
8 import { issueViewMatches } from "./issueSavedViews";
9
10 const decodePreferences = Schema.decodeOption(IssueListPreferencesSchema);
11
12 const preferences = {
13 who: "assigned",
14 status: "open",
15 hideProjects: [
16 [EnvironmentId.make("env-1"), ProjectId.make("project-1")],
17 [EnvironmentId.make("env-1"), ProjectId.make("project-2")],
18 ],
19 host: "github.com",
20 q: "crash",
21 label: ["bug", "priority"],
22 assignee: "octocat",
23 order: "created",
24 } as const;
25 const view = { id: "mine", name: "Issues Assigned to Me", preferences };
26
27 describe("saved issue views", () => {
28 it("matches regardless of label order", () => {
29 expect(issueViewMatches(view, { ...preferences, label: ["priority", "bug"], q: "crash" })).toBe(
30 true,
31 );
32 expect(issueViewMatches(view, { ...preferences, assignee: undefined })).toBe(false);
33 expect(issueViewMatches(view, { ...preferences, label: ["bug"] })).toBe(false);
34 expect(
35 issueViewMatches(view, {
36 ...preferences,
37 hideProjects: preferences.hideProjects.toReversed(),
38 }),
39 ).toBe(true);
40 expect(issueViewMatches(view, { ...preferences, hideProjects: undefined })).toBe(false);
41 });
42
43 it("keeps a selection of every project within what it reads back", () => {
44 const many = Array.from(
45 { length: 1_001 },
46 (_, index) => [EnvironmentId.make("env-1"), ProjectId.make(`project-${index}`)] as const,
47 );
48 const stored = issueListPreferences({ ...preferences, hideProjects: many });
49 const restored = decodePreferences(stored);
50 expect(restored._tag === "Some" && restored.value.hideProjects).toEqual(many.slice(0, 1_000));
51 });
52 });