39 lines
2.8 KiB
TypeScript
39 lines
2.8 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
import RelayDialog from "../src/components/RelayDialog";
|
|
import EddyExportPanel from "../src/components/EddyExportPanel";
|
|
import type { BoardItem, Feature } from "../src/types";
|
|
|
|
test("Android relay keeps its Markdown download and never renders Eddy", () => {
|
|
const item = { id: "fixture", kind: "feature", platform: "android" } as BoardItem & { kind: "feature" };
|
|
const html = renderToStaticMarkup(<RelayDialog item={item} onClose={() => {}} />);
|
|
expect(html).toContain("Claude Code / Cursor");
|
|
expect(html).not.toContain("Eddy");
|
|
expect(renderToStaticMarkup(<EddyExportPanel feature={item as Feature} />)).toBe("");
|
|
});
|
|
test("iOS feature relay offers both Markdown and Eddy", () => {
|
|
const item = { id: "fixture", kind: "feature", platform: "ios", status: "manual_review", branchName: "feature/example", mrUrl: "https://mr.invalid/1", repoKey: "tiktok-ios" } as BoardItem & { kind: "feature" };
|
|
const html = renderToStaticMarkup(<RelayDialog item={item} onClose={() => {}} />);
|
|
expect(html).toContain("Claude Code / Cursor");
|
|
expect(html).toContain("Eddy");
|
|
});
|
|
|
|
test("the Eddy panel says which satellite runs the export and why it is still queued", async () => {
|
|
const { exportNodeNotes } = await import("../src/components/EddyExportPanel");
|
|
const job = { id: "e", featureId: "f", commit: "a".repeat(40), branch: "feature/x", phase: "queued", createdAt: 0, updatedAt: 0,
|
|
expiresAt: null, error: null, result: null, nodeId: "fei-ios-02.shiro0.icu" } as const;
|
|
const node = (patch: object) => ({ id: "fei-ios-02.shiro0.icu", platform: "ios", status: "online", live: true, lastSeenAt: 0,
|
|
evalInFlight: 0, evalCapacity: 3, fixInFlight: 0, fixCapacity: 1, baseUrl: "", createdAt: 0, ...patch }) as any;
|
|
const home = { executorNodeId: "fei-ios-02.shiro0.icu" };
|
|
expect(exportNodeNotes(job, home, [node({})], true)).toEqual(["等待 fei-ios-02 领取,通常几秒内开始。"]);
|
|
expect(exportNodeNotes(job, home, [node({ fixInFlight: 1 })], true)[0]).toContain("正在执行其他工作");
|
|
expect(exportNodeNotes(job, home, [node({ live: false })], true)[0]).toContain("已离线");
|
|
expect(exportNodeNotes(job, home, [], true)).toEqual([]); // fleet not loaded yet: no guess
|
|
const moved = exportNodeNotes(job, { executorNodeId: "fei-ios-01.shiro0.icu" }, [node({ fixInFlight: 1 })], true);
|
|
expect(moved[0]).toBe("执行卫星机 fei-ios-01 离线,已改派到 fei-ios-02,所以接力文档里没有修复报告。");
|
|
expect(moved).toHaveLength(2);
|
|
expect(exportNodeNotes({ ...job, phase: "building" }, home, [node({ fixInFlight: 1 })], true)).toEqual([]);
|
|
expect(exportNodeNotes({ ...job, phase: "failed" }, { executorNodeId: "other" }, [], true)).toEqual([]);
|
|
expect(exportNodeNotes(job, home, [node({ fixInFlight: 1 })], false)[0]).toContain("is busy");
|
|
});
|