Skip to content

test(miner-extension): bring the browser extension under a real coverage gate (#4865) - #5633

Closed
carlh7777 wants to merge 1 commit into
JSONbored:mainfrom
carlh7777:test/miner-extension-coverage-gate-4865
Closed

test(miner-extension): bring the browser extension under a real coverage gate (#4865)#5633
carlh7777 wants to merge 1 commit into
JSONbored:mainfrom
carlh7777:test/miner-extension-coverage-gate-4865

Conversation

@carlh7777

Copy link
Copy Markdown
Contributor

Summary

  • apps/gittensory-miner-extension was excluded from coverage via the root vitest.config.ts blanket
    coverage.exclude: ["apps/**"], and its existing behavior tests (test/unit/miner-*.test.ts) run the
    source through a node:vm harness, which v8 cannot attribute coverage to. This PR gives the extension a
    real, measured coverage gate — the extension half of Bring the miner-ui and extension under a coverage gate #4865 (the miner-ui half shipped in test(miner-ui): bring the miner-ui under a real coverage gate #5613).
  • Adds an app-local, import-based vitest suite (apps/gittensory-miner-extension/test/) that imports the
    real source files directly — using the source's own globalThis.__GITTENSORY_MINER_EXTENSION_TEST__
    internals hook — so v8 attributes coverage to the files. Covers the pure state maps and the background
    service worker: toolbar-badge.js, opportunity-badge.js, and background.js (52 tests).
  • Adds a coverage block + measured baseline thresholds to a new apps/gittensory-miner-extension/vitest.config.ts
    (v8; include scoped to the three covered files), and changes the app's test script to vitest run --coverage.
  • Wires the app's test into the root ui:test, so the gate runs wherever npm run ui:test / npm run test:ci
    already run — no new CI step.
  • Documents the gate and the deferred scope in the app README.

The two DOM-page scripts — content.js (issue-page content script) and options.js (options-page form) — need
a jsdom mount harness and are deliberately left for a follow-up. The threshold is a real measured baseline
(100% statements/functions/lines, 96.63% branches the day this was wired), a regression floor with a small
buffer, not an aspirational target — to be raised per-PR as the deferred scripts get covered.

Advances #4865 (not closing it — the content.js/options.js coverage half is still open).

Scope

Validation

  • git diff --check
  • npm --workspace @jsonbored/gittensory-miner-extension run test — 52 passing; coverage 100% stmts /
    96.63% branches / 100% funcs / 100% lines, over the configured floor
  • npm run docs:drift-check
  • npm run test:ci (full local gate) — run before merge
  • npm audit --audit-level=moderate

If any required check was skipped, explain why:

  • This is a test-, config-, and README-only change under apps/gittensory-miner-extension/**, which Codecov
    ignores (apps/**), so it owes no codecov/patch coverage; the new gate is the app's own vitest threshold.
    It touches no src/**, no other workspace's source, no OpenAPI/MCP/wrangler/migrations, so those generated
    artifacts and their drift checks are unaffected.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, PATs, private keys, trust scores, or private rankings exposed.
  • Public GitHub text stays sanitized and low-noise.
  • Auth/cookie/CORS/session — n/a (no such changes; the extension makes no write to GitHub).
  • API/OpenAPI/MCP — n/a (no behavior change).
  • UI changes use real states — n/a (no runtime/UI change; tests + config + docs only).
  • Visible UI changes include a UI Evidence section — n/a: no user-visible UI or extension-behavior change.
  • Public docs updated (app README); no changelog edited.

UI Evidence

No visible UI or extension-behavior change. This PR only adds a test suite, a coverage-gate config, a test
script, and a dev-facing README section — there is no user-facing surface to screenshot (same as the miner-ui
coverage-gate PR #5613).

Notes

  • The existing node:vm-based tests in root test/unit/ are left in place as behavior tests; the new
    app-local suite's role is coverage instrumentation the vm harness structurally cannot provide.

- Updated package.json to include tests for the @jsonbored/gittensory-miner-extension in the ui:test script.
- Added a new test script in the miner extension's package.json for running tests with vitest.
- Introduced vitest configuration for the miner extension, enabling coverage reporting and setting thresholds.
- Created comprehensive test suites for background.js, opportunity-badge.js, and toolbar-badge.js, ensuring critical functionality is covered.
- Expanded README.md to document the new testing process and coverage expectations.
@carlh7777
carlh7777 requested a review from JSONbored as a code owner July 13, 2026 16:09
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 13, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.01%. Comparing base (b189eaf) to head (cc70d6e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5633   +/-   ##
=======================================
  Coverage   95.01%   95.01%           
=======================================
  Files         575      575           
  Lines       45738    45738           
  Branches    14661    14661           
=======================================
  Hits        43459    43459           
  Misses       1528     1528           
  Partials      751      751           
Flag Coverage Δ
shard-1 43.90% <ø> (ø)
shard-2 35.74% <ø> (ø)
shard-3 32.34% <ø> (ø)
shard-4 32.57% <ø> (ø)
shard-5 31.78% <ø> (ø)
shard-6 44.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 13, 2026
@loopover-orb

loopover-orb Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Caution

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

🛑 LoopOver review result - reject/close recommended

Review updated: 2026-07-13 16:15:06 UTC

8 files · 1 AI reviewer · 1 blocker · readiness 100/100 · CI green · unstable

🛑 Suggested Action - Reject/Close

  • AI review could not be completed: The dual-model AI review did not return a usable verdict for this change.

Review summary
This PR adds an app-local vitest suite that imports background.js/opportunity-badge.js/toolbar-badge.js directly (leveraging the existing __GITTENSORY_MINER_EXTENSION_TEST__ hook) so v8 can attribute real coverage, replacing the coverage-blind node:vm harness, and wires a measured coverage floor (98/94/98/98) into the app's test script and the root ui:test chain. The tests genuinely exercise the real source (message routing, storage degradation, alarm/startup wiring, badge painting) rather than fabricating unreachable states, and the thresholds are described as a measured baseline with a small buffer rather than an aspirational target. content.js and options.js remain uncovered and are explicitly deferred with a documented follow-up, which is reasonable scoping rather than silently reducing the ask.

Nits — 5 non-blocking
  • The coverage thresholds (98/94/98/98) in apps/gittensory-miner-extension/vitest.config.ts:22-25 are unexplained magic numbers in the diff itself, though the surrounding comment does justify them as a measured-baseline-minus-buffer.
  • No test appears to cover the `chrome.storage.sync.set`/`remove` mock paths or verify `syncGetThrows` scenarios beyond the one already tested — worth confirming full branch coverage of background.js's error paths is real and not just numerically satisfied.
  • Consider extracting the threshold values into named constants (e.g. `MEASURED_BASELINE_MINUS_BUFFER`) in vitest.config.ts for clarity, per the external review brief.
  • When content.js/options.js get their jsdom harness in the follow-up, raise thresholds back toward 100% branches per the README's stated plan.
  • AI review could not be completed — The gate is held for a human reviewer rather than passed automatically; it re-evaluates on the next update.

Why this is blocked

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review
Signal Result Evidence
Code review ❌ 1 blocker 1 reviewer
Linked issue ✅ No-issue rationale PR body explains why no issue is linked.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 193 registered-repo PR(s), 124 merged, 17 issue(s).
Contributor context ✅ Confirmed Gittensor contributor carlh7777; Gittensor profile; 193 PR(s), 17 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: moderate — This closes a real coverage gap (extension code was fully excluded from measured coverage) with genuine import-based tests rather than a token gate, directly advancing the linked #4865 issue.
Review context
  • Author: carlh7777
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, JavaScript, TypeScript, Cuda, HTML, MDX, Rust
  • Official Gittensor activity: 193 PR(s), 17 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @gittensory ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before / after /
/ mobile before / (mobile) after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Gittensory is closing this pull request on the maintainer's behalf (No linked issue detected). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant