test(ui-kit): add a package-local vitest suite for @loopover/ui-kit's logic-bearing exports#7495
Conversation
… 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
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. |
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-20 13:57:09 UTC
Review summary Nits — 4 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk 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.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. Visual preview
Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy. Scroll preview
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.
|

Summary
Fixes #7437.
packages/loopover-ui-kit(@loopover/ui-kit, the shared design system) had notestscript, novitest.config.ts, no test-toolingdevDependencies, and no test files — its logic-bearing exports were only ever exercised indirectly, through whichever consuming app happened to import them (e.g.relativeTimeFromNowwas tested only viaapps/loopover-ui'srefresh-meta.test.tsx). This mirrors the precedent of #6250 (a whole-directory coverage blind spot filed as its owngittensor:bug).What this adds
packages/loopover-ui-kit/vitest.config.ts+vitest.setup.ts, mirroringapps/loopover-miner-ui/vitest.config.ts's shape (jsdom environment,@vitejs/plugin-react,vite-tsconfig-paths, a Testing-LibrarycleanupafterEach). Nocoverageblock: this package is deliberately not in the rootvitest.config.ts'scoverage.includeand is not Codecov-gated (per the issue, the acceptance signal is that the suite runs and passes, not a percentage).testscript (vitest run) and the test-only devDependencies —vitest,@vitejs/plugin-react,vite-tsconfig-paths,jsdom,@testing-library/react— pinned to the exact versionsapps/loopover-miner-uialready uses, so no second/drifting copy of the tooling enters the monorepo.npm installadded 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/getByRolethrow on miss) rather than introducing a jest-dom version this monorepo doesn't otherwise have.excludeforsrc/**/*.test.*+ the vitest config files, so the package'sbuild(whichtsc-emitssrc/to the publisheddist/) never compiles or ships a test file. Verified:distcontains zero*.test.*.src/utils.test.ts—cn(merge + tailwind-conflict-wins + falsy drop) andrelativeTimeFromNow(all four buckets at/around their boundaries, ported verbatim fromrefresh-meta.test.tsxso the two suites can't drift, plus the future-clock-skew clamp to"just now").src/hooks/use-mobile.test.tsx—useIsMobileabove/below the 768px breakpoint and amatchMediachangeevent flipping the result (jsdom has nomatchMedia, so it's stubbed the standard shadcn way).src/components/state-views.test.tsx—LoadingState/EmptyState/ErrorStatedefault copy, theerrorKind-driven network-vs-generic copy branch (network/timeout→ connectivity copy,http→ generic, explicit title/description always wins), andStateBoundary's loading→error→empty→children precedence. Per the issue, this deliberately does NOT assert the call-count behavior of theonFailureNotifyuseEffect(lines 267–280) — that's a separately-tracked bug, so no test passeserrorLabelor locks in that effect's behavior.CI wiring note (per the issue)
npm run test:ciat the root does not pick up this new suite: itsui:*scripts runnpm run ui:kit:build(which I verified still passes and emits no test files) but only the apps' owntest/lint/typecheck, not@loopover/ui-kit's. The suite runs standalone vianpm --workspace @loopover/ui-kit run test. Wiring it intotest:ciis out of scope here (it'd need adding the package to arunfan-out list, not a single obvious hook) and is best filed as a fast-follow.Validation
npm --workspace @loopover/ui-kit run test— 19 tests pass (3 files)npm --workspace @loopover/ui-kit run buildandtypecheckgreen;dist/contains zero*.test.*(build tsconfig excludes them)npm run typecheckgreen;git diff --checkclean;npm installadded 0 new packages to the lockfilepackages/loopover-ui-kit/**(+ its lockfile edges) only — no app/API/OpenAPI/DB/wrangler surface changedSafety
site//CNAME/lovablechanges.Closes #7437