feat: improve app ui and project metadata
This commit is contained in:
@@ -4,9 +4,12 @@ import type { ForeshadowView } from "@/lib/api/types";
|
||||
import {
|
||||
buildRegisterRequest,
|
||||
buildTransitionRequest,
|
||||
countByStatus,
|
||||
extractReason,
|
||||
groupByStatus,
|
||||
isWindowApproaching,
|
||||
LANE_LABELS,
|
||||
nextFreeForeshadowCode,
|
||||
suggestForeshadowCode,
|
||||
validationReasonMessage,
|
||||
} from "./board";
|
||||
@@ -24,6 +27,24 @@ describe("suggestForeshadowCode", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("nextFreeForeshadowCode", () => {
|
||||
it("keeps the preferred code when it is free", () => {
|
||||
expect(nextFreeForeshadowCode("FS-04", new Set(["FS-01", "FS-02"]))).toBe(
|
||||
"FS-04",
|
||||
);
|
||||
});
|
||||
|
||||
it("skips taken codes and returns the first free FS-NN", () => {
|
||||
const taken = new Set(["FS-01", "FS-02", "FS-03", "FS-05", "FS-OLD"]);
|
||||
// preferred FS-01 已占 → 取首个空闲 FS-04
|
||||
expect(nextFreeForeshadowCode("FS-01", taken)).toBe("FS-04");
|
||||
});
|
||||
|
||||
it("returns FS-01 when nothing is taken", () => {
|
||||
expect(nextFreeForeshadowCode("FS-01", new Set())).toBe("FS-01");
|
||||
});
|
||||
});
|
||||
|
||||
const view = (over: Partial<ForeshadowView>): ForeshadowView => ({
|
||||
code: "F-001",
|
||||
title: "线索",
|
||||
@@ -53,6 +74,32 @@ describe("groupByStatus", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("countByStatus", () => {
|
||||
it("counts items in the same lane model used by the board", () => {
|
||||
expect(
|
||||
countByStatus([
|
||||
view({ status: "OPEN" }),
|
||||
view({ status: "OPEN" }),
|
||||
view({ status: "PARTIAL" }),
|
||||
view({ status: "CLOSED" }),
|
||||
view({ status: "OVERDUE" }),
|
||||
view({ status: "WEIRD" }),
|
||||
]),
|
||||
).toEqual({ OPEN: 3, PARTIAL: 1, CLOSED: 1, OVERDUE: 1 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("LANE_LABELS", () => {
|
||||
it("keeps author-facing labels distinct from status codes", () => {
|
||||
expect(LANE_LABELS).toEqual({
|
||||
OPEN: "待推进",
|
||||
PARTIAL: "推进中",
|
||||
CLOSED: "已回收",
|
||||
OVERDUE: "已逾期",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("isWindowApproaching", () => {
|
||||
it("is true when current chapter is inside [from,to] for OPEN/PARTIAL", () => {
|
||||
const f = view({
|
||||
|
||||
Reference in New Issue
Block a user