History

feat(pull-requests): link multiple pull requests to threads (#10839)

Julius Marminge committed 2 months ago

Commit afb84891 parent 383cc40172 files · +12057 −908Browse files

Showing the changes to apps/web/src/components/pullRequest/pullRequestReviewStore.test.ts (1 of 172 files). Show all

Unified · Split

apps/web/src/components/pullRequest/pullRequestReviewStore.test.ts+30−1
@@ -1,6 +1,11 @@
1import { beforeEach, describe, expect, it } from "vite-plus/test";1import { beforeEach, describe, expect, it } from "vite-plus/test";
2import { ProjectId } from "@t3tools/contracts";
2 3
3import { type PendingReviewComment, usePullRequestReviewStore } from "./pullRequestReviewStore";4import {
5 type PendingReviewComment,
6 pullRequestReviewKey,
7 usePullRequestReviewStore,
8} from "./pullRequestReviewStore";
4 9
5function comment(id: string, body = id): PendingReviewComment {10function comment(id: string, body = id): PendingReviewComment {
6 return { id, body, path: "src/app.ts", position: { kind: "added", newLine: 1 } };11 return { id, body, path: "src/app.ts", position: { kind: "added", newLine: 1 } };
@@ -36,6 +41,30 @@ describe("pull request review drafts", () => { · 29 unmodified lines
36 });41 });
37 });42 });
38 43
44 it("keeps drafts on different hosts separate when a thread reviews the same repository and number", () => {
45 const reference = {
46 projectId: ProjectId.make("project-a"),
47 repository: "owner/repo",
48 number: 7,
49 };
50 const publicKey = pullRequestReviewKey({ ...reference, host: "github.com" });
51 const enterpriseKey = pullRequestReviewKey({ ...reference, host: "github.example.com" });
52 const store = usePullRequestReviewStore.getState();
53 store.addComment(publicKey, comment("public"));
54 store.setSummary(publicKey, "Public review");
55
56 expect(usePullRequestReviewStore.getState().drafts[enterpriseKey]).toBeUndefined();
57 expect(usePullRequestReviewStore.getState().summaries[enterpriseKey]).toBeUndefined();
58
59 store.addComment(enterpriseKey, comment("enterprise"));
60 store.setSummary(enterpriseKey, "Enterprise review");
61 store.clear(enterpriseKey);
62 store.clearSummary(enterpriseKey, "Enterprise review");
63
64 expect(usePullRequestReviewStore.getState().drafts[publicKey]).toEqual([comment("public")]);
65 expect(usePullRequestReviewStore.getState().summaries[publicKey]).toBe("Public review");
66 });
67
39 it("does not clear a summary revised while submission is in flight", () => {68 it("does not clear a summary revised while submission is in flight", () => {
40 const store = usePullRequestReviewStore.getState();69 const store = usePullRequestReviewStore.getState();
41 store.setSummary("review-a", "Submitted body");70 store.setSummary("review-a", "Submitted body");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t