Skip to content

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

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
andriypolanski:test/miner-extension-coverage-gate-4865-v2
Jul 13, 2026
Merged

test(miner-extension): bring the browser extension under a real coverage gate (#4865)#5644
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
andriypolanski:test/miner-extension-coverage-gate-4865-v2

Conversation

@andriypolanski

Copy link
Copy Markdown
Contributor

Closes #4865

Summary

  • apps/gittensory-miner-extension was excluded from Codecov via the blanket apps/** ignore, and its existing root test/unit/miner-*.test.ts suites run source through a node:vm harness that v8 cannot attribute coverage to.
  • This PR completes the extension half of Bring the miner-ui and extension under a coverage gate #4865. The miner-ui half already shipped on main in test(miner-ui): bring the miner-ui under a real coverage gate #5613 (apps/gittensory-miner-ui/vitest.config.ts + npm test --coverage).
  • Adds an app-local, import-based vitest suite that imports background.js, opportunity-badge.js, and toolbar-badge.js directly (via the existing __GITTENSORY_MINER_EXTENSION_TEST__ hook) so v8 attributes real coverage, with measured baseline thresholds enforced by npm test.

Change

  • apps/gittensory-miner-extension/vitest.config.ts — v8 coverage scoped to the three covered source files; thresholds set at a measured baseline (98/94/98/98) with buffer below the wired-day numbers.
  • apps/gittensory-miner-extension/test/ — 19 tests across:
    • toolbar-badge.test.ts — pure state map (computeToolbarBadge)
    • opportunity-badge.test.ts — lookup, formatting, markup escaping
    • background.test.ts — issue context, sync, message routing, toolbar badge wiring, alarms/lifecycle
  • apps/gittensory-miner-extension/package.jsontest script → vitest run --coverage; adds vitest devDependency.
  • package.jsonui:test now runs @jsonbored/gittensory-miner-extension run test.
  • test/unit/codecov-policy.test.ts — regression guard that both miner-ui and miner-extension have app-local coverage gates wired into ui:test.
  • README updates — document the gate and deferred scope in both miner apps.

Deferred scope (issue still open after merge)

Scope

Validation

  • git diff --check
  • npm run actionlint (not run — no .github/workflows/** changes)
  • npm run typecheck (not run — no src/** changes)
  • npm run test:coverage (full unsharded gate — run before push)
  • npm run test:workers (not run — no Workers pool changes)
  • npm run build:mcp / npm run test:mcp-pack (not run — no MCP changes)
  • npm run ui:openapi:check (not run — no OpenAPI changes)
  • npm run ui:lint / npm run ui:typecheck / npm run ui:build (run via npm run test:ci before push)
  • npm audit --audit-level=moderate
  • npm --workspace @jsonbored/gittensory-miner-extension run test — 19 passing; coverage 100% stmts / 95.79% branches / 100% funcs / 100% lines over configured floor
  • npm run test -- --run test/unit/codecov-policy.test.ts — 5 passing

If any required check was skipped, explain why:

  • Changes are under apps/** and test/** only — outside Codecov-measured src/** / lib/**, so no codecov/patch obligation. The new gate is the extension's own vitest threshold. Full npm run test:ci should still be run locally before push.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, PATs, private keys, trust scores, or private rankings exposed.
  • Public GitHub text unaffected — tests + config + docs only; no runtime behavior change.
  • Auth/cookie/CORS/session — n/a.
  • API/OpenAPI/MCP — n/a.
  • No visible UI or extension-behavior change.
  • No changelog edit.

UI Evidence

No visible UI or extension-behavior change. This PR only adds a test suite, coverage-gate config, ui:test wiring, and README notes — same as the miner-ui coverage-gate PR #5613. No screenshots required.

Notes

  • Root test/unit/miner-*.test.ts VM-based behavior tests are left in place; the new app-local suite's role is coverage instrumentation the VM harness structurally cannot provide.
  • Thresholds are a regression floor with buffer, not an aspirational target — raise per-PR as content.js/options.js get covered.

Files to commit

apps/gittensory-miner-extension/vitest.config.ts
apps/gittensory-miner-extension/test/helpers.ts
apps/gittensory-miner-extension/test/toolbar-badge.test.ts
apps/gittensory-miner-extension/test/opportunity-badge.test.ts
apps/gittensory-miner-extension/test/background.test.ts
apps/gittensory-miner-extension/package.json
apps/gittensory-miner-extension/README.md
apps/gittensory-miner-ui/README.md
package.json
package-lock.json
test/unit/codecov-policy.test.ts

@superagent-security

Copy link
Copy Markdown
Contributor

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

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 13, 2026
@loopover-orb

loopover-orb Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-13 18:44:43 UTC

11 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds an import-based vitest suite for the miner-extension (background.js, opportunity-badge.js, toolbar-badge.js) so v8 coverage can be attributed, wires it into vitest.config.ts with measured thresholds, and adds a package.json test script plus a root ui:test hook. It closes the extension half of #4865 (the miner-ui half already shipped in #5613), and a codecov-policy regression test locks in that both apps keep app-local coverage gates. The tests are substantive (19 cases covering malformed storage, sync failures, alarms/lifecycle, badge repaint logic) rather than trivial, and content.js/options.js are explicitly and reasonably deferred pending a jsdom harness.

Nits — 5 non-blocking
  • The four threshold numbers (98/94/98/98) in apps/gittensory-miner-extension/vitest.config.ts:16-19 are unexplained magic numbers beyond the inline comment; consider a short note on how they were measured (e.g. from a coverage run) so future contributors know why 94 for branches specifically.
  • test/helpers.ts's buildChromeMock is a large, options-heavy mock (150+ lines) — fine for now, but if more chrome.* surfaces get added consider splitting per-surface builders to keep it readable.
  • The linked issue Bring the miner-ui and extension under a coverage gate #4865 is only partially closed by this PR (content.js/options.js deferred) — worth confirming that's acceptable to leave open rather than closed with a follow-up issue filed.
  • Consider filing the deferred content.js/options.js jsdom-harness work as its own tracked issue now, rather than leaving it as a comment inside README.md and vitest.config.ts, so it doesn't get lost.
  • The codecov-policy.test.ts regression guard (test/unit/codecov-policy.test.ts) only checks for the presence of `thresholds:` and `--coverage`, not the actual threshold values — a future PR could silently drop them to 0 and still pass; consider asserting minimum values.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #4865
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 (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 163 registered-repo PR(s), 106 merged, 28 issue(s).
Contributor context ✅ Confirmed Gittensor contributor andriypolanski; Gittensor profile; 163 PR(s), 28 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
Review context
  • Author: andriypolanski
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 163 PR(s), 28 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 <question> answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat <question> 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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 5db59ed into JSONbored:main Jul 13, 2026
25 checks passed
@andriypolanski
andriypolanski deleted the test/miner-extension-coverage-gate-4865-v2 branch July 16, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bring the miner-ui and extension under a coverage gate

2 participants