import { describe, expect, it } from 'vitest'; import { diagnostic } from '../../tests/browser/diagnostics'; describe('privacy-safe browser diagnostics', () => { it('only emits fixed labels, allowlisted exception names and numeric source lines', () => { const secret = 'SECRET_CANARY_password_token_host_payload'; const safe = diagnostic('management:native-hint', { name: secret, message: `expect(locator).toBeVisible() ${secret} https://secret.invalid` }, 24); expect(safe).toBe('failure_step=management:native-hint exception=Error kind=assertion source_line=24'); expect(safe).not.toContain(secret); expect(safe).not.toContain('https://'); expect(diagnostic(secret, { name: 'Error', message: secret }, 42)).toBeNull(); expect(diagnostic('management:login-banner', { name: 'TimeoutError', message: `Timeout ${secret}` }, NaN)).toBe('failure_step=management:login-banner exception=TimeoutError kind=timeout source_line=unknown'); expect(diagnostic('management:logout', undefined, 1)).toBeNull(); }); });