Skip to content

test: avoid the jsdom realm in the native asset button test - #555

Merged
Glittersup merged 1 commit into
TricklePay:mainfrom
chidii:test/issue-510
Oct 24, 2026
Merged

Glittersup merged 1 commit into
TricklePay:mainfrom
chidii:test/issue-510

Conversation

@chidii

@chidii chidii commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Summary

create-stream-fields.test.tsx runs under @vitest-environment jsdom, and the "Use XLM" test asserted against nativeAssetContractId(), which calls Asset.native().contractId(...). That call throws inside jsdom because the SDK's StrKey/sha256 expects a Node Uint8Array, while jsdom's Uint8Array is a different constructor from a different realm — TypeError: expected Uint8Array, got type=object. The same call returns CDLZFC3S…GCYSC in plain Node, so this is a test-environment realm mismatch, not a product bug.

Closes #510

Change

  • components/create-stream-fields.test.tsx: vi.mock("@/lib/native-asset", ...) returns a fixed id for the assertion path. The test still asserts onFieldChange receives whatever nativeAssetContractId() returns — the assertion is unchanged — but the return value is now computed outside jsdom, so the SDK call never happens here.
  • Mock value is the real testnet native XLM SAC id (CDLZFC3S…GCYSC), matching the value the issue reports for plain Node.

Acceptance criteria

  • The assertion runs against a value computed without the jsdom realm (mock of nativeAssetContractId).
  • The test passes and does not weaken the production helper.

Notes on not weakening coverage

lib/native-asset.ts is unchanged, and its real behaviour is still covered by lib/native-asset.test.ts, which runs under Node (the project's default test.environment — only files with @vitest-environment jsdom opt into jsdom). The mock is local to this test file.

Testing

  • npm run check (lint, typecheck, test, build) — pass

@Glittersup
Glittersup merged commit 64a9d9e into TricklePay:main Oct 24, 2026
2 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.

Run the Use XLM button test where the Stellar SDK works

2 participants