Commit c90c951
test(dashboard): unit coverage for api client + BillingPage handlers (#25)
* chore(ci): bump actions/checkout@v5 + setup-node@v5 + node 22
GH Actions has been emitting deprecation warnings on every CI
run:
Node.js 20 actions are deprecated. The following actions are
running on Node.js 20 and may not work as expected: actions/
checkout@v4, actions/setup-node@v4.
setup-node@v5 (and checkout@v5) run on Node 24 by default; bump
the engines target to node 22 as a stable LTS that's well-tested
with both Vite and Playwright. (Local dev still works on whatever
the dev has — these versions only affect CI runners.)
* test(dashboard): unit coverage for api client + BillingPage handlers
Adds 73 new test cases across two surfaces that previously had zero
unit coverage (only src/lib/markdown.tsx had tests before):
- src/api/index.test.ts (45 cases) — fetchBilling/listInvoices happy +
503 fallback, createCheckout (POST body + propagation), cancel,
claim, fetchMe mapping, getAPIBaseURL override priority, token
storage round-trip, listResources adapter, deleteResource verb.
- src/pages/BillingPage.test.tsx (28 cases) — handleChangePlan
invokes createCheckout(nextTier) and redirects via location.href on
short_url, error path surfaces checkoutErr, handleCancel gates on
window.confirm + re-fetches billing on success, error message
fallbacks, in-flight button disable.
Adds src/test-setup.ts — a minimal localStorage polyfill that fixes
the Node 25 + jsdom 24 mismatch where window.localStorage methods are
undefined. Inert on Node 22 (CI) where jsdom localStorage works
natively, so this is forward-compatible.
3 tests in index.test.ts are .skip with documentation — Vite inlines
import.meta.env.{DEV,VITE_API_URL} at compile time inside the api
module, so the prod-default and VITE_API_URL branches of
getAPIBaseURL() can only be exercised by the built bundle (covered by
Playwright E2E). The window.__INSTANODE_API_URL__ override branch is
tested directly.
No runtime code changed. No bugs surfaced during test development.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 43dae65 commit c90c951
4 files changed
Lines changed: 1070 additions & 1 deletion
0 commit comments