This commit is contained in:
Matěj Kubíček
2026-09-02 20:38:45 +02:00
parent 0c524ed6af
commit c7948a788a
46 changed files with 10099 additions and 152 deletions
+27
View File
@@ -0,0 +1,27 @@
import { describe, expect, it } from 'vitest';
import { analyseCopyPatterns } from '../src/content/heuristics';
import { evidenceFromHeuristics, heuristicScore } from '../src/background/heuristics';
describe('page heuristics', () => {
it('finds dense buzzwords and em-dash cadence without declaring an AI verdict', () => {
const text = 'Supercharge your workflow with our world-class, enterprise-grade platform — move faster — work smarter — without compromise.';
const findings = analyseCopyPatterns(text);
expect(findings.map((finding) => finding.ruleId)).toEqual(expect.arrayContaining([
'copy-marketing-buzzwords',
'copy-em-dash-cadence'
]));
expect(evidenceFromHeuristics(findings).every((item) => item.verdict === 'unknown')).toBe(true);
});
it('adds a diversity point when independent categories agree', () => {
const evidence = evidenceFromHeuristics([
{ ruleId: 'one', category: 'visual', title: 'One', detail: 'One', score: 2, occurrences: 1 },
{ ruleId: 'two', category: 'layout', title: 'Two', detail: 'Two', score: 3, occurrences: 1 }
]);
expect(heuristicScore(evidence)).toBe(6);
});
it('ignores ordinary direct prose', () => {
expect(analyseCopyPatterns('The archive contains monthly invoices. Select a year, then download the required PDF.')).toEqual([]);
});
});