Skip to content

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

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

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

Conversation

@carlh7777

Copy link
Copy Markdown
Contributor

Summary

apps/gittensory-miner-extension was excluded from all coverage via the root vitest.config.ts blanket
coverage.exclude: ["apps/**"], and its only tests (test/unit/miner-*.test.ts) ran the source through a
node:vm harness that v8 cannot attribute coverage to. This PR gives the extension a real, measured coverage
gate over every shipped script, completing the extension half of #4865 (the miner-ui half shipped in #5613).

  • Adds an app-local, import-based vitest suite (apps/gittensory-miner-extension/test/) that imports the
    real source files directly — via the source's own globalThis.__GITTENSORY_MINER_EXTENSION_TEST__ internals
    hook — so v8 attributes true coverage. 85 tests across all five scripts:
    background.js, content.js, opportunity-badge.js, options.js, toolbar-badge.js.
  • The two DOM-page scripts (content.js, options.js) run under jsdom via a per-file
    // @vitest-environment jsdom docblock; the rest run in Node.
  • Adds apps/gittensory-miner-extension/vitest.config.ts (v8; include scoped to the five scripts) 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 in the app README.

Coverage is 100% statements / 97.89% branches / 100% functions / 100% lines. The only uncovered branches are the
four if (globalThis.__GITTENSORY_MINER_EXTENSION_TEST__) test-only export guards (one per script), whose false
arm can never run while the suite's setup file has that flag set. Thresholds are set to that measured baseline
(100 / 97 / 100 / 100) — a regression floor, not an aspirational ratchet.

Closes #4865.

Scope

Validation

  • npm --workspace @jsonbored/gittensory-miner-extension run test — 85 passing; 100% stmts / 97.89% branches
    / 100% funcs / 100% lines, over the configured floor.
  • npm run ui:test — full UI chain green (gittensory-ui 244, miner-ui 111, miner-extension 85).

Safety

  • No secrets, wallets, hotkeys/coldkeys, PATs, private keys, trust scores, or private rankings exposed.
  • Test-, config-, and README-only change under apps/gittensory-miner-extension/**; touches no src/**,
    no OpenAPI/MCP/wrangler/migrations, so no generated artifacts are affected.
  • No user-visible UI or extension-behavior change (tests + config + docs only).

Notes

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

- Updated the `ui:test` script in `package.json` to include tests from the `@jsonbored/gittensory-miner-extension` workspace, ensuring comprehensive coverage.
- Added a new `test` script in the `apps/gittensory-miner-extension/package.json` to run tests using Vitest, improving the testing framework.
- Expanded the README.md to document the testing process and coverage details for the miner extension, providing clarity for developers.
- Introduced Vitest configuration in `vitest.config.ts` to streamline test execution and coverage reporting.
- Created multiple test files for various components, including `background.test.js`, `content.test.js`, and `opportunity-badge.test.js`, to ensure robust testing of the miner extension's functionality.
@carlh7777
carlh7777 requested a review from JSONbored as a code owner July 13, 2026 18:21
@superagent-security

Copy link
Copy Markdown
Contributor

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

@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

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

Caution

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

🛑 LoopOver review result - reject/close recommended

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

10 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 a real, v8-attributed vitest suite for the miner extension's five source scripts, replacing the coverage-blind node:vm harness, and wires it into the shared `ui:test` pipeline with a package-level test script. The suite is thorough (85 tests, both true/false arms of most branches, error-vs-non-Error throw paths, DOM mounting/removal paths) and the threshold rationale (97% branch floor for four irreducible test-only export guards) is clearly documented in comments. This is exactly the kind of narrow, test-only infrastructure change the repo's review conventions favor, and it closes #4865 per the description.

Nits — 5 non-blocking
  • apps/gittensory-miner-extension/vitest.config.ts:23 hardcodes the branch threshold as `97` — a named constant or inline reference to the measured 97.89% would make the intentional slack under the baseline clearer to a future editor.
  • The flagged 'Contributor trust' CI check failing is outside the diff's control and not a code defect, but per repo convention this PR still needs a linked/closing issue reference verified beyond the description text (it claims to close Bring the miner-ui and extension under a coverage gate #4865, which should be confirmed as an open, eligible issue).
  • Consider extracting the repeated `flush()` double-microtask-tick helper (background.test.js, content.test.js, options.test.js each redefine similar timing helpers) into a shared test util if more scripts are added later — not urgent given only three files currently duplicate it.
  • apps/gittensory-miner-extension/vitest.config.ts:14-16 could reference the measured 97.89% branch value directly in a comment near the `branches: 97` threshold for quicker regression triage.
  • 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

  • Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. Linked issue overlaps another open PR — Review the related PRs before spending reviewer time on duplicate work.
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review
Signal Result Evidence
Code review ❌ 1 blocker 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: 192 registered-repo PR(s), 124 merged, 17 issue(s).
Contributor context ✅ Confirmed Gittensor contributor carlh7777; Gittensor profile; 192 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 — The diff replaces a coverage-blind test harness with a real v8-attributed suite across all five shipped scripts and wires it into CI, which is a genuine, well-targeted infrastructure improvement matching its stated intent to close #4865.
Linked issue satisfaction

Partially addressed
The PR fully delivers the extension half of the issue (app-local vitest+v8 config, real import-based coverage, thresholds, README docs, CI wiring), but the issue explicitly asks for both apps and the root vitest.config.ts's blanket apps/** ignore is not shown to be carved out for either app in this diff; the description states the miner-ui half shipped separately in #5613, so this PR alone leaves

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: 192 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 <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 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Gittensory is closing this pull request on the maintainer's behalf (Linked issue overlaps another open PR; duplicate of another open PR). 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: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

1 participant