Skip to content

[Testing] Build End-to-End Integration Test Infrastructure with Soroban Testnet and Playwright #30

Description

@KarenZita01

Description

The frontend has no infrastructure for end-to-end integration testing with the Soroban smart contracts and backend API. Submitting transactions to a testnet, waiting for confirmations, and verifying state changes requires a sophisticated testing infrastructure. Without this, integration bugs will reach production.

Integration test gaps:

  • No test Stellar account management
  • No test Soroban RPC configuration
  • No automated testnet contract deployment for testing
  • No fixture/seeds for test data
  • No end-to-end flow tests (UI -> API -> Contract)
  • No snapshot testing for contract state
  • No CI integration for testnet testing
  • No test data cleanup automation
  • No wallet mocking for contract interactions
  • No gas cost benchmarking in integration tests

Technical Context & Impact

  • Affected Components/Files: cypress/ or playwright/ (missing), test/ (missing), src/test/ (missing)
  • Impact: Cannot validate full system integration; contract changes may break frontend silently

Step-by-Step Implementation Guide

  1. Create test infrastructure module: src/test/integration/:
    • setupTestEnvironment.ts - Deploys test contracts, funds test accounts
    • testConfig.ts - Test constants (contract IDs, account keys, network RPC)
    • TestWallet.ts - Mock wallet or test Stellar account for automated interactions
  2. Write end-to-end integration tests:
    • registerMeter.spec.ts - Connect wallet -> Register meter -> Verify meter appears in list
    • createStream.spec.ts - Fund gas buffer -> Create stream -> Verify stream active
    • submitReading.spec.ts - Submit meter reading -> Verify reading stored
    • billingFlow.spec.ts - Full billing cycle: submit readings -> bill generated -> payment processed
  3. Set up test Soroban environment: docker-compose.test.yml with:
    • Stellar Quickstart container for local testnet
    • Pre-configured test accounts with funding
    • Contract deployment automation on container start
  4. Add Playwright configuration for integration: playwright.integration.config.ts:
    • Point to local testnet or testnet
    • Configure test accounts with funded wallets
    • Set timeouts longer for blockchain confirmations (30s)
  5. Create test data generators: src/test/factories/:
    • meterFactory.ts - Generate realistic meter data
    • readingFactory.ts - Generate realistic consumption readings
    • streamFactory.ts - Generate stream configurations
  6. Add CI integration test workflow: .github/workflows/integration.yml:
    • Start local Stellar Quickstart
    • Deploy contracts
    • Run Playwright integration tests
    • Tear down environment
  7. Create snapshot testing: Capture contract state after known operations and compare

Verification & Testing Steps

  1. Run npm run test:integration -> verify end-to-end flows pass
  2. Test with local Soroban (docker): start Quickstart, deploy contracts, run tests
  3. Verify test accounts are properly funded before tests
  4. Test cleanup: verify test contracts are destroyed after test suite
  5. Run CI integration workflow -> verify all steps complete successfully
  6. Measure test coverage of user journeys -> >90% of critical paths covered

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions