Гант: групповая полоса прерывается там, где нет активностей; справочник этапов (stages) в модели
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -138,6 +138,30 @@ describe("справочник ответственных", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("справочник этапов", () => {
|
||||
it("название этапа берётся из справочника, без справочника остаётся значение колонки stage", () => {
|
||||
const base = { refs: [], legacyRoles: false, systems: [], data: [] };
|
||||
const withRef = buildModel("khbuild", { ...base, process: [{ id: "S1", stage: "st_arch" }, { id: "S2", stage: "нет в справочнике" }, { id: "S3" }], stages: [{ id: "st_arch", stage_name: "Архитектура", comment: "уточнить границы" }] });
|
||||
expect(withRef.rows.map((r) => r.stage)).toEqual(["Архитектура", "нет в справочнике", null]);
|
||||
expect(withRef.stages).toEqual([{ id: "st_arch", name: "Архитектура", comment: "уточнить границы" }]);
|
||||
const without = buildModel("khnata", { ...base, process: [{ id: "S1", stage: "Architecture" }] });
|
||||
expect(without.rows[0]?.stage).toBe("Architecture");
|
||||
expect(without.stages).toEqual([]);
|
||||
});
|
||||
it("loadModel: нет таблицы stages (42P01) - читается без справочника", async () => {
|
||||
const db = {
|
||||
query: async (sql: string) => {
|
||||
if (sql.includes("_stages")) throw Object.assign(new Error("relation does not exist"), { code: "42P01" });
|
||||
if (sql.includes("_process")) return { rows: [{ id: "S1", stage: "A" }] };
|
||||
return { rows: [] };
|
||||
},
|
||||
};
|
||||
const m = await loadModel(db as never, "khbuild");
|
||||
expect(m.rows[0]?.stage).toBe("A");
|
||||
expect(m.stages).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("computeSchedule", () => {
|
||||
it("берёт срок из ограничения, остальное выводит по зависимостям", () => {
|
||||
const rows = [
|
||||
@@ -175,6 +199,7 @@ describe("computeSchedule", () => {
|
||||
|
||||
const model: ProcessModel = {
|
||||
set: "khbuild",
|
||||
stages: [],
|
||||
responsible: [
|
||||
{ id: "architect", role: "architect", person: "RIOS", comment: null },
|
||||
{ id: "pm", role: "pm", person: "PM", comment: "кто именно?" },
|
||||
@@ -242,6 +267,30 @@ describe("Гант: группы, вехи, свёртывание, масшта
|
||||
expect(g.milestones.map((m) => [m.row.id, m.day])).toEqual([["CP-0", 0], ["X-9", 30]]);
|
||||
});
|
||||
|
||||
it("групповая полоса прерывается там, где в группе нет активностей, и продолжается дальше", () => {
|
||||
const rows = [
|
||||
row({ id: "A", date_constraint: "день 0 → день 10" }),
|
||||
row({ id: "B", date_constraint: "день 5 → день 12" }), // перекрывается с A: отрезки объединяются
|
||||
row({ id: "C", date_constraint: "день 30 → день 40" }), // после паузы
|
||||
row({ id: "M", date_constraint: "день 20", is_milestone: true }), // веха в паузе: ромб есть, полосы нет
|
||||
];
|
||||
const s2 = computeSchedule(rows);
|
||||
const g = summarizeGroup("G", rows.map((r) => ({ row: r, t: s2.timings.get(r.id)! })));
|
||||
expect(g.segments).toEqual([[0, 12], [30, 40]]);
|
||||
expect([g.start, g.end]).toEqual([0, 40]);
|
||||
expect(g.milestones.map((m) => m.row.id)).toEqual(["M"]);
|
||||
const svg = renderGantt({ ...model, rows: rows.map((r) => ({ ...r, stage: "G" })) }, s2, {});
|
||||
// два прямоугольника сводной полосы (две высоты 14 с заливкой цвета группы) вместо одного
|
||||
expect(svg.match(/height="14" rx="2"/g)).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("группа только из вех или без работ с длительностью рисуется одним сплошным отрезком", () => {
|
||||
const rows = [row({ id: "M1", date_constraint: "день 7", is_milestone: true }), row({ id: "M2", date_constraint: "день 75", is_milestone: true })];
|
||||
const s2 = computeSchedule(rows);
|
||||
const g = summarizeGroup("G", rows.map((r) => ({ row: r, t: s2.timings.get(r.id)! })));
|
||||
expect(g.segments).toEqual([[7, 75]]);
|
||||
});
|
||||
|
||||
it("повторяющиеся шаги и шаги без срока не растягивают группу", () => {
|
||||
const rows = [row({ id: "R", date_constraint: "еженедельно" }), row({ id: "Q", date_constraint: "день 10 → день 20" }), row({ id: "Z" })];
|
||||
const s2 = computeSchedule(rows);
|
||||
|
||||
Reference in New Issue
Block a user