Files
streamline/control-web/test/sidecar_mr_placement.test.ts
T
2026-11-16 17:26:44 -08:00

47 lines
2.4 KiB
TypeScript

import { test, expect, describe } from "bun:test";
import { readFileSync } from "node:fs";
import path from "node:path";
/**
* 附加仓(tt_im_monorepo 等)的 MR 和流水线放在哪、主仓无改动时交付 MR 那一行长什么样。
*
* 生产 ce9bf567:只改了 tt_im_monorepo 的单子,抽屉「产物」区挂着一条 Bits 流水线链接,
* 看上去像子 MR 链接、点进去却是测试流水线;复核清单里交付 MR 那一行又是红色「MR 提交失败」,
* 其实主仓本来就没改动。约定改成:
* 一、附加仓的 MR / 开发任务 / 流水线只在复核清单交付 MR 右边的齿轮「MR 操作」里出现;
* 二、改动只在附加仓时,交付 MR 那一行是灰色「主仓无改动」,点开就是「MR 操作」。
*/
const REPO = path.resolve(import.meta.dir, "../..");
const drawer = readFileSync(path.join(REPO, "control-web/src/components/TaskDetailDrawer.tsx"), "utf8");
describe("附加仓的入口只在齿轮里", () => {
test("「产物」区不再列附加仓 MR / 流水线", () => {
const artifacts = drawer.slice(drawer.indexOf('<h4>{t("drawer.artifacts")}</h4>'), drawer.indexOf("{item.logPath && ("));
expect(artifacts).not.toContain("codeSidecars");
expect(artifacts).not.toContain("pipelines");
});
test("齿轮「MR 操作」里有附加仓那一节和它的流水线", () => {
expect(drawer).toContain('<MrActionSection title={t("drawer.mrActionsSidecarTitle")}>');
expect(drawer).toContain("{sub.peers}");
});
});
describe("主仓无改动", () => {
test("判据走 shared 的 isSidecarOnlyDelivery,且只在还没有交付 MR 时成立", () => {
expect(drawer).toContain("!item.mrUrl && isSidecarOnlyDelivery(item.repoKey, codeSidecars.length)");
});
test("交付 MR 那一行:不当失败分类,点开是「MR 操作」", () => {
expect(drawer).toContain("hasUrl || pipelineOnlyDone || noDeliveryChange ? null : classifyMrFailure(step.failureReason)");
const row = drawer.slice(drawer.indexOf("noDeliveryChange ? ("), drawer.indexOf(") : hasUrl ? ("));
expect(row).toContain("setMrActionsOpen(true)");
expect(row).toContain('t("drawer.mrRowNoChange")');
});
test("gitlab 通道的附加仓不要点的人绑 Bits Token", () => {
expect(drawer).toContain('const needsBitsToken = !(variant === "sub" && step.repo.mrChannel === "gitlab");');
expect(drawer).toContain("needsBitsToken && hasBitsToken !== true ? (");
});
});