Skip to content

test: add SessionProvider unit and WASM integration tests#2435

Open
kronosapiens wants to merge 1 commit intomainfrom
kronosapiens/fix-session-registration
Open

test: add SessionProvider unit and WASM integration tests#2435
kronosapiens wants to merge 1 commit intomainfrom
kronosapiens/fix-session-registration

Conversation

@kronosapiens
Copy link
Contributor

Summary

Adds comprehensive test coverage for SessionProvider class with two test suites:

  1. Unit Tests (session-provider.test.ts): 16 focused Jest tests covering pure TypeScript logic—constructor validation, policy subset validation, session ingestion from redirects, and selective disconnect cleanup. No WASM or network dependencies.

  2. WASM Integration Tests (wasm-integration.test.mjs): 15 tests exercising the real @cartridge/controller-wasm binary to verify policy conversion and session account construction end-to-end.

Also adds test:wasm npm script for standalone Node.js WASM testing.

Test Coverage

  • Constructor validation when policies/preset missing
  • validatePoliciesSubset() logic: subset matching, address/method rejection, authorization validation, message policies
  • ingestSessionFromRedirect(): base64 decoding, padding correction, malformed payload handling, required field validation
  • disconnect(): selective localStorage removal
  • WASM round-trip: single/multiple contracts, approval policies, address normalization, policy ordering stability

All tests pass. No regressions to existing tests.

@vercel
Copy link

vercel bot commented Feb 21, 2026

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

Project Deployment Actions Updated (UTC)
controller-example-next Ready Ready Preview Feb 21, 2026 3:00pm
keychain Ready Ready Preview Feb 21, 2026 3:00pm
keychain-storybook Ready Ready Preview Feb 21, 2026 3:00pm

Request Review

Add focused unit tests for SessionProvider's core logic (validatePoliciesSubset, ingestSessionFromRedirect, constructor validation, disconnect selective removal).
Add WASM integration tests exercising real binary with toWasmPolicies round-trip, policy ordering stability, and address normalization.
Both test suites pass with all existing tests (67 Jest + 15 WASM).
Includes test:wasm npm script for standalone Node.js WASM testing.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.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