DRY: replace Puppeteer page.evaluate with browser script injection, add browser tests

Major cleanup:
- detectUrl() now injects the browser script via page.evaluate() and
  calls window.impeccableScan() instead of reimplementing all detection
  logic inline. Removes ~80 lines of triple-duplicated code.
- Removed dead isPureBlackOrWhite function.
- CLI reduced from 1286 to 1212 lines.

New: Puppeteer-powered browser parity tests (detect-antipatterns-browser.test.js):
- Starts a local HTTP server for fixtures
- Loads fixture pages in headless Chrome
- Runs the browser detection script via impeccableScan()
- Verifies findings match expectations for all fixture categories:
  borders, colors, layout, typography, partials

8 new browser tests catch desync between CLI and browser script
(like the WeakSet iteration bugs we hit earlier).

puppeteer added as devDependency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-03-17 16:53:13 -07:00
co-authored by Claude Opus 4.6
parent b34e0949a0
commit 7bc3a5567d
4 changed files with 191 additions and 192 deletions
+1
View File
@@ -32,6 +32,7 @@
"type": "module",
"devDependencies": {
"jsdom": "^29.0.0",
"puppeteer": "^24.39.1",
"wrangler": "^4.71.0"
}
}