Skip to content

fix(ci): resolve freighter-api CJS crash, BigInt bug, and invalid test fixtures#206

Merged
David1984TK merged 2 commits into
mainfrom
fix/ci-walletkit-metatags
Jun 30, 2026
Merged

fix(ci): resolve freighter-api CJS crash, BigInt bug, and invalid test fixtures#206
David1984TK merged 2 commits into
mainfrom
fix/ci-walletkit-metatags

Conversation

@David1984TK

@David1984TK David1984TK commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • walletKit.js — production-breaking circular-import TDZ fix: CONFIG.NETWORK was read at module top-level, before the contrato.js ↔ walletKit.js circular import could resolve, causing ReferenceError: Cannot access 'CONFIG' before initialization in every real browser context. Moved the read inside initializeKit() so it evaluates lazily. Previously invisible in unit tests (walletKit is always mocked there); surfaced when running Playwright against the live dev server.
  • Vitest unit tests: mock walletKit.js in contrato.test.js, ConectarWallet.test.jsx, and accessibility.test.jsx to stop transitively loading @stellar/freighter-api CJS (which crashed under Vitest's ESM resolver). Rewrote ConectarWallet.test.jsx to match the wallet-kit-based component API.
  • metaTags.js BigInt fix: convert proyecto.meta/aportado to BigInt before arithmetic to avoid TypeError: Cannot mix BigInt and other types.
  • stellar.test.js fixtures: replace invalid-checksum test addresses with real valid G/C-address pairs.
  • Playwright E2E specs: rewrite stale locators in landing.spec.ts and golden-path.spec.ts (removed "Freighter" button references; scoped the navbar "Conectar" locator to avoid strict-mode violations from 3 matching buttons). Fix freighter.ts fixture to seed localStorage.lastWallet='freighter' so walletKit.getConnectedAddress() actually attempts reconnection instead of early-returning null.

Result

All 25 E2E tests pass locally (8 landing + 10 golden-path + 7 filtros). All 124 Vitest unit tests pass.

Test plan

  • Frontend React CI (Vitest) — 124 tests green
  • Playwright E2E CI — 25 tests green

…and invalid test fixtures

- Mock ../stellar/walletKit.js in contrato.test.js, ConectarWallet.test.jsx,
  and accessibility.test.jsx so tests no longer transitively load the real
  @stellar/freighter-api CJS module via stellar-wallets-kit, which crashed
  with a named-export SyntaxError under Vitest's ESM resolution.
- Rewrite ConectarWallet.test.jsx to match the current wallet-kit-based
  component API (getConnectedAddress/openWalletModal) instead of stale
  Freighter-only mocks and a "Freighter" button that no longer exists.
- Fix metaTags.js BigInt/Number mixing TypeError by converting
  proyecto.meta/aportado to BigInt before arithmetic; update metaTags.test.js
  expectations and add a regression test for missing meta/aportado fields.
- Replace invalid checksum fixtures in stellar.test.js with real, valid
  Stellar G-address/C-address pairs so esDireccionValida/esContractIdValido
  tests actually exercise valid-address acceptance.
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bimex-frontend Ready Ready Preview, Comment Jun 30, 2026 6:20pm

…specs

- walletKit.js: move CONFIG.NETWORK read inside initializeKit() so it
  evaluates lazily, after the contrato.js↔walletKit.js circular import
  resolves. Previously this crashed with ReferenceError at module load
  time in every real browser context (production-breaking, invisible in
  unit tests because walletKit is always mocked there).

- e2e/fixtures/freighter.ts: mockFreighterConnected now seeds
  localStorage.lastWallet='freighter' so walletKit.getConnectedAddress()
  doesn't early-return null. mockFreighterDisconnected clears it.
  The underlying postMessage protocol mock was already correct.

- e2e/landing.spec.ts: replace stale "Freighter button" locator with
  a hero-scoped button check; scope the navbar "Conectar" locator to
  nav[aria-label] to avoid strict-mode violations from 3 matching buttons.

- e2e/golden-path.spec.ts: same locator fixes as landing.spec.ts.

Result: all 25 E2E tests (8 landing + 10 golden-path + 7 filtros) pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JfnhH2CghRyxav22rfM8bQ
@David1984TK David1984TK marked this pull request as ready for review June 30, 2026 19:07
@David1984TK David1984TK merged commit a5fcded into main Jun 30, 2026
6 checks passed
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.

2 participants