Initial import of streamline
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import "./setup_env";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { isDonePhase, parseBoardPhase } from "../src/board_phase";
|
||||
import { bucketOf } from "../../control-web/src/lib/board";
|
||||
import type { BoardItem } from "../../control-web/src/types";
|
||||
|
||||
// The `done` phase is only safe if everything in it lands in one of the board's
|
||||
// finished buckets — a row served only in the second pass must never belong to a
|
||||
// tab the first paint has to get right.
|
||||
const FINISHED = new Set(["merged", "archived", "evaluate_finish"]);
|
||||
|
||||
const BUG_STATUSES = ["initializing", "info_required", "pending_confirmation", "awaiting_fix", "fixing", "manual_review", "fix_succeeded", "fix_failed", "unreproducible", "archived", "cancelled", "evaluate_finish"];
|
||||
const FEATURE_STATUSES = ["initializing", "info_required", "pending_confirmation", "awaiting_implementation", "implementing", "manual_review", "completed", "implementation_failed", "archived", "cancelled"];
|
||||
const SECURITY_STATUSES = ["initializing", "info_required", "awaiting_security", "security_running", "manual_review", "completed", "unreproducible", "security_failed", "cancelled", "archived"];
|
||||
const MR_VARIANTS: Array<{ mergedIntoBaseAt: number | null; mrState: string | null; meegoState: string | null }> = [
|
||||
{ mergedIntoBaseAt: null, mrState: null, meegoState: null },
|
||||
{ mergedIntoBaseAt: 1_700_000_000_000, mrState: null, meegoState: null },
|
||||
{ mergedIntoBaseAt: null, mrState: "merged", meegoState: "open" },
|
||||
{ mergedIntoBaseAt: null, mrState: "Merging", meegoState: null },
|
||||
{ mergedIntoBaseAt: null, mrState: "opened", meegoState: "resolved" },
|
||||
{ mergedIntoBaseAt: null, mrState: "closed", meegoState: "closed" },
|
||||
{ mergedIntoBaseAt: null, mrState: "merged", meegoState: "REOPENED" },
|
||||
{ mergedIntoBaseAt: 1_700_000_000_000, mrState: null, meegoState: "reopened" },
|
||||
];
|
||||
|
||||
describe("board phase split", () => {
|
||||
test("parseBoardPhase accepts only the two phases", () => {
|
||||
expect(parseBoardPhase("active")).toBe("active");
|
||||
expect(parseBoardPhase("done")).toBe("done");
|
||||
expect(parseBoardPhase(undefined)).toBeNull();
|
||||
expect(parseBoardPhase("all")).toBeNull();
|
||||
});
|
||||
|
||||
for (const [kind, statuses] of [["bug", BUG_STATUSES], ["feature", FEATURE_STATUSES], ["security", SECURITY_STATUSES]] as const) {
|
||||
test(`${kind}: every done row is in a finished bucket`, () => {
|
||||
for (const status of statuses) for (const v of MR_VARIANTS) {
|
||||
const item = { kind, status, ...v } as unknown as BoardItem;
|
||||
if (isDonePhase(kind, { status, ...v })) {
|
||||
const bucket = bucketOf(item);
|
||||
// Carry the case in the message so a failure names the offending row.
|
||||
expect(FINISHED.has(bucket) ? "finished" : `${status} ${JSON.stringify(v)} → ${bucket}`).toBe("finished");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
test("the expected sets (bug fix_succeeded only with a merge signal; cancelled stays active)", () => {
|
||||
expect(isDonePhase("bug", { status: "archived" })).toBe(true);
|
||||
expect(isDonePhase("bug", { status: "evaluate_finish" })).toBe(true);
|
||||
expect(isDonePhase("bug", { status: "cancelled" })).toBe(false);
|
||||
expect(isDonePhase("bug", { status: "fix_succeeded" })).toBe(false);
|
||||
expect(isDonePhase("bug", { status: "fix_succeeded", mergedIntoBaseAt: 5 })).toBe(true);
|
||||
expect(isDonePhase("bug", { status: "fix_succeeded", mrState: "MERGED" })).toBe(true);
|
||||
expect(isDonePhase("bug", { status: "fix_succeeded", mrState: "opened" })).toBe(false);
|
||||
expect(isDonePhase("feature", { status: "completed" })).toBe(true);
|
||||
expect(isDonePhase("feature", { status: "archived" })).toBe(true);
|
||||
expect(isDonePhase("feature", { status: "cancelled" })).toBe(false);
|
||||
expect(isDonePhase("security", { status: "completed" })).toBe(true);
|
||||
expect(isDonePhase("security", { status: "cancelled" })).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user