test(miner-extension): bring the miner extension under a real coverage gate - #5639
test(miner-extension): bring the miner extension under a real coverage gate#5639claytonlin1110 wants to merge 2 commits into
Conversation
…e gate apps/gittensory-miner-extension had no test suite at all -- coverage was excluded via the blanket apps/** ignore and its five source files' existing __GITTENSORY_MINER_EXTENSION_TEST__ internals-exposure hooks were unused. Add a vitest suite (one *.test.js per source file, jsdom environment) that dynamically imports each file after setting that flag and mocking the chrome.*/fetch/DOM surfaces it needs, exercising both sides of every optional-API guard (chrome.alarms, onStartup, onInstalled, action+onChanged) and error path. Wire miner-extension:test into CI (mirrors how extension:lint/typecheck are already wired) and set coverage thresholds to the measured baseline (99.2% statements, 92.1% branches, 95.12% functions, 100% lines), matching apps/gittensory-miner-ui/vitest.config.ts's precedent from the sibling half of this same issue. Closes JSONbored#4865
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 LoopOver review result - reject/close recommendedReview updated: 2026-07-13 18:36:14 UTC
🛑 Suggested Action - Reject/Close Review summary Nits — 5 non-blocking
Why this is blocked
📋 Copy for AI agents — paste into your coding agent
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk 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.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands Visual preview
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.
|
The lockfile change in the previous commit (adding jsdom/vitest to the
miner-extension workspace) was written by a plain `npm install`, which
dropped 16 pre-existing "peer": true phantom lockfile entries for unmet-
but-declared optional peer dependencies (@cloudflare/workers-types,
@types/gensync, agents/node_modules/@babel/{core,compat-data,helpers,
helper-compilation-targets,helper-validator-option,lru-cache}, empathic,
import-meta-resolve, @anthropic-ai/sdk, @stablelib/base64, fast-sha256,
json-schema-to-ts, standardwebhooks, ts-algebra) that npm ci's stricter
lockfile-completeness validation still requires present -- confirmed by
diffing package-lock.json's package keys between main and this branch,
finding the 16 removed entries line up 1:1 with this PR's actual CI
failure ("Missing: X from lock file" on every job).
Re-running npm install (under both npm 11 and npm 10, from a clean
main-derived baseline) did not restore these entries either -- npm's
install resolver treats them as prunable cruft since nothing currently
requires them to be installed. This commit surgically restores just
those 16 entries from main's lockfile via a targeted merge, keeping the
legitimate jsdom/vitest additions untouched.
|
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. |

Summary
apps/gittensory-miner-extensionhad zero test coverage — excluded via the root vitest config's blanketapps/**ignore, and its five source files'__GITTENSORY_MINER_EXTENSION_TEST__-gated internals-exposure hooks (already wired in by whoever built Give the browser extension a real package.json and CI wiring #4866/feat(miner-extension): add workspace package and CI wiring #5567) went unused.*.test.jsper source file (background.js,content.js,opportunity-badge.js,options.js,toolbar-badge.js), running underjsdom. Each test file setsglobalThis.__GITTENSORY_MINER_EXTENSION_TEST__ = trueplus whateverchrome.*/fetch/DOM mocks that file needs, then does a dynamicimport()(a static import would be hoisted above that setup) to get a fresh module instance per scenario viavi.resetModules().background.js's optional-API guards (chrome.alarms,chrome.runtime.onStartup/onInstalled,chrome.action+chrome.storage.onChanged) present vs. absent; every error path (syncRankedCandidatesFromMinerUi's non-2xx / malformed-payload / thrown-fetch cases;options.js's malformed-JSON / oversized-payload / rejected-sendMessagecases); the "never populated" vs. "populated but empty" vs. "populated" three-way distinction intoolbar-badge.js.miner-extension:testinto.github/workflows/ci.ymlright alongside the existingextension:lint/miner-extension:lint/typechecksteps (same trigger condition), and adds the matchingminer-extension:testscript to the rootpackage.json.vitest.config.tsare set to the real measured baseline (99.2% statements / 92.1% branches / 95.12% functions / 100% lines) with a small buffer below, mirroringapps/gittensory-miner-ui/vitest.config.ts's identical framing from test(miner-ui): bring the miner-ui under a real coverage gate #5613 — a floor to catch a genuine regression, not a ratchet.README.md.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Closes #4865
Validation
git diff --checknpm run actionlintnpm run db:migrations:check/db:schema-drift:check/selfhost:env-reference:check(no DB/env changes in this PR; ran as part ofnpm run test:ci)npm run typechecknpm run test:coverage(this PR only touchesapps/gittensory-miner-extension/**, which Codecov'ssrc/**-only patch rule does not gate — coverage here is enforced locally via the newvitest.config.tsthresholds instead, matching the miner-ui half's precedent)npm run miner-extension:test— 96 tests, all passing, coverage thresholds metnpm run ui:lintnpm run ui:typechecknpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run cf-typegen:check(part ofnpm run test:ci) fails locally on this Windows dev machine with awrangler ENOENT—scripts/gen-cf-typegen.mjscallsexecFileSync("wrangler", ...)withoutshell: true, which cannot invoke npm's.cmdshim on Windows (reproduces in isolation, independent of any change in this PR). This PR makes no Cloudflare/wrangler.jsoncchanges; the check runs fine on the actual CI (Linux runners). Every other step innpm run test:ciran and passed before that point.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots. N/A for this PR — it has no visible UI surface (pure test coverage + CI config), so no screenshot evidence applies.Notes
gittensory-extension(the sibling maintainer-facing extension) still has no test suite of its own — out of scope for Bring the miner-ui and extension under a coverage gate #4865, which only names the miner-ui and miner-extension.