|
4 | 4 | ThreadId, |
5 | 5 | type ScopedThreadRef, |
6 | 6 | type PullRequestDetailView, |
7 | | - type PullRequestSummary, |
8 | | - type PullRequestListEntry, |
9 | 7 | type ThreadPullRequestLink, |
10 | 8 | } from "@t3tools/contracts"; |
11 | 9 | import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings"; |
@@ -47,13 +45,13 @@ vi.mock("~/state/pullRequests", async (importOriginal) => ({ |
47 | 45 | ...(await importOriginal<typeof import("~/state/pullRequests")>()), |
48 | 46 | pullRequestEnvironment: { detail: () => "detail", activity: () => "activity" }, |
49 | 47 | usePullRequestTurnRefresh: () => 0, |
50 | | - useSharedPullRequestSummary: () => observedSummary, |
| 48 | + useSharedPullRequestSummary: () => null, |
51 | 49 | })); |
52 | 50 | vi.mock("~/state/vcs", () => ({ vcsEnvironment: { listRefs: () => null } })); |
53 | 51 | vi.mock("~/state/query", () => ({ |
54 | 52 | useEnvironmentQuery: (query: string) => ({ |
55 | | - data: query === "detail" ? loadedDetail : null, |
56 | | - isPending: query === "detail" && loadedDetail === null, |
| 53 | + data: query === "detail" ? detail : null, |
| 54 | + isPending: false, |
57 | 55 | isSuccess: true, |
58 | 56 | error: null, |
59 | 57 | refresh, |
@@ -205,12 +203,8 @@ const threadRef: ScopedThreadRef = { |
205 | 203 | const draftId = DraftId.make("draft-1"); |
206 | 204 | const newDraftId = DraftId.make("new-draft"); |
207 | 205 | let renderer: ReactTestRenderer; |
208 | | -let loadedDetail: PullRequestDetailView | null = detail; |
209 | | -let observedSummary: PullRequestSummary | null = null; |
210 | 206 |
|
211 | 207 | beforeEach(() => { |
212 | | - loadedDetail = detail; |
213 | | - observedSummary = null; |
214 | 208 | vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true); |
215 | 209 | vi.stubGlobal("window", { addEventListener: vi.fn(), removeEventListener: vi.fn() }); |
216 | 210 | useComposerDraftStore.setState({ draftsByThreadKey: {} }); |
@@ -342,147 +336,3 @@ describe.each([ |
342 | 336 | } |
343 | 337 | }); |
344 | 338 | }); |
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 | | -}); |
0 commit comments