43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { shouldShowNotice } from '../src/content/notice';
|
|
import type { PageStatus, ScanResult } from '../src/shared/types';
|
|
|
|
function resultWithStatus(status: PageStatus): ScanResult {
|
|
return {
|
|
scanId: 'scan',
|
|
pageUrl: 'https://example.com/',
|
|
pageTitle: 'Example',
|
|
scannedAt: new Date(0).toISOString(),
|
|
summary: {
|
|
status,
|
|
inspectedImages: 0,
|
|
totalImages: 0,
|
|
inspectedTextBlocks: 0,
|
|
totalTextBlocks: 0,
|
|
aiItems: 0,
|
|
invalidItems: 0,
|
|
disclosedItems: 0,
|
|
inaccessibleItems: 0,
|
|
heuristicScore: status === 'heuristic-suspected' ? 7 : 0,
|
|
heuristicFindings: status === 'heuristic-suspected' ? 3 : 0
|
|
},
|
|
page: { id: 'page', kind: 'page', label: 'Example', verdict: 'unknown', strength: 'none', evidence: [] },
|
|
images: [],
|
|
texts: [],
|
|
warnings: []
|
|
};
|
|
}
|
|
|
|
describe('in-page result visibility', () => {
|
|
it('shows meaningful heuristic and provenance results', () => {
|
|
expect(shouldShowNotice(resultWithStatus('heuristic-suspected'))).toBe(true);
|
|
expect(shouldShowNotice(resultWithStatus('verified-ai'))).toBe(true);
|
|
expect(shouldShowNotice(resultWithStatus('invalid-credential'))).toBe(true);
|
|
});
|
|
|
|
it('stays silent on unknown or inaccessible pages', () => {
|
|
expect(shouldShowNotice(resultWithStatus('no-supported-evidence'))).toBe(false);
|
|
expect(shouldShowNotice(resultWithStatus('unable-to-inspect'))).toBe(false);
|
|
});
|
|
});
|