diff --git a/httpd-client/index.ts b/httpd-client/index.ts index 83d22854d..5637d5cd4 100644 --- a/httpd-client/index.ts +++ b/httpd-client/index.ts @@ -13,7 +13,7 @@ import type { Policy, Scope, } from "./lib/shared.js"; -import type { Comment, Embed } from "./lib/project/comment.js"; +import type { Comment, Embed, Reaction } from "./lib/project/comment.js"; import type { Commit, CommitBlob, @@ -71,6 +71,7 @@ export type { Policy, Project, Range, + Reaction, Remote, Review, Revision, @@ -121,13 +122,11 @@ const nodeTrackingSchema = array( ); export interface NodeStats { - projects: { count: number }; - users: { count: number }; + repos: { total: number }; } const nodeStatsSchema = object({ - projects: object({ count: number() }), - users: object({ count: number() }), + repos: object({ total: number() }), }) satisfies ZodSchema; export class HttpdClient { diff --git a/httpd-client/lib/project.ts b/httpd-client/lib/project.ts index e4054a55b..2628e58f2 100644 --- a/httpd-client/lib/project.ts +++ b/httpd-client/lib/project.ts @@ -96,7 +96,8 @@ export type Blob = z.infer; const treeEntrySchema = object({ path: string(), name: string(), - kind: union([literal("blob"), literal("tree")]), + oid: string(), + kind: union([literal("blob"), literal("tree"), literal("submodule")]), }); export type TreeEntry = z.infer; diff --git a/httpd-client/lib/project/comment.ts b/httpd-client/lib/project/comment.ts index 56d726001..d5ce83bc1 100644 --- a/httpd-client/lib/project/comment.ts +++ b/httpd-client/lib/project/comment.ts @@ -1,24 +1,25 @@ import type { z } from "zod"; import { array, boolean, number, object, string } from "zod"; -import { codeLocationSchema } from "../shared"; +import { authorSchema, codeLocationSchema } from "../shared"; export type Comment = z.infer; -export type Embed = z.infer["embeds"][0]; +export type Embed = Comment["embeds"][0]; +export type Reaction = Comment["reactions"][0]; export const commentSchema = object({ id: string(), - author: object({ id: string(), alias: string().optional() }), + author: authorSchema, body: string(), edits: array( object({ - author: object({ id: string(), alias: string().optional() }), + author: authorSchema, body: string(), embeds: array(object({ name: string(), content: string() })), timestamp: number(), }), ), embeds: array(object({ name: string(), content: string() })), - reactions: array(object({ emoji: string(), authors: array(string()) })), + reactions: array(object({ emoji: string(), authors: array(authorSchema) })), timestamp: number(), location: codeLocationSchema.nullable().optional(), resolved: boolean(), diff --git a/httpd-client/lib/project/issue.ts b/httpd-client/lib/project/issue.ts index 9ca0fe982..d45a7dfd6 100644 --- a/httpd-client/lib/project/issue.ts +++ b/httpd-client/lib/project/issue.ts @@ -3,6 +3,7 @@ import type { ZodSchema, z } from "zod"; import { array, boolean, literal, object, string, union } from "zod"; import { commentSchema } from "./comment.js"; +import { authorSchema } from "../shared.js"; export type IssueState = | { status: "open" } @@ -18,12 +19,12 @@ const issueStateSchema = union([ export const issueSchema = object({ id: string(), - author: object({ id: string(), alias: string().optional() }), + author: authorSchema, title: string(), state: issueStateSchema, discussion: array(commentSchema), labels: array(string()), - assignees: array(string()), + assignees: array(authorSchema), }); export type Issue = z.infer; diff --git a/httpd-client/lib/project/patch.ts b/httpd-client/lib/project/patch.ts index f9cb0e404..7f41ddf9b 100644 --- a/httpd-client/lib/project/patch.ts +++ b/httpd-client/lib/project/patch.ts @@ -15,13 +15,9 @@ import { tuple, union, } from "zod"; -import { codeLocationSchema } from "../shared.js"; +import { authorSchema } from "../shared.js"; -export type PatchState = - | { status: "draft" } - | { status: "open"; conflicts?: [string, string][] } - | { status: "archived" } - | { status: "merged"; revision: string; commit: string }; +export type PatchState = z.infer; const patchStateSchema = union([ object({ @@ -39,26 +35,21 @@ const patchStateSchema = union([ revision: string(), commit: string(), }), -]) satisfies ZodSchema; +]); -export interface Merge { - author: { id: string; alias?: string }; - revision: string; - commit: string; - timestamp: number; -} +export type Merge = z.infer; const mergeSchema = object({ - author: object({ id: string(), alias: string().optional() }), + author: authorSchema, revision: string(), commit: string(), timestamp: number(), -}) satisfies ZodSchema; +}); export type Verdict = "accept" | "reject"; const reviewSchema = object({ - author: object({ id: string(), alias: string().optional() }), + author: authorSchema, verdict: optional(union([literal("accept"), literal("reject")]).nullable()), comments: array(commentSchema), summary: string().nullable(), @@ -69,11 +60,11 @@ export type Review = z.infer; const revisionSchema = object({ id: string(), - author: object({ id: string(), alias: string().optional() }), + author: authorSchema, description: string(), edits: array( object({ - author: object({ id: string(), alias: string().optional() }), + author: authorSchema, body: string(), embeds: array(object({ name: string(), content: string() })), timestamp: number(), @@ -82,8 +73,7 @@ const revisionSchema = object({ reactions: array( object({ emoji: string(), - location: codeLocationSchema.nullable(), - authors: array(string()), + authors: array(authorSchema), }), ), base: string(), @@ -98,7 +88,7 @@ export type Revision = z.infer; export const patchSchema = object({ id: string(), - author: object({ id: string(), alias: string().optional() }), + author: authorSchema, title: string(), state: patchStateSchema, target: string(), diff --git a/httpd-client/lib/shared.ts b/httpd-client/lib/shared.ts index e8011d5b9..bbc2a73a2 100644 --- a/httpd-client/lib/shared.ts +++ b/httpd-client/lib/shared.ts @@ -70,3 +70,8 @@ export const codeLocationSchema = object({ }); export type CodeLocation = z.infer; + +export const authorSchema = object({ + id: string(), + alias: string().optional(), +}); diff --git a/httpd-client/tests/project.test.ts b/httpd-client/tests/project.test.ts index 996a3f03a..c8479cb08 100644 --- a/httpd-client/tests/project.test.ts +++ b/httpd-client/tests/project.test.ts @@ -182,7 +182,18 @@ describe("project", () => { }, sessionId, ); - await assertIssue(issueId, { assignees: [bobRemote] }, api); + await assertIssue( + issueId, + { + assignees: [ + { + id: "did:key:z6Mkg49NtQR2LyYRDCQFK4w1VVHqhypZSSRo7HsyuN7SV7v5", + alias: "bob", + }, + ], + }, + api, + ); }, ); diff --git a/src/components/Comment.svelte b/src/components/Comment.svelte index 8b01de3e1..e046fd4b9 100644 --- a/src/components/Comment.svelte +++ b/src/components/Comment.svelte @@ -34,7 +34,10 @@ | ((body: string, embeds: Embed[]) => Promise) | undefined = undefined; export let reactOnComment: - | ((nids: string[], reaction: string) => Promise) + | (( + authors: Comment["reactions"][0]["authors"], + reaction: string, + ) => Promise) | undefined = undefined; diff --git a/src/components/ReactionSelector.svelte b/src/components/ReactionSelector.svelte index e21134319..7fb2411b0 100644 --- a/src/components/ReactionSelector.svelte +++ b/src/components/ReactionSelector.svelte @@ -12,7 +12,7 @@ export let reactions: Comment["reactions"] | undefined = undefined; const dispatch = createEventDispatcher<{ - select: { emoji: string; authors: string[] }; + select: Comment["reactions"][0]; }>(); diff --git a/src/components/Reactions.svelte b/src/components/Reactions.svelte index d0d5f68af..34efc518a 100644 --- a/src/components/Reactions.svelte +++ b/src/components/Reactions.svelte @@ -5,7 +5,10 @@ export let reactions: Comment["reactions"]; export let handleReaction: - | ((authors: string[], reaction: string) => Promise) + | (( + authors: Comment["reactions"][0]["authors"], + reaction: string, + ) => Promise) | undefined; diff --git a/src/components/Thread.svelte b/src/components/Thread.svelte index 5cd17d170..a6a8239e5 100644 --- a/src/components/Thread.svelte +++ b/src/components/Thread.svelte @@ -25,7 +25,11 @@ | ((commentId: string, comment: string, embeds: Embed[]) => Promise) | undefined; export let reactOnComment: - | ((commentId: string, nids: string[], reaction: string) => Promise) + | (( + commentId: string, + authors: Comment["reactions"][0]["authors"], + reaction: string, + ) => Promise) | undefined; async function toggleReply() { diff --git a/src/views/projects/Cob/AssigneeInput.svelte b/src/views/projects/Cob/AssigneeInput.svelte index 369745397..f4e89077c 100644 --- a/src/views/projects/Cob/AssigneeInput.svelte +++ b/src/views/projects/Cob/AssigneeInput.svelte @@ -1,4 +1,6 @@ + + + +
+
+ +
+ {name} @ {formatCommit(oid)} +
diff --git a/tests/e2e/project.spec.ts b/tests/e2e/project.spec.ts index c4356fc46..047f37298 100644 --- a/tests/e2e/project.spec.ts +++ b/tests/e2e/project.spec.ts @@ -34,7 +34,7 @@ test("navigate to project", async ({ page }) => { ); await expect( page.getByRole("link", { - name: "Commits 6", + name: "Commits 7", }), ).toBeVisible(); } @@ -54,7 +54,7 @@ test("navigate to project", async ({ page }) => { test("show source tree at specific revision", async ({ page }) => { await page.goto(sourceBrowsingUrl); - await page.getByRole("link", { name: "Commits 6" }).click(); + await page.getByRole("link", { name: "Commits 7" }).click(); await page .locator(".teaser", { hasText: "335dd6d" }) @@ -120,7 +120,7 @@ test("navigate deep file hierarchies", async ({ page }) => { await sourceTree.getByText("entirely").click(); await sourceTree.getByText("possible").click(); await sourceTree.getByText("in").nth(1).click(); - await sourceTree.getByText("git").click(); + await sourceTree.getByRole("button", { name: "git" }).click(); await sourceTree.getByText("repositories").click(); await sourceTree.getByText(".gitkeep").click(); await expect( @@ -151,6 +151,11 @@ test("navigate deep file hierarchies", async ({ page }) => { } }); +test("submodules", async ({ page }) => { + await page.goto(sourceBrowsingUrl); + await expect(page.getByText("rips @ 329dee9")).toBeVisible(); +}); + test("files with special characters in the filename", async ({ page }) => { await page.goto(sourceBrowsingUrl); diff --git a/tests/e2e/project/commit.spec.ts b/tests/e2e/project/commit.spec.ts index 99775d2bc..f0b8822f6 100644 --- a/tests/e2e/project/commit.spec.ts +++ b/tests/e2e/project/commit.spec.ts @@ -13,7 +13,7 @@ test("navigation from commit list", async ({ page }) => { await page.goto(sourceBrowsingUrl); await page.getByTitle("Change peer").click(); await page.getByRole("link", { name: "bob" }).click(); - await page.getByRole("link", { name: "Commits 7" }).click(); + await page.getByRole("link", { name: "Commits 8" }).click(); await page.getByText("Update readme").click(); await expect(page).toHaveURL(commitUrl); @@ -30,7 +30,9 @@ test("relative timestamps", async ({ page }) => { }; }); await page.goto(commitUrl); - await expect(page.getByText("Bob Belcher committed 28f3710")).toBeVisible(); + await expect( + page.getByText(`Bob Belcher committed ${shortBobHead}`), + ).toBeVisible(); }); test("modified file", async ({ page }) => { diff --git a/tests/e2e/project/commits.spec.ts b/tests/e2e/project/commits.spec.ts index f780f85ea..2ba9940d4 100644 --- a/tests/e2e/project/commits.spec.ts +++ b/tests/e2e/project/commits.spec.ts @@ -2,6 +2,7 @@ import { aliceMainHead, expect, gitOptions, + shortBobHead, sourceBrowsingUrl, test, } from "@tests/support/fixtures.js"; @@ -9,7 +10,7 @@ import { createProject } from "@tests/support/project"; test("peer and branch switching", async ({ page }) => { await page.goto(sourceBrowsingUrl); - await page.getByRole("link", { name: "Commits 6" }).click(); + await page.getByRole("link", { name: "Commits 7" }).click(); // Alice's peer. { @@ -23,10 +24,10 @@ test("peer and branch switching", async ({ page }) => { await expect(page.getByTitle("Change peer")).toHaveText("alice Delegate"); await expect(page.getByText("Thursday, November 17, 2022")).toBeVisible(); - await expect(page.locator(".list .teaser")).toHaveCount(6); + await expect(page.locator(".list .teaser")).toHaveCount(7); const latestCommit = page.locator(".teaser").first(); - await expect(latestCommit).toContainText("Add README.md"); + await expect(latestCommit).toContainText("Add submodule"); await expect(latestCommit).toContainText(aliceMainHead.substring(0, 7)); const earliestCommit = page.locator(".teaser").last(); @@ -68,12 +69,12 @@ test("peer and branch switching", async ({ page }) => { await expect(page.getByText("Thursday, November 17, 2022")).toBeVisible(); await expect(page.locator(".list").last().locator(".teaser")).toHaveCount( - 6, + 7, ); const latestCommit = page.locator(".teaser").first(); await expect(latestCommit).toContainText("Update readme"); - await expect(latestCommit).toContainText("28f3710"); + await expect(latestCommit).toContainText(shortBobHead); const earliestCommit = page.locator(".teaser").last(); await expect(earliestCommit).toContainText( @@ -85,7 +86,7 @@ test("peer and branch switching", async ({ page }) => { test("expand commit message", async ({ page }) => { await page.goto(sourceBrowsingUrl); - await page.getByRole("link", { name: "Commits 6" }).click(); + await page.getByRole("link", { name: "Commits 7" }).click(); const commitToggle = page.getByRole("button", { name: "expand" }).first(); await commitToggle.click(); @@ -111,14 +112,16 @@ test("relative timestamps", async ({ page }) => { }); await page.goto(sourceBrowsingUrl); - await page.getByRole("link", { name: "Commits 6" }).click(); + await page.getByRole("link", { name: "Commits 7" }).click(); await page.getByTitle("Change peer").click(); await page.getByRole("link", { name: "bob" }).click(); await expect(page.getByTitle("Change peer")).toHaveText("bob"); const latestCommit = page.locator(".teaser").first(); - await expect(latestCommit).toContainText("Bob Belcher committed 28f3710 now"); - await expect(latestCommit).toContainText("28f3710"); + await expect(latestCommit).toContainText( + `Bob Belcher committed ${shortBobHead} now`, + ); + await expect(latestCommit).toContainText(shortBobHead); const earliestCommit = page.locator(".teaser").last(); await expect(earliestCommit).toContainText( "Alice Liddell committed 36d5bbe last month", diff --git a/tests/e2e/router.ts b/tests/e2e/router.ts index 301e9c436..58b1f1527 100644 --- a/tests/e2e/router.ts +++ b/tests/e2e/router.ts @@ -66,7 +66,7 @@ test.describe("project page navigation", () => { .waitFor({ state: "hidden" }); await expect(page).toHaveURL(projectTreeURL); - await page.getByRole("link", { name: "Commits 6" }).click(); + await page.getByRole("link", { name: "Commits 7" }).click(); await expect(page).toHaveURL( `${sourceBrowsingUrl}/history/${aliceMainHead}`, ); @@ -89,7 +89,7 @@ test.describe("project page navigation", () => { await page.getByText(".hidden").click(); await expect(page).toHaveURL(`${projectTreeURL}/tree/.hidden`); - await page.getByRole("link", { name: "Commits 6" }).click(); + await page.getByRole("link", { name: "Commits 7" }).click(); await expect(page).toHaveURL(`${sourceBrowsingUrl}/history`); }); diff --git a/tests/fixtures/repos/source-browsing.tar.bz2 b/tests/fixtures/repos/source-browsing.tar.bz2 index 9125e508b..5e6eea3f3 100644 Binary files a/tests/fixtures/repos/source-browsing.tar.bz2 and b/tests/fixtures/repos/source-browsing.tar.bz2 differ diff --git a/tests/support/fixtures.ts b/tests/support/fixtures.ts index 02bf560d9..2449e5182 100644 --- a/tests/support/fixtures.ts +++ b/tests/support/fixtures.ts @@ -13,6 +13,7 @@ import { createOptions, supportDir, tmpDir } from "@tests/support/support.js"; import { createPeerManager } from "@tests/support/peerManager.js"; import { createProject } from "@tests/support/project.js"; import type { PeerManager, RadiclePeer } from "./peerManager.js"; +import { formatCommit } from "@app/lib/utils.js"; export { expect }; @@ -652,13 +653,13 @@ export async function createMarkdownFixture(peer: RadiclePeer) { ); } -export const aliceMainHead = "dd068e9aff9a569e597f6abaf84f120dd0cbbd70"; +export const aliceMainHead = "4a9f278344b795afaef44c0d9effb35c4d794fba"; export const aliceRemote = "did:key:z6MkqGC3nWZhYieEVTVDKW5v588CiGfsDSmRVG9ZwwWTvLSK"; export const bobRemote = "did:key:z6Mkg49NtQR2LyYRDCQFK4w1VVHqhypZSSRo7HsyuN7SV7v5"; -export const bobHead = "28f37105bb78db48111e36281291ff253dd050e8"; -export const shortBobHead = "28f3710"; +export const bobHead = "ff32f18dc09d82bff329ffcd96fd5eba2d7f826c"; +export const shortBobHead = formatCommit(bobHead); export const sourceBrowsingRid = "rad:z4BwwjPCFNVP27FwVbDFgwVwkjcir"; export const cobRid = "rad:z3fpY7nttPPa6MBnAv2DccHzQJnqe"; export const markdownRid = "rad:z2tchH2Ti4LxRKdssPQYs6VHE5rsg"; diff --git a/tests/support/heartwood-version b/tests/support/heartwood-version index c835542a0..b817d6f00 100644 --- a/tests/support/heartwood-version +++ b/tests/support/heartwood-version @@ -1 +1 @@ -a48081f2717f069d456ec09f31d9e639b232dbed +570a7eb141b6ba001713c46345d79b6fead1ca15 diff --git a/tests/tmp/.gitkeep b/tests/tmp/.gitkeep deleted file mode 100644 index e69de29bb..000000000