Fix MVP audit evidence pipeline
This commit is contained in:
@@ -225,8 +225,8 @@ test("audits.getDetail returns audit + lead context with null-safe lead lookup",
|
||||
);
|
||||
hasPattern(
|
||||
getDetailSource,
|
||||
/return\s*{\s*audit,\s*lead\s*}/,
|
||||
"getDetail should return { audit, lead }.",
|
||||
/return\s*{[\s\S]*audit,[\s\S]*lead,[\s\S]*sourceSummaries:[\s\S]*}/,
|
||||
"getDetail should return audit, lead, and sourceSummaries.",
|
||||
);
|
||||
hasPattern(
|
||||
sourceFile.getFullText(),
|
||||
@@ -234,3 +234,48 @@ test("audits.getDetail returns audit + lead context with null-safe lead lookup",
|
||||
"audits.ts should export a getDetail query.",
|
||||
);
|
||||
});
|
||||
|
||||
test("audits.getDetail joins compact checked-page evidence from latest successful enrichment", () => {
|
||||
const getDetailSource = extractExportSource("getDetail");
|
||||
|
||||
hasPattern(
|
||||
getDetailSource,
|
||||
/query\("agentRuns"\)[\s\S]*withIndex\("by_type_and_status_and_leadId"[\s\S]*eq\("type",\s*"website_enrichment"\)[\s\S]*eq\("status",\s*"succeeded"\)[\s\S]*eq\("leadId",\s*audit\.leadId\)[\s\S]*order\("desc"\)[\s\S]*take\(1\)/,
|
||||
"getDetail should locate the latest successful website_enrichment run for the audit lead.",
|
||||
);
|
||||
|
||||
for (const table of [
|
||||
"websiteCrawlPages",
|
||||
"websiteTechnicalChecks",
|
||||
"websiteCrawlScreenshots",
|
||||
]) {
|
||||
hasPattern(
|
||||
getDetailSource,
|
||||
new RegExp(
|
||||
`query\\("${table}"\\)[\\s\\S]*withIndex\\("by_runId"[\\s\\S]*eq\\("runId",\\s*enrichmentRunId\\)[\\s\\S]*take\\(DETAIL_EVIDENCE_LIMIT\\)`,
|
||||
),
|
||||
`${table} should be loaded from the bounded enrichment run evidence window.`,
|
||||
);
|
||||
}
|
||||
|
||||
hasPattern(
|
||||
getDetailSource,
|
||||
/audit\.checkedPages\.map\(/,
|
||||
"getDetail should preserve audit.checkedPages as the canonical display order.",
|
||||
);
|
||||
hasPattern(
|
||||
getDetailSource,
|
||||
/fallbackCheckedPageEvidence/,
|
||||
"getDetail should return checked-page fallback rows when enrichment evidence is missing.",
|
||||
);
|
||||
hasPattern(
|
||||
getDetailSource,
|
||||
/ctx\.storage\.getUrl\(screenshot\.storageId\)/,
|
||||
"getDetail should resolve screenshot storage ids to display URLs.",
|
||||
);
|
||||
hasPattern(
|
||||
getDetailSource,
|
||||
/sourceSummaries:\s*{\s*checkedPages/,
|
||||
"getDetail should expose checked page summaries under sourceSummaries.checkedPages.",
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user