Files
rust-discovery/tests/browser/safe-reporter.ts
2026-11-13 13:49:11 +01:00

27 lines
1.6 KiB
TypeScript

import type { FullResult, Reporter, TestCase, TestResult, TestStep } from '../../web/node_modules/@playwright/test/reporter';
import { diagnostic } from './diagnostics';
/** Playwright action error call logs can contain locator.fill(password) arguments.
* Never print raw test errors/steps/stdout/stderr, even on a failed login. */
export default class SafeReporter implements Reporter {
private executed = 0;
onBegin() { console.log('Dev/test browser simulation suite. Secret-bearing step/error logs suppressed.'); }
onTestEnd(_test: TestCase, result: TestResult) {
if (result.status !== 'skipped') this.executed++;
console.log(`Browser simulation: ${result.status}.`);
// Extract only repository source line numbers. Assertion text, call logs
// and entered form values (including passwords) remain suppressed.
for (const error of result.errors) {
const match = error.stack?.match(/mvp-actions\.spec\.ts:(\d+):\d+/);
if (match) console.log(`Cloud/root UI failure source_line=${Number(match[1])}`);
}
}
onStepEnd(_test: TestCase, _result: TestResult, step: TestStep) {
if (step.category !== 'test.step') return;
const safe = diagnostic(step.title, step.error, step.location?.line);
if (safe) console.error(safe);
}
onError() { console.error('Browser simulation infrastructure error; details suppressed to protect login secrets.'); }
onEnd(result: FullResult) { console.log(this.executed ? `Browser simulation suite: ${result.status}. No production approval evidence.` : 'No browser test executed (discovery or skipped). No acceptance evidence.'); }
}