Repository navigation
Expand file tree
/
Copy pathPullRequestGuideTab.browser.test.tsx
More file actions
76 lines (68 loc) · 2.52 KB
/
Copy pathPullRequestGuideTab.browser.test.tsx
File metadata and controls
76 lines (68 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { EnvironmentId, ProjectId, type PullRequestRef } from "@t3tools/contracts";
import { expect, it, vi } from "vite-plus/test";
import { userEvent } from "vite-plus/test/browser";
vi.mock(import("./guide/useReviewGuideWriter"), () => ({ useReviewGuideWriter: vi.fn() }));
import { render } from "../../../test/render";
import { useReviewGuideWriter } from "./guide/useReviewGuideWriter";
import { PullRequestGuideTab } from "./PullRequestGuideTab";
const reference: PullRequestRef = {
projectId: ProjectId.make("project"),
repository: "owner/repo",
number: 1,
};
const verboseFailure = [
"Codex CLI command failed: OpenAI Codex v0.164.0",
...Array.from({ length: 200 }, (_, line) => `prompt line ${line}: read the change in order`),
"ERROR: provider auth command `sh` timed out after 5000 ms",
].join("\n");
it("keeps Try again inside a short panel when a failed guide has long diagnostics", async () => {
const write = vi.fn(async () => {});
vi.mocked(useReviewGuideWriter).mockReturnValue({
query: { isPending: false, error: null } as never,
data: {
guide: null,
run: {
_tag: "Failed",
headSha: "head",
failedAt: "2026-10-27T16:37:47.661Z",
detail: verboseFailure,
},
currentHeadSha: "head",
},
running: false,
canWrite: true,
write,
});
const panel = document.createElement("div");
panel.style.cssText = "position: relative; width: 480px; height: 360px; overflow: hidden";
const tab = document.createElement("div");
tab.style.cssText = "position: absolute; inset: 0";
panel.append(tab);
document.body.append(panel);
using _panel = { [Symbol.dispose]: () => panel.remove() };
await using screen = await render(
<PullRequestGuideTab
environmentId={EnvironmentId.make("environment")}
reference={reference}
title="Test pull request"
workspaceRoot="/workspace"
active
canComment={false}
rangeComments={false}
completionScope={null}
onAskAboutLines={null}
onAskAboutStop={null}
onFinishReview={null}
onOpenFile={() => {}}
/>,
{ container: tab },
);
const retry = screen.getByRole("button", { name: "Try again" });
await expect.element(retry).toBeVisible();
const panelBox = panel.getBoundingClientRect();
const retryBox = retry.element().getBoundingClientRect();
expect(retryBox.top).toBeGreaterThanOrEqual(panelBox.top);
expect(retryBox.bottom).toBeLessThanOrEqual(panelBox.bottom);
await userEvent.click(retry);
expect(write).toHaveBeenCalledOnce();
});