mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-07 00:44:49 +00:00
* refactor(forge): forge-neutral foundation (GitHub-only) Decouple git-hosting from GitHub behind a neutral abstraction (issue #1616), GitHub-only for now; existing GitHub behaviour is unchanged. - Forge manifest, neutral ForgeService contract, forge registry + resolver, and a client forge-module registry. - GitHub code renamed to the neutral shape; PR/Issue attachment wording preserved. - forge.search.response enums parse tolerantly (unknown kind/auth state degrade instead of breaking the client). - createPullRequest reports typed CLI/auth errors instead of a generic message. - forge-resolver host/remote caches are LRU-bounded. - Forge host trust is explicit: only a known cloud host or a CLI-authenticated host is ever talked to; an unauthenticated GitHub Enterprise host fails resolution instead of routing to github.com. - Docs: forge-providers guide, glossary and i18n forge-copy conventions, architecture and rpc-namespacing terminology. - Vitest React Native mocks (unistyles, svg, linking, lucide) consolidated into shared aliased test-stubs. * feat(forge): GitLab adapter, forge-aware UI, pipelines and approvals GitLab adapter over the glab CLI on the neutral contracts: MR status, forge-aware UI, pipeline tree, and N-of-M approvals. - threadIsResolved is part of the neutral timeline item. - Pipeline load failures show an error instead of an empty section. - Manual pipeline jobs render as pending. - Fork/detached MR head pipelines are fetched by MR iid (glab ci get --merge-request). * feat(forge): Gitea family adapter (Gitea, Forgejo, Codeberg) One adapter over the tea CLI serving Gitea, Forgejo, and Codeberg on the neutral contracts. - CI status aggregates commit statuses and Actions runs together. - Gitea's terminal "warning" state maps to failure on server and client. - Gitea Actions check details are reachable from the PR pane by workflowRunId. * refactor(forge): localize compatibility handling * test(forge): expect normalized GitLab facts --------- Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
154 lines
4.8 KiB
TypeScript
154 lines
4.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
collapseActivity,
|
|
expandActivity,
|
|
getActivityState,
|
|
getCollapsedEntryIds,
|
|
getVisibleEntries,
|
|
} from "./activity-state";
|
|
import type { PrTimelineEntry } from "./timeline";
|
|
import type { PrPaneActivity } from "./data";
|
|
|
|
function activity(id: string, overrides: Partial<PrPaneActivity> = {}): PrPaneActivity {
|
|
return {
|
|
id,
|
|
provider: "github",
|
|
kind: "comment",
|
|
author: "octocat",
|
|
avatarColor: "#0ea5e9",
|
|
body: "Looks good.",
|
|
age: "3d ago",
|
|
url: `https://github.com/getpaseo/paseo/pull/42#${id}`,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
function singleEntry(id: string, resolved = false, outdated = false): PrTimelineEntry {
|
|
return {
|
|
kind: "single",
|
|
id,
|
|
activity: activity(id, {
|
|
location:
|
|
resolved || outdated
|
|
? { path: "a.ts", line: 1, isResolved: resolved, isOutdated: outdated }
|
|
: undefined,
|
|
}),
|
|
};
|
|
}
|
|
|
|
function threadEntry(id: string, resolved = false, outdated = false): PrTimelineEntry {
|
|
return {
|
|
kind: "thread",
|
|
id: `thread:${id}`,
|
|
location: { path: "a.ts", line: 1, isResolved: resolved, isOutdated: outdated },
|
|
isResolved: resolved,
|
|
comments: [activity(id)],
|
|
};
|
|
}
|
|
|
|
function reviewEntry(id: string, threads: PrTimelineEntry[]): PrTimelineEntry {
|
|
return {
|
|
kind: "review",
|
|
id,
|
|
review: activity(id, { kind: "review", reviewState: "commented" }),
|
|
threads: threads.filter((entry) => entry.kind === "thread"),
|
|
};
|
|
}
|
|
|
|
describe("pull request activity state", () => {
|
|
it("collapses and expands activity by PR-scoped stable key", () => {
|
|
const collapsed = collapseActivity(getActivityState(), {
|
|
prNumber: 42,
|
|
activityId: "comment-1",
|
|
});
|
|
|
|
expect(collapsed.collapsedKeys).toEqual(["42:comment-1"]);
|
|
expect(expandActivity(collapsed, { prNumber: 42, activityId: "comment-1" })).toEqual({
|
|
collapsedKeys: [],
|
|
expandedKeys: ["42:comment-1"],
|
|
});
|
|
});
|
|
|
|
it("collapses resolved and outdated entries by default", () => {
|
|
const entries = [
|
|
singleEntry("normal"),
|
|
singleEntry("resolved", true),
|
|
singleEntry("outdated", false, true),
|
|
threadEntry("thread-normal"),
|
|
threadEntry("thread-resolved", true),
|
|
threadEntry("thread-outdated", false, true),
|
|
];
|
|
|
|
const visible = getVisibleEntries(getActivityState(), { prNumber: 42, entries });
|
|
|
|
expect(visible.map((v) => ({ id: v.entry.id, collapsed: v.collapsed }))).toEqual([
|
|
{ id: "normal", collapsed: false },
|
|
{ id: "resolved", collapsed: true },
|
|
{ id: "outdated", collapsed: true },
|
|
{ id: "thread:thread-normal", collapsed: false },
|
|
{ id: "thread:thread-resolved", collapsed: true },
|
|
{ id: "thread:thread-outdated", collapsed: true },
|
|
]);
|
|
});
|
|
|
|
it("collapses a resolved general thread that carries no location", () => {
|
|
const entries: PrTimelineEntry[] = [
|
|
{ kind: "thread", id: "thread:general", isResolved: true, comments: [activity("g1")] },
|
|
];
|
|
|
|
const visible = getVisibleEntries(getActivityState(), { prNumber: 42, entries });
|
|
|
|
expect(visible.map((v) => ({ id: v.entry.id, collapsed: v.collapsed }))).toEqual([
|
|
{ id: "thread:general", collapsed: true },
|
|
]);
|
|
});
|
|
|
|
it("lets user expand a default-collapsed entry", () => {
|
|
const entries = [threadEntry("resolved", true)];
|
|
const expanded = expandActivity(getActivityState(), {
|
|
prNumber: 42,
|
|
activityId: "thread:resolved",
|
|
});
|
|
|
|
const visible = getVisibleEntries(expanded, { prNumber: 42, entries });
|
|
expect(visible[0].collapsed).toBe(false);
|
|
});
|
|
|
|
it("lets user collapse a default-expanded entry", () => {
|
|
const entries = [threadEntry("normal")];
|
|
const collapsed = collapseActivity(getActivityState(), {
|
|
prNumber: 42,
|
|
activityId: "thread:normal",
|
|
});
|
|
|
|
const visible = getVisibleEntries(collapsed, { prNumber: 42, entries });
|
|
expect(visible[0].collapsed).toBe(true);
|
|
});
|
|
|
|
it("includes default-collapsed nested review threads in collapsed IDs", () => {
|
|
const entries = [
|
|
reviewEntry("review", [
|
|
threadEntry("thread-normal"),
|
|
threadEntry("thread-resolved", true),
|
|
threadEntry("thread-outdated", false, true),
|
|
]),
|
|
];
|
|
|
|
const collapsedIds = getCollapsedEntryIds(getActivityState(), { prNumber: 42, entries });
|
|
|
|
expect([...collapsedIds].sort()).toEqual(["thread:thread-outdated", "thread:thread-resolved"]);
|
|
});
|
|
|
|
it("lets user expand a default-collapsed nested review thread", () => {
|
|
const entries = [reviewEntry("review", [threadEntry("thread-resolved", true)])];
|
|
const expanded = expandActivity(getActivityState(), {
|
|
prNumber: 42,
|
|
activityId: "thread:thread-resolved",
|
|
});
|
|
|
|
const collapsedIds = getCollapsedEntryIds(expanded, { prNumber: 42, entries });
|
|
|
|
expect(collapsedIds.has("thread:thread-resolved")).toBe(false);
|
|
});
|
|
});
|