Story 26: Establish TDD workflow and quality gates

Add workflow engine with acceptance gates, test recording, and review
queue. Frontend displays gate status (blocked/ready), test summaries,
failing badges, and warnings. Proceed action is disabled when gates
are not met. Includes 13 unit tests (Vitest) and 9 E2E tests
(Playwright) covering all five acceptance criteria.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dave
2026-02-19 12:54:04 +00:00
parent 3a98669c4c
commit 013b28d77f
31 changed files with 3627 additions and 417 deletions

View File

@@ -0,0 +1,101 @@
export type TestStatus = "pass" | "fail";
export interface TestCasePayload {
name: string;
status: TestStatus;
details?: string | null;
}
export interface RecordTestsPayload {
story_id: string;
unit: TestCasePayload[];
integration: TestCasePayload[];
}
export interface AcceptanceRequest {
story_id: string;
}
export interface TestRunSummaryResponse {
total: number;
passed: number;
failed: number;
}
export interface AcceptanceResponse {
can_accept: boolean;
reasons: string[];
warning?: string | null;
summary: TestRunSummaryResponse;
missing_categories: string[];
}
export interface ReviewStory {
story_id: string;
can_accept: boolean;
reasons: string[];
warning?: string | null;
summary: TestRunSummaryResponse;
missing_categories: string[];
}
export interface ReviewListResponse {
stories: ReviewStory[];
}
const DEFAULT_API_BASE = "/api";
function buildApiUrl(path: string, baseUrl = DEFAULT_API_BASE): string {
return `${baseUrl}${path}`;
}
async function requestJson<T>(
path: string,
options: RequestInit = {},
baseUrl = DEFAULT_API_BASE,
): Promise<T> {
const res = await fetch(buildApiUrl(path, baseUrl), {
headers: {
"Content-Type": "application/json",
...(options.headers ?? {}),
},
...options,
});
if (!res.ok) {
const text = await res.text();
throw new Error(text || `Request failed (${res.status})`);
}
return res.json() as Promise<T>;
}
export const workflowApi = {
recordTests(payload: RecordTestsPayload, baseUrl?: string) {
return requestJson<boolean>(
"/workflow/tests/record",
{ method: "POST", body: JSON.stringify(payload) },
baseUrl,
);
},
getAcceptance(payload: AcceptanceRequest, baseUrl?: string) {
return requestJson<AcceptanceResponse>(
"/workflow/acceptance",
{ method: "POST", body: JSON.stringify(payload) },
baseUrl,
);
},
getReviewQueue(baseUrl?: string) {
return requestJson<ReviewListResponse>("/workflow/review", {}, baseUrl);
},
getReviewQueueAll(baseUrl?: string) {
return requestJson<ReviewListResponse>("/workflow/review/all", {}, baseUrl);
},
ensureAcceptance(payload: AcceptanceRequest, baseUrl?: string) {
return requestJson<boolean>(
"/workflow/acceptance/ensure",
{ method: "POST", body: JSON.stringify(payload) },
baseUrl,
);
},
};