donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
159 lines • 5.03 kB
TypeScript
/**
* @fileoverview Donobu HTML report renderer.
*
* Pure library that turns a `DonobuReport` (Playwright-JSON superset with
* optional triage data) into a self-contained HTML document. No filesystem
* writes, no CLI arg parsing, no environment variable reads — callers (the
* reporter and the auto-heal orchestrator) own I/O.
*/
import type { DonobuReport } from './model';
interface TreatmentPlanRecord {
generatedAtIso?: string;
plan: {
failureSummary: string;
failureReason: string;
confidence: number;
observedIndicators: string[];
remediationSteps: Array<{
category: string;
summary: string;
details: string;
}>;
additionalDataRequests: Array<{
description: string;
suggestedSources: string[];
}>;
shouldRetryAutomation: boolean;
requiresCodeChange: boolean;
requiresProductFix: boolean;
notes?: string;
automationDirectives?: Record<string, any>;
};
failure: {
testCase: {
title: string;
file?: string;
projectName?: string;
};
runId?: string | null;
runDirectory?: string;
evidencePath?: string;
};
}
interface HistoricalSignals {
flakinessScore: number;
regressionLikelihood: number;
recentPassRate: number;
priorSelfHealSuccess: boolean;
cacheWasRecentlyValid: boolean;
}
interface FlowHistorySummary {
flowName: string;
totalRuns: number;
successCount: number;
failureCount: number;
otherCount: number;
passRate: number;
recentRuns: Array<{
id: string;
state: string;
runMode: string;
startedAt: number | null;
completedAt: number | null;
durationMs: number | null;
}>;
currentStreak: {
state: 'SUCCESS' | 'FAILED' | 'MIXED';
length: number;
};
lastSuccessfulRunId: string | null;
queryWindowDays: number;
queriedAt: string;
}
interface FailureEvidenceRecord {
schemaVersion: number;
evidenceId: string;
runId: string | null;
runDirectory: string;
collectedAtIso: string;
failureScreenshotPath?: string | null;
baselineScreenshotPath?: string | null;
failureContext: {
testCase: {
title: string;
file?: string;
projectName: string;
status: string;
retry: number;
duration: number;
};
failure: {
errors: Array<{
message?: string;
stack?: string;
snippet?: string;
actual?: string;
expected?: string;
location?: string;
}>;
attachments: Array<{
name: string;
contentType: string;
path?: string | null;
}>;
};
donobuFlow: {
metadata: Record<string, any> | null;
recentToolCalls: Array<{
toolName?: string;
name?: string;
outcome?: Record<string, any>;
durationMs?: number;
parameters?: string | null;
[k: string]: any;
}>;
};
testSnippet: string | null;
flowHistory?: FlowHistorySummary | null;
heuristics: {
failureReason: string;
evidence: string[];
confidence: number;
failureSummary: string;
shouldRetryAutomation: boolean;
requiresCodeChange: boolean;
requiresProductFix: boolean;
occurredDuringPageAi: boolean;
staleCacheIndicators: Record<string, boolean>;
historicalSignals?: HistoricalSignals | null;
remediationSteps: Array<{
category: string;
summary: string;
details: string;
}>;
};
};
}
export interface TriageData {
plans: TreatmentPlanRecord[];
evidence: FailureEvidenceRecord[];
}
export declare function loadTriageData(triageDir: string): TriageData;
export declare function renderHtml(report: DonobuReport, triage: TriageData, outputDir: string | null): string;
/**
* Render the tiny redirect HTML that Donobu drops into each Playwright-managed
* per-test directory under `test-results/`. The stub bounces straight to the
* combined report's `#?testId=<id>` deep link — meta-refresh + JS replace +
* visible fallback link, so it works with or without JS, online or `file://`.
*
* Strictly additive: Donobu does not create or rename Playwright's per-test
* directories — the caller in `html.ts` only writes this file into directories
* Playwright already created for the test's attachments.
*/
export declare function renderPerTestStub(params: {
testId: string;
title: string;
relPathToReport: string;
}): string;
export {};
//# sourceMappingURL=render.d.ts.map