Skip to content

Fix formatting in techniques.js#26

Merged
sebdraven merged 6 commits into
mainfrom
BartM82-patch-1
May 14, 2026
Merged

Fix formatting in techniques.js#26
sebdraven merged 6 commits into
mainfrom
BartM82-patch-1

Conversation

@BartM82
Copy link
Copy Markdown
Member

@BartM82 BartM82 commented May 14, 2026

No description provided.

@BartM82 BartM82 requested a review from sebdraven May 14, 2026 20:01
sebdraven and others added 5 commits May 14, 2026 22:37
Test infrastructure
-------------------
- Vitest + happy-dom: 5 test files, 83 unit tests covering ContentExtractor
  (cleanText keeping Unicode scripts, detectPageType edge cases, title
  extraction), TechniqueAnalyzer (risk bands, keyword matching boundaries,
  weight escalation), SuspiciousSitesManager (exact/contains/pattern matching
  plus the Storm1516 social-account format, handle extraction, logging gate),
  UIManager (escapeHtml, sanitizeHexColor, isSafeHttpUrl, adjustColor clamp,
  tooltip), and manifest sanity (JSON validity, declared paths exist).
- tests/helpers/loadScript.js loads each content-script source as it would
  run in Chrome (indirect eval inside happy-dom's window), keeping the
  production code unchanged.

Source-side adjustments to make the modules testable
----------------------------------------------------
- Suspicioussitesmanager.js: expose `window.SuspiciousSitesManager` (the
  class, in addition to the instance). Gate the "no databases loaded"
  warning behind DIMA_DEBUG — same noise-reduction rationale as the
  previous review pass. Tidy an unused destructure variable.

Tooling
-------
- package.json with vitest, happy-dom, eslint, globals; scripts: test,
  test:watch, test:coverage, lint, lint:fix, ci.
- eslint.config.js (flat config): browser globals for source, node +
  vitest globals for tests, no-eq-eq smart, no-redeclare disabled because
  database files declare their own globals at top level.
- vitest.config.js: happy-dom env, coverage scoped to modules/ + content.js.
- .gitignore.

GitHub Actions
--------------
- ci.yml: lint + tests on every push to main and every PR.
- release.yml: on tag v*.*.*, verify tag matches manifest.version, run
  npm ci, zip the runtime files (manifest, content.js, modules/, data/,
  docs, README, LICENSE, icons), upload as workflow artifact and create
  a draft GitHub release.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
contentExtractor.test.js — add three cases that exercise the matchStem
switch on `article` and `blog`:
  - /articles/foo -> news
  - /blogs/post   -> blog
  - blogs.example.com -> blog

animations.test.js — new file. Scans content.js for @Keyframes
declarations and uiManager.js for `animation:` references, asserting
that every name begins with `dima`. Prevents a future change from
re-introducing a generic keyframe name (fadeIn, slideIn, ...) that
would collide with the host page's CSS namespace.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
accessibility.test.js — exercise createButton() against happy-dom and
assert that the rendered badge:
  - carries role=button and tabindex=0
  - exposes an aria-label including score and risk level
  - hides the decorative 🧠 from screen readers
  - fires showModal on Enter and on Space
  - preventDefault on Space (so the host page doesn't scroll)
  - ignores unrelated keys

syncInit.test.js — guard the bootstrap of Suspicioussitesmanager.js:
  - no setTimeout(...) call in the init block (comments are stripped
    so the historical note explaining why the delay was removed
    doesn't trip the assertion)
  - window.checkSuspiciousSite is callable immediately after the
    module is loaded (no async wait)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drops the `push: branches: [main]` trigger from the CI workflow. The
test/lint suite already runs on every pull request just before merge,
so a second run after the merge lands on main is redundant — it costs
a minute of Actions time without changing what we know about main.

The release workflow keeps its `push: tags` trigger; tagging still
produces the draft release zip.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sebdraven sebdraven merged commit 5871e51 into main May 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants