import { containsSensitiveKey, redactSensitive } from '@/lib/demo/redaction';
import { describe, expect, it } from 'vitest';

describe('privacy-safe diagnostics', () => {
  it('redacts nested personal fields', () => {
    expect(
      redactSensitive({
        category: 'validation',
        lead: { workEmail: 'person@example.test', company: 'Example Rentals' },
      }),
    ).toEqual({
      category: 'validation',
      lead: { workEmail: '[REDACTED]', company: '[REDACTED]' },
    });
  });

  it('detects sensitive diagnostic structures', () => {
    expect(containsSensitiveKey({ context: { message: 'private' } })).toBe(true);
    expect(containsSensitiveKey({ category: 'timeout', correlationId: 'abc' })).toBe(false);
  });
});
