Skip to content

Commit 21c9918

Browse files
committed
fix: retain complete review data and validate GitHub fixtures
1 parent 2433ea1 commit 21c9918

5 files changed

Lines changed: 67 additions & 54 deletions

File tree

‎apps/mobile/src/features/threads/useThreadHeaderOptions.test.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @vitest-environment jsdom
21
import type { VcsStatusResult } from "@t3tools/contracts";
32
import { act, useEffect } from "react";
43
import { createRoot, type Root } from "react-dom/client";

‎apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,25 @@ describe("review verdicts", () => {
547547
});
548548

549549
describe("pull request timeline", () => {
550+
it("omits bodiless non-verdict reviews from Summary and Timeline while retaining verdicts", () => {
551+
const empty = {
552+
...TIMELINE_SOURCE.comments[0]!,
553+
id: "empty",
554+
kind: "review" as const,
555+
body: "",
556+
reviewState: "COMMENTED",
557+
};
558+
const approval = { ...empty, id: "approval", reviewState: "APPROVED" };
559+
const comments = [empty, approval, TIMELINE_SOURCE.comments[0]!];
560+
expect(pullRequestConversationItems(comments, []).map((item) => item.id)).toEqual([
561+
"approval",
562+
"c1",
563+
]);
564+
expect(
565+
buildPullRequestTimeline({ ...TIMELINE_SOURCE, comments }).map((event) => event.id),
566+
).toEqual(["approval", "c1", "1baf7bdcafe", "created"]);
567+
});
568+
550569
it("keeps open and resolved review conversations together, including thread-only replies", () => {
551570
const root = { ...TIMELINE_SOURCE.comments[0]!, id: "root", path: "src/app.ts" };
552571
const reply = {

‎packages/source-control-github/src/server/GitHubPullRequestApi.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4307,8 +4307,6 @@ layer("GitHubPullRequestApi.layer", (it) => {
43074307
diffSide: "RIGHT",
43084308
startLine: null,
43094309
startDiffSide: null,
4310-
startLine: null,
4311-
startDiffSide: null,
43124310
comments: { nodes: [{ id: "PRRC_1" }] },
43134311
},
43144312
],

‎packages/source-control-github/src/server/GitHubPullRequestApi.ts‎

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,57 +3059,56 @@ export const make = Effect.gen(function* () {
30593059
});
30603060
},
30613061

3062-
uploadAttachment: (input) =>
3063-
Effect.gen(function* () {
3064-
const host = input.host.toLowerCase();
3065-
if (host !== "github.com" && !host.endsWith(".ghe.com"))
3066-
return yield* readError(
3067-
input.cwd,
3068-
"uploadAttachment",
3069-
new Error(
3070-
"Local attachments are supported on GitHub.com and GitHub Enterprise Cloud. Paste a hosted link for this host.",
3071-
),
3072-
);
3073-
const repository = yield* api.rest({
3074-
host,
3075-
operation: "uploadAttachment",
3076-
path: `repos/${input.repository}`,
3077-
});
3078-
const decoded = yield* decodeAttachmentRepository(repository.body).pipe(
3079-
Effect.mapError((cause) => readError(input.cwd, "uploadAttachment", cause)),
3062+
uploadAttachment: Effect.fn("GitHubPullRequestApi.uploadAttachment")(function* (input) {
3063+
const host = input.host.toLowerCase();
3064+
if (host !== "github.com" && !host.endsWith(".ghe.com"))
3065+
return yield* readError(
3066+
input.cwd,
3067+
"uploadAttachment",
3068+
new Error(
3069+
"Local attachments are supported on GitHub.com and GitHub Enterprise Cloud. Paste a hosted link for this host.",
3070+
),
30803071
);
3081-
const result = yield* api.rest({
3082-
host,
3083-
operation: "uploadAttachment",
3084-
method: "POST",
3085-
path: "user-attachments/assets",
3086-
timeout: "2 minutes",
3087-
upload: {
3088-
repositoryId: decoded.id,
3089-
name: input.name,
3090-
mimeType: input.mimeType,
3091-
sizeBytes: input.sizeBytes,
3092-
stream: fileSystem.stream(input.path),
3093-
},
3094-
});
3095-
const asset = yield* decodeAttachmentAsset(result.body).pipe(
3096-
Effect.mapError((cause) => readError(input.cwd, "uploadAttachment", cause)),
3072+
const repository = yield* api.rest({
3073+
host,
3074+
operation: "uploadAttachment",
3075+
path: `repos/${input.repository}`,
3076+
});
3077+
const decoded = yield* decodeAttachmentRepository(repository.body).pipe(
3078+
Effect.mapError((cause) => readError(input.cwd, "uploadAttachment", cause)),
3079+
);
3080+
const result = yield* api.rest({
3081+
host,
3082+
operation: "uploadAttachment",
3083+
method: "POST",
3084+
path: "user-attachments/assets",
3085+
timeout: "2 minutes",
3086+
upload: {
3087+
repositoryId: decoded.id,
3088+
name: input.name,
3089+
mimeType: input.mimeType,
3090+
sizeBytes: input.sizeBytes,
3091+
stream: fileSystem.stream(input.path),
3092+
},
3093+
});
3094+
const asset = yield* decodeAttachmentAsset(result.body).pipe(
3095+
Effect.mapError((cause) => readError(input.cwd, "uploadAttachment", cause)),
3096+
);
3097+
const url = yield* Effect.try({
3098+
try: () => new URL(asset.url),
3099+
catch: (cause) => readError(input.cwd, "uploadAttachment", cause),
3100+
});
3101+
if (
3102+
url.protocol !== "https:" ||
3103+
(url.hostname !== host && url.hostname !== `uploads.${host}`)
3104+
)
3105+
return yield* readError(
3106+
input.cwd,
3107+
"uploadAttachment",
3108+
new Error("GitHub returned an invalid attachment URL."),
30973109
);
3098-
const url = yield* Effect.try({
3099-
try: () => new URL(asset.url),
3100-
catch: (cause) => readError(input.cwd, "uploadAttachment", cause),
3101-
});
3102-
if (
3103-
url.protocol !== "https:" ||
3104-
(url.hostname !== host && url.hostname !== `uploads.${host}`)
3105-
)
3106-
return yield* readError(
3107-
input.cwd,
3108-
"uploadAttachment",
3109-
new Error("GitHub returned an invalid attachment URL."),
3110-
);
3111-
return { url: asset.url };
3112-
}),
3110+
return { url: asset.url };
3111+
}),
31133112

31143113
commentOnPullRequest: (input) =>
31153114
pullRequestNodeId({ ...input, operation: "commentOnPullRequest" }).pipe(

‎packages/source-control-github/src/server/gitHubPullRequestJson.test.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,8 +1587,6 @@ describe("review thread decoding", () => {
15871587
path: "src/a.ts",
15881588
line: 53,
15891589
diffSide: "RIGHT",
1590-
startLine: null,
1591-
startDiffSide: null,
15921590
startLine: 48,
15931591
startDiffSide: "LEFT",
15941592
comments: { totalCount: 1, nodes: [comment("range", "Review these lines")] },

0 commit comments

Comments
 (0)