Download extension/test/render.test.ts from Gaurav711/HyperFlow: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/spaces/Gaurav711/HyperFlow/resolve/main/extension/test/render.test.ts
- Command line
-
hf download hf://spaces/Gaurav711/HyperFlow/extension/test/render.test.ts
-
curl -L -o render.test.ts https://huggingface.co/spaces/Gaurav711/HyperFlow/resolve/main/extension/test/render.test.ts
1.81 kB
| import type { Report } from '../src/analyze'; | |
| import { renderReport, renderUnsupported } from '../src/render'; | |
| const ATTACK = '<img src=x onerror="window.pwned=1">'; | |
| 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(/₹/); | |
| }); | |