import assert from "node:assert/strict"; import { test } from "node:test"; import type { GiteaPull } from "../client.ts"; // **No poll of the forge for heads** (issue 1422; design 47 H ยง764, H-A-100): the forge's events say a pull request's new // head as pull.updated, a merge and a close; nothing weighs a sibling or asks a merge check. const edited = (base: string) => ({ name: "forge.pull-request.edited", body: { owner: "novox", repo: "hq", number: 7, base, merged: false } }); function deps() { const calls: string[] = []; return { calls, d: { getRepo: async () => ({ r: 1 }), getPull: async () => ({ state: "open", base: "trunk" }) as any, announceUpdated: async () => { calls.push("updated"); }, announceMerge: async () => { calls.push("merge"); }, announceClosed: async () => { calls.push("closed"); }, } }; } test("an edited event announces the head into the base it now has, without a poll", async () => { const { actOn } = await import("../watch.ts"); const { calls, d } = deps(); await actOn(edited("trunk"), d); assert.deepEqual(calls, ["updated"]); }); test("a close without a merge is announced by its event, a merged close is left to the merge event", async () => { const { actOn } = await import("../watch.ts"); const { calls, d } = deps(); await actOn({ name: "forge.pull-request.closed", body: { owner: "novox", repo: "hq", number: 7, merged: false } }, d); assert.deepEqual(calls, ["closed"]); calls.length = 0; await actOn({ name: "forge.pull-request.closed", body: { owner: "novox", repo: "hq", number: 7, merged: true } }, d); assert.deepEqual(calls, []); });