Publish curated projectbrain source from 88fab8df1542019289e947f092c2b387e0825c60

This commit is contained in:
Public Source Publisher committed 2026-10-04 15:47:50 +00:00
1 parent 48e72d07e0
commit eca2891b07
45 files changed
+2697 -328

No files matched your search

+29 -6
View File
@@ -107,13 +107,36 @@ describe("Gitea webhook verification", () => {
});
describe("Gitea API client", () => {
it("accepts Gitea's empty HTTP 200 merge response without inventing a failed merge", async () => {
const fetcher = vi.fn(async (input: string | URL | Request) => String(input).endsWith("/version")
? new Response(JSON.stringify({ version: "1.27.3" }), { status: 200 })
: new Response(null, { status: 200 }));
it.each([
["1.14.0", "Do"],
["1.14.7", "Do"],
["1.25.5", "Do"],
["1.26.4", "do"],
["1.27.3", "do"],
["28.0.0", "do"],
["28.1.3", "do"],
] as const)("uses the supported Gitea merge field for %s", async (version, expectedKey) => {
const bodies: Record<string, unknown>[] = [];
const fetcher = vi.fn(async (input: string | URL | Request, init?: RequestInit) => {
if (String(input).endsWith("/version")) return new Response(JSON.stringify({ version }), { status: 200 });
bodies.push(JSON.parse(String(init?.body ?? "{}")) as Record<string, unknown>);
return new Response(null, { status: 200 });
});
const client = new GiteaClient("https://gitea.example.com", "test-token", fetcher as typeof fetch);
await expect(client.mergePullRequest("Owner", "Repo", 7, { method: "merge", headCommitId: "a".repeat(40) })).resolves.toBeUndefined();
expect(fetcher).toHaveBeenCalledTimes(2);
expect(bodies[0]?.[expectedKey]).toBe("merge");
expect(bodies[0]?.[expectedKey === "Do" ? "do" : "Do"]).toBeUndefined();
});
it.each(["1.24.6", "29.0.0", "not-a-version", ""])("fails closed for unsupported Gitea merge version %s", async (version) => {
const fetcher = vi.fn(async (input: string | URL | Request) => String(input).endsWith("/version")
? new Response(JSON.stringify({ version }), { status: 200 })
: new Response(null, { status: 200 }));
const client = new GiteaClient("https://gitea.example.com", "test-token", fetcher as typeof fetch);
await expect(client.mergePullRequest("Owner", "Repo", 7, { method: "merge", headCommitId: "a".repeat(40) }))
.rejects.toMatchObject({ code: "GITEA_VERSION_UNSUPPORTED" });
expect(fetcher).toHaveBeenCalledTimes(1);
});
it("creates a private initialized repository through the bounded user endpoint", async () => {
const fetcher = vi.fn(async () => new Response(JSON.stringify({
@@ -509,11 +532,11 @@ describe("ChatGPT feature delivery approval", () => {
it("requires every Gitea Actions workflow for the exact branch head to succeed", () => {
const run = (id: number, conclusion: string, headSha = "current-sha"): GiteaActionRun => ({
id, run_number: id, display_title: "CI", path: ".gitea/workflows/ci.yml", event: "push", head_sha: headSha,
id, run_number: id, display_title: "Managed validation / full", path: ".gitea/workflows/managed-validation.yml", event: "workflow_dispatch", head_sha: headSha,
head_branch: "chatgpt/feature", status: "completed", conclusion, html_url: `https://gitea.example.com/runs/${id}`,
});
expect(assertSuccessfulActionRuns([run(1, "success"), run(2, "success")], "chatgpt/feature", "current-sha")).toHaveLength(2);
expect(() => assertSuccessfulActionRuns([run(1, "success"), run(2, "failure")], "chatgpt/feature", "current-sha")).toThrow("FEATURE_DELIVERY_CI_NOT_SUCCESSFUL");
expect(() => assertSuccessfulActionRuns([run(1, "success"), run(2, "failure")], "chatgpt/feature", "current-sha")).toThrow("FEATURE_DELIVERY_FULL_VALIDATION_REQUIRED");
expect(() => assertSuccessfulActionRuns([run(1, "success", "stale-sha")], "chatgpt/feature", "current-sha")).toThrow("FEATURE_DELIVERY_CI_NOT_SUCCESSFUL");
});
});