test(dashboard): unit coverage for api client + BillingPage handlers#25
Merged
Merged
Conversation
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.)
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 73 new test cases across two surfaces that previously had zero unit coverage. Before this PR the dashboard had 26 tests (all on the shared markdown renderer). After: 99 tests (96 pass, 3 documented-skip).
`src/api/index.test.ts` (45 cases) — covers the live API client used by BillingPage + ClaimPage + AuthGate:
`src/pages/BillingPage.test.tsx` (28 cases) — covers the upgrade-flow handlers:
Implementation notes
What changed at runtime
Nothing. Only test files + `vite.config.ts` `test.setupFiles` entry + a new test-only polyfill module. The 26 existing markdown tests still pass.
Findings
No real bugs surfaced during test development. The 503 fallback paths, error propagation, button disable behavior, and confirm/alert side effects all work as documented.
Test plan