The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { expect, it } from "vite-plus/test"; |
| 2 | import type { PullRequestSavedView } from "../../persistence/mobile-preferences"; |
| 3 | import { pullRequestSavedViewPreferences, pullRequestViewMatches } from "./pullRequestSavedViews"; |
| 4 | |
| 5 | const view = { |
| 6 | id: "review", |
| 7 | name: "Review queue", |
| 8 | environmentId: "remote", |
| 9 | query: "bug", |
| 10 | controls: { |
| 11 | state: "open", |
| 12 | involvement: "reviewing", |
| 13 | filters: { |
| 14 | author: "me", |
| 15 | draft: "hide", |
| 16 | labels: [["bug", "fix"], ["urgent"]], |
| 17 | excludedLabels: ["hold", "later"], |
| 18 | }, |
| 19 | sort: "created", |
| 20 | projectId: "project", |
| 21 | projectEnvironmentId: "remote", |
| 22 | }, |
| 23 | } as const satisfies PullRequestSavedView; |
| 24 | |
| 25 | it("recognizes a saved view regardless of filter property or label ordering", () => { |
| 26 | const controls = { |
| 27 | ...view.controls, |
| 28 | filters: { |
| 29 | excludedLabels: ["later", "hold"], |
| 30 | labels: [["urgent"], ["fix", "bug"]], |
| 31 | draft: "hide", |
| 32 | author: "me", |
| 33 | }, |
| 34 | } as const; |
| 35 | expect(pullRequestViewMatches(view, { ...view, query: " bug ", controls })).toBe(true); |
| 36 | expect(view.controls.filters.labels).toEqual([["bug", "fix"], ["urgent"]]); |
| 37 | expect( |
| 38 | pullRequestViewMatches(view, { |
| 39 | ...view, |
| 40 | controls: { ...view.controls, projectEnvironmentId: "other" }, |
| 41 | }), |
| 42 | ).toBe(false); |
| 43 | }); |
| 44 | |
| 45 | it("applies a view's environment and controls while keeping other environments' controls", () => { |
| 46 | const local = { state: "merged", involvement: "authored", filters: {}, sort: "oldest" } as const; |
| 47 | expect( |
| 48 | pullRequestSavedViewPreferences( |
| 49 | { pullRequestListFilters: { environmentId: "local", controls: { local } } }, |
| 50 | view, |
| 51 | ), |
| 52 | ).toEqual({ |
| 53 | pullRequestListFilters: { |
| 54 | environmentId: "remote", |
| 55 | controls: { local, remote: view.controls }, |
| 56 | }, |
| 57 | }); |
| 58 | }); |