Skip to content

test(frontend): cover max balance button behavior#13302

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/missing-test-coverage-b388
Draft

test(frontend): cover max balance button behavior#13302
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/missing-test-coverage-b388

Conversation

@cursor

@cursor cursor Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Motivation

Recent MaxBalanceButton changes added fee-aware max calculations and a maxAmount cap used by Liquidium repayment/supply flows. The existing spec only checked rendered labels, leaving the user-funds path where clicking Max mutates amount and re-applies after fee changes untested.

Risky behavior now covered:

  • Native-token fees are reserved before comparing against a higher maxAmount cap.
  • Lower maxAmount caps still win after fee reservation.
  • Clicking Max writes the capped amount and marks amountSetToMax.
  • Zero balances remain a no-op.
  • Fee changes debounce and re-apply Max when the amount was already set to Max.

Changes

  • Added MaxBalanceButtonTestHost.svelte to expose bindable amount and amountSetToMax state in component tests.
  • Extended MaxBalanceButton.spec.ts with focused fee/cap/click/debounce regression cases.

These tests materially reduce regression risk because MaxBalanceButton is shared across send/stake/Liquidium flows and directly controls the maximum spendable amount shown and submitted by users.

Tests

  • npx @sveltejs/mcp svelte-autofixer ./src/frontend/src/tests/lib/components/common/MaxBalanceButtonTestHost.svelte --svelte-version 5
  • npx prettier --check src/frontend/src/tests/lib/components/common/MaxBalanceButton.spec.ts src/frontend/src/tests/lib/components/common/MaxBalanceButtonTestHost.svelte
  • npx eslint src/frontend/src/tests/lib/components/common/MaxBalanceButton.spec.ts src/frontend/src/tests/lib/components/common/MaxBalanceButtonTestHost.svelte --max-warnings 0
  • npx vitest run src/frontend/src/tests/lib/components/common/MaxBalanceButton.spec.ts

Notes:

  • npm run test -- src/frontend/src/tests/lib/components/common/MaxBalanceButton.spec.ts is currently blocked before Vitest by an existing unrelated TypeScript error in src/frontend/src/sol/utils/sol-instructions-system.utils.ts (SystemInstruction.CreateAccountAllowPrefund not assignable to never).
  • npm run check:tests is blocked by the same existing unrelated TypeScript error.
  • npm ci is blocked on this checkout by an existing package-lock sync issue (@emnapi/core / @emnapi/runtime missing from lockfile), so dependencies were installed with npm install --package-lock=false to keep this PR test-only.
Open in Web View Automation 

cursoragent and others added 2 commits July 1, 2026 10:10
Co-authored-by: Antonio Ventilii <AntonioVentilii@users.noreply.github.com>
Co-authored-by: Antonio Ventilii <AntonioVentilii@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant