import type { Report } from '../src/analyze'; import { renderReport, renderUnsupported } from '../src/render'; const ATTACK = ''; const report: Report = { store: 'zepto', findings: [{ rule: 'preselected_paid_addon', severity: 'warn', amountMinor: 9900, evidence: [ATTACK], message: '₹99.00 add-on was selected by default' }], matches: [{ line: ATTACK, matches: [{ score: 0.7, confirmed: false, seen: { store: 'blinkit', name: ATTACK, brand: null, sizeValue: 1, sizeUnit: 'count', priceMinor: 100, available: true, locationKey: 'a'.repeat(64), seenAt: '2026-10-23T09:00:00Z' } }] }], split: { status: 'optimal', assignment: { 'line-0': 'blinkit' }, storeTotalsMinor: { blinkit: 28500 }, totalMinor: 28500, bestSingleStore: { store: 'blinkit', totalMinor: 28500 }, savingsMinor: 0, unpurchasable: [] }, assumptions: ['Assumption text'], }; it('renders page text as text, never as markup', () => { const root = document.createElement('main'); renderReport(root, report); expect(root.querySelector('img')).toBeNull(); expect(root.textContent).toContain(ATTACK); expect((window as unknown as { pwned?: number }).pwned).toBeUndefined(); }); it('asks the user to confirm low-confidence matches', () => { const root = document.createElement('main'); const confirmed: [number, string][] = []; renderReport(root, report, (i, s) => confirmed.push([i, s])); root.querySelector('button')!.click(); expect(confirmed).toEqual([[0, 'blinkit']]); }); it('says when a page layout is unsupported instead of showing numbers', () => { const root = document.createElement('main'); renderUnsupported(root, 'blinkit', 'cart container missing'); expect(root.textContent).toContain('not supported'); expect(root.textContent).not.toMatch(/₹/); });