Гант: порядок и цвета этапов из khbuild_stages (ord, color_fill, color_stroke), без константы в коде
All checks were successful
ci / test (push) Successful in 24s
ci / deploy (push) Successful in 1m30s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-17 09:11:26 +03:00
parent bfe6b4338b
commit 5cd07f709b
4 changed files with 33 additions and 34 deletions

View File

@@ -143,9 +143,9 @@ 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: "уточнить границы" }] });
const withRef = buildModel("khbuild", { ...base, process: [{ id: "S1", stage: "st_arch" }, { id: "S2", stage: "нет в справочнике" }, { id: "S3" }], stages: [{ id: "st_arch", stage_name: "Архитектура", comment: "уточнить границы", ord: 40, color_fill: "#d4ece3", color_stroke: "#3f9a78" }] });
expect(withRef.rows.map((r) => r.stage)).toEqual(["Архитектура", "нет в справочнике", null]);
expect(withRef.stages).toEqual([{ id: "st_arch", name: "Архитектура", comment: "уточнить границы" }]);
expect(withRef.stages).toEqual([{ id: "st_arch", name: "Архитектура", comment: "уточнить границы", ord: 40, fill: "#d4ece3", stroke: "#3f9a78" }]);
const without = buildModel("khnata", { ...base, process: [{ id: "S1", stage: "Architecture" }] });
expect(without.rows[0]?.stage).toBe("Architecture");
expect(without.stages).toEqual([]);
@@ -341,11 +341,21 @@ describe("Гант: группы, вехи, свёртывание, масшта
expect(narrow).toMatch(/font-weight="600" fill="#[0-9a-f]{6}">Работа<[/]text>/); // не влезло - подпись над полосой
});
it("группы презентации: порядок и цвета фиксированы, заливка сплошная (без штриховки)", () => {
const rows = ["Стройка", "Пермит", "Договоры PreConstruction", "Финансы", "Свой этап", "Спецификации", "Архитектура", "Закупки"].map((s, i) => row({ id: "S-" + i, stage: s, date_constraint: "день " + (10 + i) }));
const m: ProcessModel = { ...model, rows };
it("этапы: порядок и цвета берутся из справочника (ord, color_fill, color_stroke), заливка сплошная (без штриховки)", () => {
const names = ["Стройка", "Пермит", "Договоры PreConstruction", "Финансы", "Свой этап", "Спецификации", "Архитектура", "Закупки"];
const rows = names.map((s, i) => row({ id: "S-" + i, stage: s, date_constraint: "день " + (10 + i) }));
const refs: ProcessModel["stages"] = [
{ id: "Договоры PreConstruction", name: "Договоры PreConstruction", comment: null, ord: 20, fill: "#dde0e6", stroke: "#7a808f" },
{ id: "Пермит", name: "Пермит", comment: null, ord: 30, fill: "#f7d9cc", stroke: "#d8622f" },
{ id: "Архитектура", name: "Архитектура", comment: null, ord: 40, fill: "#d4ece3", stroke: "#3f9a78" },
{ id: "Спецификации", name: "Спецификации", comment: null, ord: 50, fill: "#d3e4ef", stroke: "#3f7ea6" },
{ id: "Финансы", name: "Финансы", comment: null, ord: 60, fill: "#f5e6c8", stroke: "#d4982f" },
{ id: "Закупки", name: "Закупки", comment: null, ord: 80, fill: "#dbe6ee", stroke: "#6f93ab" },
{ id: "Стройка", name: "Стройка", comment: null, ord: 90, fill: "#cfe6da", stroke: "#1f7a52" },
];
const m: ProcessModel = { ...model, rows, stages: refs };
const sc = computeSchedule(m.rows);
expect(stageOrder(m.rows, sc)).toEqual(["Договоры PreConstruction", "Пермит", "Архитектура", "Спецификации", "Финансы", "Закупки", "Стройка", "Свой этап"]);
expect(stageOrder(m.rows, sc, refs)).toEqual(["Договоры PreConstruction", "Пермит", "Архитектура", "Спецификации", "Финансы", "Закупки", "Стройка", "Свой этап"]);
const svg = renderGantt(m, sc, {});
expect(svg).toContain("#7a808f"); // Договоры
expect(svg).toContain("#d8622f"); // Пермит