Skip to content

Commit 504a9f6

Browse files
committed
test(web): keep one PR cache transition regression
1 parent 0cb0896 commit 504a9f6

3 files changed

Lines changed: 24 additions & 337 deletions

File tree

‎apps/web/src/components/pullRequest/PullRequestDetailPanel.test.tsx‎

Lines changed: 3 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import {
44
ThreadId,
55
type ScopedThreadRef,
66
type PullRequestDetailView,
7-
type PullRequestSummary,
8-
type PullRequestListEntry,
97
type ThreadPullRequestLink,
108
} from "@t3tools/contracts";
119
import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
@@ -47,13 +45,13 @@ vi.mock("~/state/pullRequests", async (importOriginal) => ({
4745
...(await importOriginal<typeof import("~/state/pullRequests")>()),
4846
pullRequestEnvironment: { detail: () => "detail", activity: () => "activity" },
4947
usePullRequestTurnRefresh: () => 0,
50-
useSharedPullRequestSummary: () => observedSummary,
48+
useSharedPullRequestSummary: () => null,
5149
}));
5250
vi.mock("~/state/vcs", () => ({ vcsEnvironment: { listRefs: () => null } }));
5351
vi.mock("~/state/query", () => ({
5452
useEnvironmentQuery: (query: string) => ({
55-
data: query === "detail" ? loadedDetail : null,
56-
isPending: query === "detail" && loadedDetail === null,
53+
data: query === "detail" ? detail : null,
54+
isPending: false,
5755
isSuccess: true,
5856
error: null,
5957
refresh,
@@ -205,12 +203,8 @@ const threadRef: ScopedThreadRef = {
205203
const draftId = DraftId.make("draft-1");
206204
const newDraftId = DraftId.make("new-draft");
207205
let renderer: ReactTestRenderer;
208-
let loadedDetail: PullRequestDetailView | null = detail;
209-
let observedSummary: PullRequestSummary | null = null;
210206

211207
beforeEach(() => {
212-
loadedDetail = detail;
213-
observedSummary = null;
214208
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
215209
vi.stubGlobal("window", { addEventListener: vi.fn(), removeEventListener: vi.fn() });
216210
useComposerDraftStore.setState({ draftsByThreadKey: {} });
@@ -342,147 +336,3 @@ describe.each([
342336
}
343337
});
344338
});
345-
346-
describe("PR list status in the sidebar detail", () => {
347-
const panel = (listEntry: PullRequestListEntry | null = null) => (
348-
<PullRequestDetailPanel
349-
environmentId={threadRef.environmentId}
350-
reference={detail}
351-
listEntry={listEntry}
352-
shortcutsEnabled={false}
353-
getShortcutContext={() => ({
354-
terminalFocus: false,
355-
terminalOpen: false,
356-
previewFocus: false,
357-
previewOpen: false,
358-
isWeb: true,
359-
isDesktop: false,
360-
})}
361-
/>
362-
);
363-
364-
it("uses newer check status without stale counts, then restores refreshed check details", async () => {
365-
loadedDetail = {
366-
...detail,
367-
mergeability: "mergeable",
368-
autoMergeEnabled: false,
369-
mergeCapabilities: { merge: true, squash: false, rebase: false },
370-
capabilities: {
371-
...detail.capabilities,
372-
actions: ["merge", "enable-auto-merge"],
373-
mergeMethods: ["merge"],
374-
},
375-
viewerPermissions: { ...detail.viewerPermissions, actions: ["merge", "enable-auto-merge"] },
376-
};
377-
await act(async () => {
378-
renderer = create(panel());
379-
});
380-
const text = () =>
381-
renderer.root
382-
.findAllByType("span")
383-
.map((node) => node.children.filter((child) => typeof child === "string").join(""));
384-
expect(text()).toContain("All checks passed");
385-
386-
observedSummary = { ...loadedDetail, checksState: "failing" };
387-
await act(async () => {
388-
renderer.update(panel());
389-
});
390-
expect(text()).toContain("Some checks were not successful");
391-
expect(
392-
renderer.root
393-
.findAllByType("button")
394-
.some((node) => node.props["aria-label"] === "Auto-merge (merge)"),
395-
).toBe(true);
396-
expect(text()).not.toContain("All checks passed");
397-
398-
observedSummary = { ...loadedDetail, checksState: null };
399-
await act(async () => {
400-
renderer.update(panel());
401-
});
402-
expect(text()).toContain("No checks reported");
403-
404-
loadedDetail = {
405-
...loadedDetail,
406-
checks: [
407-
{
408-
name: "Workflow",
409-
status: "action-required",
410-
description: null,
411-
url: "https://github.com/owner/repo/actions/runs/42",
412-
},
413-
],
414-
};
415-
observedSummary = null;
416-
await act(async () => {
417-
renderer.update(panel());
418-
});
419-
expect(text().some((value) => value.includes("awaiting approval"))).toBe(true);
420-
expect(text()).not.toContain("Some checks were not successful");
421-
422-
observedSummary = { ...loadedDetail, checksState: "passing" };
423-
await act(async () => {
424-
renderer.update(panel());
425-
});
426-
expect(text()).toContain("1 workflow awaiting approval");
427-
});
428-
429-
it("shows the known title and conflict before full detail arrives", async () => {
430-
loadedDetail = null;
431-
observedSummary = detail;
432-
await act(async () => {
433-
renderer = create(panel());
434-
});
435-
expect(
436-
renderer.root.findAll((node) => node.children.includes("Conflicts with main")),
437-
).toHaveLength(1);
438-
expect(renderer.root.findAll((node) => node.children.includes(detail.title))).toHaveLength(1);
439-
});
440-
441-
it("keeps the list conflict when the shared summary omits mergeability", async () => {
442-
loadedDetail = null;
443-
observedSummary = { ...detail, mergeability: undefined, isDraft: undefined };
444-
const row = { ...detail, host: "github.com", viewerReviewRequested: false };
445-
await act(async () => {
446-
renderer = create(panel(row));
447-
});
448-
expect(
449-
renderer.root.findAll((node) => node.children.includes("Conflicts with main")),
450-
).toHaveLength(1);
451-
});
452-
453-
it("uses the list conflict while an older detail snapshot is displayed", async () => {
454-
loadedDetail = { ...detail, mergeability: "mergeable", additions: 17, deletions: 3 };
455-
await act(async () => {
456-
renderer = create(panel());
457-
});
458-
expect(
459-
renderer.root.findAll((node) => node.children.includes("Resolve conflicts")),
460-
).toHaveLength(0);
461-
462-
loadedDetail = null;
463-
observedSummary = {
464-
provider: detail.provider,
465-
projectId: detail.projectId,
466-
repository: detail.repository,
467-
number: detail.number,
468-
title: detail.title,
469-
url: detail.url,
470-
state: detail.state,
471-
headBranch: detail.headBranch,
472-
baseBranch: detail.baseBranch,
473-
updatedAt: detail.updatedAt,
474-
mergeability: "conflicting",
475-
};
476-
await act(async () => {
477-
renderer.update(panel());
478-
});
479-
expect(
480-
renderer.root.findAll((node) => node.children.includes("Resolve conflicts")).length,
481-
).toBeGreaterThan(0);
482-
const displayedCounts = renderer.root
483-
.findAllByType("span")
484-
.map((node) => node.children.join(""));
485-
expect(displayedCounts).toContain("+17");
486-
expect(displayedCounts).toContain("-3");
487-
});
488-
});

‎apps/web/src/components/pullRequest/PullRequestSummaryTab.test.tsx‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,14 @@ afterEach(() => {
7676
vi.unstubAllGlobals();
7777
});
7878

79-
function render(value = detail, checksStale = false) {
79+
function render(value = detail) {
8080
return (
8181
<PullRequestSummaryTab
8282
environmentId={EnvironmentId.make("environment")}
8383
threadRef={null}
8484
reference={value}
8585
detail={value}
8686
activityPending={false}
87-
checksStale={checksStale}
8887
activityError={null}
8988
onRefresh={() => {}}
9089
/>
@@ -213,17 +212,3 @@ it("opens bot reports in pages without hiding human comments", () => {
213212
renderer.root.findAllByType("p").some((p) => p.children.join("").startsWith("Bot report")),
214213
).toBe(false);
215214
});
216-
217-
it("withholds outdated check runs until their details catch up", () => {
218-
act(() => {
219-
renderer = create(render(detail, true));
220-
});
221-
click("Checks");
222-
const visibleText = () =>
223-
renderer.root.findAllByType("span").map((node) => node.children.join(""));
224-
expect(visibleText()).toContain("Check details are out of date.");
225-
expect(visibleText()).not.toContain("Unit tests");
226-
act(() => renderer.update(render(detail)));
227-
expect(visibleText()).toContain("Unit tests");
228-
expect(visibleText()).not.toContain("Check details are out of date.");
229-
});

0 commit comments

Comments
 (0)