The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { EnvironmentId, type ThreadPullRequestLink } from "@t3tools/contracts"; |
| 2 | import { expect, it, vi } from "vite-plus/test"; |
| 3 | |
| 4 | import { render } from "../../test/render"; |
| 5 | import { AppAtomRegistryProvider } from "../rpc/atomRegistry"; |
| 6 | import { makeThreadFixture } from "../test-fixtures"; |
| 7 | import { ThreadRowLeadingStatus } from "./ThreadStatusIndicators"; |
| 8 | |
| 9 | const environmentId = EnvironmentId.make("environment-test"); |
| 10 | |
| 11 | vi.mock(import("../state/entities"), async (original) => ({ |
| 12 | ...(await original()), |
| 13 | useProject: () => null, |
| 14 | useServerConfigs: (() => |
| 15 | new Map([ |
| 16 | [environmentId, { environment: { capabilities: { threadPullRequests: true } } }], |
| 17 | ])) as never, |
| 18 | })); |
| 19 | |
| 20 | it("updates palette PR status from linked snapshots without a legacy link or branch PR", async () => { |
| 21 | const link: ThreadPullRequestLink = { |
| 22 | host: "github.com", |
| 23 | repository: "example/repo", |
| 24 | number: 7, |
| 25 | url: "https://github.com/example/repo/pull/7", |
| 26 | source: "manual", |
| 27 | linkedAt: "2026-01-01T00:00:00Z", |
| 28 | stack: null, |
| 29 | snapshot: { |
| 30 | state: "merged", |
| 31 | title: "Linked change", |
| 32 | headBranch: "deleted-branch", |
| 33 | baseBranch: "main", |
| 34 | isDraft: false, |
| 35 | updatedAt: null, |
| 36 | syncedAt: "2026-01-03T00:00:00Z", |
| 37 | }, |
| 38 | }; |
| 39 | const row = (pullRequest: ThreadPullRequestLink) => ( |
| 40 | <AppAtomRegistryProvider> |
| 41 | <ThreadRowLeadingStatus |
| 42 | thread={makeThreadFixture({ |
| 43 | environmentId, |
| 44 | linkedPullRequest: null, |
| 45 | branchPullRequest: null, |
| 46 | pullRequests: [pullRequest], |
| 47 | })} |
| 48 | /> |
| 49 | </AppAtomRegistryProvider> |
| 50 | ); |
| 51 | await using screen = await render(row(link)); |
| 52 | await expect.element(screen.getByLabelText("PR #7 - Merged: Linked change")).toBeVisible(); |
| 53 | await expect.element(screen.getByLabelText("PR #7, status pending")).not.toBeInTheDocument(); |
| 54 | |
| 55 | await screen.rerender(row({ ...link, snapshot: null })); |
| 56 | await expect.element(screen.getByLabelText("PR #7, status pending")).toBeVisible(); |
| 57 | await expect |
| 58 | .element(screen.getByLabelText("PR #7 - Merged: Linked change")) |
| 59 | .not.toBeInTheDocument(); |
| 60 | |
| 61 | await screen.rerender( |
| 62 | row({ ...link, snapshot: { ...link.snapshot!, state: "open", isDraft: true } }), |
| 63 | ); |
| 64 | await expect.element(screen.getByLabelText("PR #7 - Draft: Linked change")).toBeVisible(); |
| 65 | await expect.element(screen.getByLabelText("PR #7, status pending")).not.toBeInTheDocument(); |
| 66 | }); |