Skip to content

Fix spending-limits usage & persistence, wire shell i18n, run e2e in CI - #737

Merged
Jambox11 merged 2 commits into
mux-labs:stagingfrom
synkijojo-byte:fix/spending-limits-shell-i18n-e2e
Aug 29, 2026
Merged

Fix spending-limits usage & persistence, wire shell i18n, run e2e in CI#737
Jambox11 merged 2 commits into
mux-labs:stagingfrom
synkijojo-byte:fix/spending-limits-shell-i18n-e2e

Conversation

@synkijojo-byte

Copy link
Copy Markdown
Contributor

Closes #648, closes #649, closes #650, closes #651.

#648 — Compute spending-limits todayUsage from real activity

  • src/app/api/spending-limits/route.ts imported getBackendApiBaseUrl from @/lib/api/config, but that helper did not exist — the production proxy threw at runtime (tests passed only because they mock the whole module). Added getBackendApiBaseUrl() reading the server-only MUX_BACKEND_URL, normalised, returning "" when unset so the route responds 503 instead of fabricating data. Registered MUX_BACKEND_URL in src/lib/env.ts and .env.example.
  • src/app/api/demo/spending-limits/route.ts no longer returns a hardcoded todayUsage: 750. It derives the figure from the mock transaction store via the new computeTodayUsage() (src/lib/spending-limits/todayUsage.ts) — the sum of completed transaction amounts on the latest day. The real route already gets todayUsage straight from mux-backend (backend work is out of scope here).

#649 — Stop writing spending limits to localStorage as account state

  • SpendingLimitsCard no longer reads or writes the spending-limits localStorage key. Limits are account state owned by the backend; a per-browser copy is wrong for a second device or a shared machine.
  • On a failed load it now shows an explicit error plus clearly-labelled default limits (no silent cache fallback). todayUsage starts at 0 rather than a fabricated 750 placeholder.

#650 — Consume shellLabels in Sidebar and TopNav

  • Sidebar nav items and TopNav (network-switcher labels, page-title map, breadcrumb "Home", sign-out label) now source copy from src/lib/i18n/shellLabels.ts. Added nav.users and header.breadcrumbHome; header.logout set to the existing visible text ("Sign out") so no user-facing copy changes.
  • Repaired the pre-existing broken Sidebar.test.tsx (missing useRouter mock and imports) so the suite runs again.

#651 — Run Playwright e2e in CI

  • Added an e2e-tests job to .github/workflows/ci.yml that installs Chromium and runs pnpm run test:e2e against the in-repo mock API routes (NEXT_PUBLIC_API_URL="").
  • tests/ci-workflow.test.ts guards the job so it cannot silently regress.

Docs

README env table + smoke-tests section, docs/frontend-env-vars.md, and src/docs/API_Hooks.md updated to match.

Testing

  • pnpm exec vitest run over every touched file: 92 passed.
  • Compared full failing-test sets on this branch vs. clean staging for the touched directories: 0 new failures, 14 pre-existing failures fixed (the whole Sidebar.test.tsx suite + one obsolete cache test).
  • Pre-existing, unrelated redness on staging is left untouched: parse errors in APIKeyModal.tsx / ApiKeysTable.tsx (already noted in playwright.config.ts) that block the typecheck job, and route tests failing on a missing isMockFallbackAllowed import in src/app/api/auth/login/route.ts.

🤖 Generated with Claude Code

Closes mux-labs#648, mux-labs#649, mux-labs#650, mux-labs#651.

mux-labs#648 — Compute spending-limits todayUsage from real activity
- Add getBackendApiBaseUrl() (reads server-only MUX_BACKEND_URL); the
  production /api/spending-limits proxy imported it but it did not exist,
  so the route threw at runtime. Register MUX_BACKEND_URL in env schema
  and .env.example.
- /api/demo/spending-limits no longer returns a hardcoded todayUsage: 750.
  It derives the figure from the mock transaction store via the new
  computeTodayUsage() helper (sum of completed transaction amounts on the
  latest day). The real route already gets todayUsage straight from
  mux-backend.

mux-labs#649 — Stop writing spending limits to localStorage as account state
- SpendingLimitsCard no longer reads or writes the "spending-limits"
  localStorage key. Limits are account state owned by the backend; a
  per-browser copy is wrong for a second device or a shared machine.
- On a failed load it shows an explicit error plus clearly-labelled
  default limits (no silent cache fallback). todayUsage starts at 0
  instead of a fabricated 750 placeholder.

mux-labs#650 — Consume shellLabels in Sidebar and TopNav
- Sidebar nav items and TopNav (network switcher labels, page-title map,
  breadcrumb "Home", sign-out label) now source copy from
  src/lib/i18n/shellLabels.ts. Added nav.users and header.breadcrumbHome;
  header.logout set to the existing visible text ("Sign out").
- Repaired the pre-existing broken Sidebar.test.tsx (missing useRouter
  mock / imports) so the suite runs again.

mux-labs#651 — Run Playwright e2e in CI
- Add an e2e-tests job to .github/workflows/ci.yml that installs Chromium
  and runs `pnpm run test:e2e` against the in-repo mock API routes.
- tests/ci-workflow.test.ts guards the job so it can't silently regress.

Docs: README env table + smoke-tests section, docs/frontend-env-vars.md,
src/docs/API_Hooks.md updated to match.

Note: pre-existing typecheck errors in APIKeyModal.tsx / ApiKeysTable.tsx
and unrelated failing route tests on staging are untouched by this branch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AnArGB2SYQdyydwngKE6qC
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@synkijojo-byte Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Jambox11
Jambox11 merged commit d15775a into mux-labs:staging Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants