Skip to content

test(ui-kit): add a package-local vitest suite for @loopover/ui-kit's logic-bearing exports#7495

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
xfodev:test/ui-kit-vitest-7437
Jul 20, 2026
Merged

test(ui-kit): add a package-local vitest suite for @loopover/ui-kit's logic-bearing exports#7495
JSONbored merged 1 commit into
JSONbored:mainfrom
xfodev:test/ui-kit-vitest-7437

Conversation

@xfodev

@xfodev xfodev commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #7437. packages/loopover-ui-kit (@loopover/ui-kit, the shared design system) had no test script, no vitest.config.ts, no test-tooling devDependencies, and no test files — its logic-bearing exports were only ever exercised indirectly, through whichever consuming app happened to import them (e.g. relativeTimeFromNow was tested only via apps/loopover-ui's refresh-meta.test.tsx). This mirrors the precedent of #6250 (a whole-directory coverage blind spot filed as its own gittensor:bug).

What this adds

  • packages/loopover-ui-kit/vitest.config.ts + vitest.setup.ts, mirroring apps/loopover-miner-ui/vitest.config.ts's shape (jsdom environment, @vitejs/plugin-react, vite-tsconfig-paths, a Testing-Library cleanup afterEach). No coverage block: this package is deliberately not in the root vitest.config.ts's coverage.include and is not Codecov-gated (per the issue, the acceptance signal is that the suite runs and passes, not a percentage).
  • A test script (vitest run) and the test-only devDependenciesvitest, @vitejs/plugin-react, vite-tsconfig-paths, jsdom, @testing-library/react — pinned to the exact versions apps/loopover-miner-ui already uses, so no second/drifting copy of the tooling enters the monorepo. npm install added 0 new packages to the lockfile (every version was already resolved); the lockfile change is just recording the workspace's new edges. I matched miner-ui's toolset exactly, which does not include @testing-library/jest-dom, so the tests use plain Testing-Library queries (getByText/getByRole throw on miss) rather than introducing a jest-dom version this monorepo doesn't otherwise have.
  • A tsconfig exclude for src/**/*.test.* + the vitest config files, so the package's build (which tsc-emits src/ to the published dist/) never compiles or ships a test file. Verified: dist contains zero *.test.*.
  • Colocated unit tests for the logic-bearing exports only (not the ~40 presentational shadcn primitives):
    • src/utils.test.tscn (merge + tailwind-conflict-wins + falsy drop) and relativeTimeFromNow (all four buckets at/around their boundaries, ported verbatim from refresh-meta.test.tsx so the two suites can't drift, plus the future-clock-skew clamp to "just now").
    • src/hooks/use-mobile.test.tsxuseIsMobile above/below the 768px breakpoint and a matchMedia change event flipping the result (jsdom has no matchMedia, so it's stubbed the standard shadcn way).
    • src/components/state-views.test.tsxLoadingState/EmptyState/ErrorState default copy, the errorKind-driven network-vs-generic copy branch (network/timeout → connectivity copy, http → generic, explicit title/description always wins), and StateBoundary's loading→error→empty→children precedence. Per the issue, this deliberately does NOT assert the call-count behavior of the onFailureNotify useEffect (lines 267–280) — that's a separately-tracked bug, so no test passes errorLabel or locks in that effect's behavior.

CI wiring note (per the issue)

npm run test:ci at the root does not pick up this new suite: its ui:* scripts run npm run ui:kit:build (which I verified still passes and emits no test files) but only the apps' own test/lint/typecheck, not @loopover/ui-kit's. The suite runs standalone via npm --workspace @loopover/ui-kit run test. Wiring it into test:ci is out of scope here (it'd need adding the package to a run fan-out list, not a single obvious hook) and is best filed as a fast-follow.

Validation

  • npm --workspace @loopover/ui-kit run test19 tests pass (3 files)
  • npm --workspace @loopover/ui-kit run build and typecheck green; dist/ contains zero *.test.* (build tsconfig excludes them)
  • Root npm run typecheck green; git diff --check clean; npm install added 0 new packages to the lockfile
  • Scope: packages/loopover-ui-kit/** (+ its lockfile edges) only — no app/API/OpenAPI/DB/wrangler surface changed

Safety

  • No secrets, wallets, hotkeys/coldkeys, PATs, private keys, raw trust scores, private rankings, or maintainer evidence. Test-only devDependencies, all already present in the monorepo at these versions.
  • Auth/CORS/session: N/A. API/OpenAPI/MCP: N/A. UI: no runtime component change — tests + tooling only. No changelog edit; no site//CNAME/lovable changes.

Closes #7437

… logic-bearing exports

packages/loopover-ui-kit had no test script, vitest config, or test files, so its own
logic (relativeTimeFromNow, useIsMobile, the state-primitive copy branches) was only
verified incidentally through consuming apps. Adds a package-local vitest.config.ts +
setup (mirroring apps/loopover-miner-ui: jsdom + React plugin + testing-library
cleanup), a test script, the test devDependencies pinned to miner-ui's exact versions
(0 new lockfile packages), a tsconfig exclude so the dist build never ships a test
file, and colocated unit tests for utils, use-mobile, and state-views -- excluding the
separately-tracked onFailureNotify effect's call-count behavior. Not wired into
test:ci (out of scope per the issue); runs via npm --workspace @loopover/ui-kit test.

Closes JSONbored#7437
@xfodev
xfodev requested a review from JSONbored as a code owner July 20, 2026 12:59
@superagent-security

Copy link
Copy Markdown
Contributor

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

@github-actions
github-actions Bot had a problem deploying to preview/pr-7495 July 20, 2026 13:06 Failure
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.41%. Comparing base (a3f2baa) to head (acb05cf).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7495   +/-   ##
=======================================
  Coverage   91.41%   91.41%           
=======================================
  Files         717      717           
  Lines       73035    73035           
  Branches    21635    21638    +3     
=======================================
  Hits        66765    66765           
  Misses       5227     5227           
  Partials     1043     1043           
Flag Coverage Δ
shard-1 32.41% <ø> (ø)
shard-2 35.38% <ø> (-0.01%) ⬇️
shard-3 31.81% <ø> (ø)
shard-4 43.65% <ø> (ø)
shard-5 37.18% <ø> (ø)
shard-6 36.12% <ø> (ø)

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

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

loopover-orb Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-20 13:57:09 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds a package-local vitest suite to @​loopover/ui-kit, which previously had zero direct test coverage of its logic-bearing exports (cn, relativeTimeFromNow, useIsMobile, state-views components). The devDependency versions are pinned to exactly match apps/loopover-miner-ui's existing toolset (confirmed against the provided miner-ui package.json), avoiding a drifting second copy of the tooling, and the tsconfig exclude correctly keeps test files out of the tsc build. Tests are well-targeted at real exported symbols and boundary conditions (e.g., the 768px breakpoint, relativeTimeFromNow's clock-skew clamp), and CI is green across all checks including codecov and security scans.

Nits — 4 non-blocking
  • The lockfile diff pulls in jsdom and vite-tsconfig-paths transitive trees with no SLSA/sigstore attestation, per the external brief — worth a quick supply-chain sanity check even though these versions already exist elsewhere in the monorepo's dependency graph (apps/loopover-miner-ui).
  • package-lock.json is large by nature of npm's format; not actionable but noting the external brief's size flag is a lockfile artifact, not a real code-size concern.
  • Consider adding a short note in the package README or CONTRIBUTING pointing at `npm test` for ui-kit now that it exists, so future contributors don't miss it.
  • packages/loopover-ui-kit/src/utils.test.ts:1 nicely ports the refresh-meta.test.tsx cases verbatim — if apps/loopover-ui's own suite is ever deleted/deduped in favor of this one, that's a good follow-up but out of scope here.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7437
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: 55 registered-repo PR(s), 30 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor xfodev; Gittensor profile; 55 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Review context
  • Author: xfodev
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, TypeScript
  • Official Gittensor activity: 55 PR(s), 0 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.
🧪 Chat with LoopOver

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

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

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

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

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

Scroll preview
Route Before (production) After (this PR's preview)
/ before / (scroll)
before / (scroll)

A short scroll-through clip (desktop) — click either thumbnail to open the full animation. Evidence for scroll-linked behavior a single screenshot can't show.

🟩 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.

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

@JSONbored
JSONbored merged commit edb6e54 into JSONbored:main Jul 20, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(ui-kit): packages/loopover-ui-kit has no test script, no vitest config, and no test files

2 participants