Close scratch iteration 008 and enforce full surface audits

This commit is contained in:
master
2026-03-13 11:00:12 +02:00
parent fe35801cc5
commit c9a30331ce
11 changed files with 534 additions and 32 deletions

View File

@@ -435,6 +435,54 @@ async function verifySurfaceActions(context, surface) {
return results;
}
function collectSurfaceIssues(surface, record) {
const issues = [];
if (!record.headingMatched) {
issues.push(`heading-mismatch:${surface.key}:${record.headingText || '<empty>'}`);
}
for (const problemText of record.problemTexts) {
issues.push(`problem-text:${surface.key}:${problemText}`);
}
for (const errorText of record.consoleErrors) {
issues.push(`console:${surface.key}:${errorText}`);
}
for (const errorText of record.pageErrors) {
issues.push(`pageerror:${surface.key}:${errorText}`);
}
for (const failure of record.requestFailures) {
issues.push(`requestfailed:${surface.key}:${failure.method} ${failure.url} ${failure.error}`);
}
for (const failure of record.responseErrors) {
issues.push(`response:${surface.key}:${failure.status} ${failure.method} ${failure.url}`);
}
if (surface.searchQuery) {
if (!record.search?.available) {
issues.push(`search-unavailable:${surface.key}`);
} else if (
!record.search.resultsVisible
&& record.search.suggestionCount === 0
&& (record.search.resultsText || '').length === 0
) {
issues.push(`search-empty:${surface.key}:${surface.searchQuery}`);
}
}
for (const actionResult of record.actions) {
if (!actionResult.ok) {
issues.push(`action-failed:${surface.key}:${actionResult.key}:${actionResult.reason ?? actionResult.finalUrl ?? 'unknown'}`);
}
}
return issues;
}
async function main() {
mkdirSync(outputDirectory, { recursive: true });
const authReport = await authenticateFrontdoor({
@@ -452,17 +500,27 @@ async function main() {
generatedAtUtc: new Date().toISOString(),
baseUrl,
surfaces: [],
issues: [],
};
for (const surface of surfaceConfigs) {
const surfaceReport = await inspectSurface(context, surface);
surfaceReport.actions = await verifySurfaceActions(context, surface);
surfaceReport.issues = collectSurfaceIssues(surface, surfaceReport);
surfaceReport.ok = surfaceReport.issues.length === 0;
report.surfaces.push(surfaceReport);
report.issues.push(...surfaceReport.issues);
}
await browser.close();
report.failedSurfaceCount = report.surfaces.filter((surface) => !surface.ok).length;
report.runtimeIssueCount = report.issues.length;
writeFileSync(outputPath, `${JSON.stringify(report, null, 2)}\n`, 'utf8');
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
if (report.failedSurfaceCount > 0 || report.runtimeIssueCount > 0) {
process.exit(1);
}
}
if (process.argv[1] && path.resolve(process.argv[1]) === __filename) {