// 复核通过不许再碰 git。 // // 2026-10-26 之前,`baseRef` 非空的 bug(特性验收 / 非默认产品基线)点「通过」会让 // 承载它的卫星把 `bugfix/` merge + push 回基线 —— 一条和 Bits MR 并行的合入 // 路径,而且不经过 code review。这个测试钉死它不会回来:approve 只写状态,任何卫星 // 调用都算回归。 // // 注意任务故意带 `baseRef` + `branchName` + 无工单:这正是以前会触发 merge-back 的 // 形状,同时把 Meego 那一段跳过,让测试不需要任何网络。 import "./setup_env"; import { afterAll, mock, test, expect } from "bun:test"; const task = { id: "merge-free-approve", status: "manual_review", meegoId: null, meegoUrl: null, baseRef: "whee/develop", branchName: "bugfix/no-merge-back", title: "approval must not touch git", }; const patches: Record[] = []; mock.module("../src/db", () => ({ getTask: async () => task, updateTask: async (_id: string, patch: Record) => { patches.push(patch); }, getFeature: async () => null, updateFeature: async () => {}, getSecurity: async () => null, updateSecurity: async () => {}, })); mock.module("../src/meego", () => ({ setMeegoIssueResolved: async () => ({ ok: true }), addMeegoComment: async () => {}, })); mock.module("../src/cluster", () => ({ // 旧的 merge-back 走的就是 proxyToNode;复核通过时任何卫星调用都是回归。 proxyToNode: async () => { throw new Error("复核通过不应调用执行机"); }, satPath: new Proxy({}, { get: () => (...args: unknown[]) => `/sat/${args.join("/")}` }), })); mock.module("../src/bus", () => ({ broadcast: () => {} })); mock.module("../src/enrich", () => ({ enrichTaskLite: async (x: unknown) => x, enrichFeatureLite: async (x: unknown) => x, enrichSecurityLite: async (x: unknown) => x, })); mock.module("../src/notify", () => ({ notifyStatusChange: () => {}, notifyFeatureStatusChange: () => {}, notifySecurityStatusChange: () => {}, })); mock.module("../src/mr_sync", () => ({ syncMrStatusForTask: () => {} })); afterAll(() => { mock.restore(); }); test("baseRef 非空的 bug 复核通过:只写状态,不 merge、不 push", async () => { const { approveBugReview } = await import("../src/review_actions"); const r = await approveBugReview(task.id); expect(r.ok).toBe(true); expect(r.code).toBeUndefined(); expect(patches).toHaveLength(1); expect(patches[0]).toMatchObject({ status: "fix_succeeded", failureReason: null }); // 历史列不再写:新行的合入信号只来自 mr_sync 看到的 Bits MR。 expect(Object.prototype.hasOwnProperty.call(patches[0], "mergedIntoBaseAt")).toBe(false); });