Update patch review schemas

To address changes to patch code review,
implemented in Heartwood in commit 45e87a6.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-07-11 13:59:23 +02:00
parent 145169d03d
commit 9294e23ea4
3 changed files with 11 additions and 42 deletions
+8 -39
View File
@@ -52,51 +52,21 @@ const mergeSchema = object({
timestamp: number(),
}) satisfies ZodSchema<Merge>;
interface CodeLocation {
path: string;
commit: string;
lines: {
start: number;
end: number;
};
}
const codeLocationSchema = object({
path: string(),
commit: string(),
lines: object({
start: number(),
end: number(),
}),
}) satisfies ZodSchema<CodeLocation>;
interface CodeComment {
location: CodeLocation;
comment: string;
timestamp: number;
}
const codeCommentSchema = object({
location: codeLocationSchema,
comment: string(),
timestamp: number(),
}) satisfies ZodSchema<CodeComment>;
type Verdict = "accept" | "reject";
export interface Review {
author: { id: string; alias?: string };
verdict?: Verdict | null;
comment?: string | null;
inline: CodeComment[];
summary: string | null;
comments: string[];
timestamp: number;
}
const reviewSchema = object({
author: object({ id: string(), alias: string().optional() }),
verdict: optional(union([literal("accept"), literal("reject")]).nullable()),
comment: optional(string().nullable()),
inline: array(codeCommentSchema),
comments: array(string()),
summary: string().nullable(),
timestamp: number(),
}) satisfies ZodSchema<Review>;
@@ -151,19 +121,18 @@ export const patchSchema = object({
export const patchesSchema = array(patchSchema) satisfies ZodSchema<Patch[]>;
export type PatchUpdateAction =
| { type: "edit"; title: string; description: string; target: string }
| { type: "edit"; title: string; target: string }
| { type: "editRevision"; revision: string; description: string }
| { type: "editReview"; review: string; summary?: string }
| { type: "tag"; add: string[]; remove: string[] }
| { type: "revision"; description: string; base: string; oid: string }
| { type: "lifecycle"; state: PatchState }
| { type: "redact"; revision: string }
| {
type: "review";
author: { id: string; alias?: string };
revision: string;
verdict?: Verdict;
comment?: string;
inline: CodeComment;
summary?: string;
verdict?: Verdict | null;
}
| { type: "merge"; revision: string; commit: string }
| { type: "thread"; revision: string; action: ThreadUpdateAction };
+2 -2
View File
@@ -372,7 +372,7 @@
</div>
{:else if element.type === "review"}
{@const [author, review] = element.inner}
{#if review.comment}
{#if review.summary}
<div
class="action"
class:comment-review={review.verdict === null}
@@ -389,7 +389,7 @@
baseUrl,
projectHead,
)}
body={review.comment} />
body={review.summary} />
</div>
{:else}
<div
+1 -1
View File
@@ -52,7 +52,7 @@ test("use revision selector", async ({ page }) => {
).toHaveText("Add more text");
// Switching to the initial revision
await page.getByText("Revision 2592b1e").click();
await page.getByText("Revision 779ce78").click();
await expect(page.locator(".dropdown")).toBeVisible();
await page.getByRole("link", { name: "Revision 0f3697f" }).click();
await expect(page.locator(".dropdown")).toBeHidden();