peppa/packages/testkit/test/bugs-first.test.ts
Асель 242c5b59e9 PEP-103: bug stories first — the dispatcher takes fixes before features
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:40:34 +05:00

30 lines
2.0 KiB
TypeScript

// PEP-103: the dispatcher takes bug stories first — from production errors or the «Стабильность» epic.
import assert from "node:assert/strict";
import { after, describe, test } from "node:test";
import { sql } from "drizzle-orm";
import { core, db, runner, teardown } from "./helpers.ts";
after(teardown);
describe("PEP-103: bugs first", () => {
test("bug stories come before features, each in board order", async () => {
const p = await core.createProject(db, { slug: "mock-bugs", key: "MBUG", name: "Bugs", giteaOwner: "x", workspacePath: "/tmp/mock-bugs" });
const feature1 = await core.createTask(db, { projectId: p.id, title: "Фича 1" });
const feature2 = await core.createTask(db, { projectId: p.id, title: "Фича 2" });
const stability = await core.createGoal(db, p.id, "Стабильность");
const epicBug = await core.createTask(db, { projectId: p.id, title: "Падает оплата", goalId: stability.id });
const incidentBug = await core.createTask(db, { projectId: p.id, title: "TypeError на главной" });
db.run(sql`insert into incidents (project_id, source, bugsink_issue_id, title, status, task_id, events, first_seen, last_seen, created_at, updated_at) values (${p.id}, 'api', 'mock-issue-1', 'TypeError', 'open', ${incidentBug.task.id}, 1, 0, 0, 0, 0)`);
const order = (await runner.readyBacklog(db, p.id)).map((t) => t.title);
assert.deepEqual(order, ["Падает оплата", "TypeError на главной", "Фича 1", "Фича 2"]);
assert.ok(feature1 && feature2);
});
test("no bugs — the board order is kept", async () => {
const p = await core.createProject(db, { slug: "mock-nobugs", key: "MNOB", name: "No bugs", giteaOwner: "x", workspacePath: "/tmp/mock-nobugs" });
await core.createTask(db, { projectId: p.id, title: "A" });
await core.createTask(db, { projectId: p.id, title: "B" });
assert.deepEqual((await runner.readyBacklog(db, p.id)).map((t) => t.title), ["A", "B"]);
});
});