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 @@
11 import { beforeEach, describe, expect, it } from "vite-plus/test";
2+import { ProjectId } from "@t3tools/contracts";
23
3−import { type PendingReviewComment, usePullRequestReviewStore } from "./pullRequestReviewStore";
4+import {
5+ type PendingReviewComment,
6+ pullRequestReviewKey,
7+ usePullRequestReviewStore,
8+} from "./pullRequestReviewStore";
49
510 function comment(id: string, body = id): PendingReviewComment {
611 return { id, body, path: "src/app.ts", position: { kind: "added", newLine: 1 } };
@@ -36,6 +41,30 @@ describe("pull request review drafts", () => { · 29 unmodified lines
3641 });
3742 });
3843
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+
3968 it("does not clear a summary revised while submission is in flight", () => {
4069 const store = usePullRequestReviewStore.getState();
4170 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