Skip to content

feat: build end-to-end integration test infrastructure with Soroban t… - #37

Merged
KarenZita01 merged 1 commit into
EquipChain:mainfrom
Richardkingz2019:test/e2e-soroban-playwright
Jul 30, 2026
Merged

feat: build end-to-end integration test infrastructure with Soroban t…#37
KarenZita01 merged 1 commit into
EquipChain:mainfrom
Richardkingz2019:test/e2e-soroban-playwright

Conversation

@Richardkingz2019

Copy link
Copy Markdown

…estnet and Playwright

Closes #30

What this PR does

Implements the complete end-to-end integration test infrastructure requested in issue #30, covering all seven gap areas identified:

New files added

Test infrastructure (src/test/integration/)

  • estConfig.ts - Full typed config: base URL, Soroban RPC URL, network passphrase, test account secret, contract IDs (meterRegistry, streamManager, billingLedger), tx confirmation timeout, and per-operation gas cost benchmarks (registerMeter, createStream, submitReading, processBilling).
  • setupTestEnvironment.ts - isSorobanRpcHealthy() health probe, captureContractSnapshot() / snapshotsAreDifferent() for snapshot testing, deployTestContracts() placeholder wired to CONTRACT_ID_* env vars, and a LIFO cleanup registry (registerCleanup / runTestCleanup).
  • TestWallet.ts - Mock wallet class that simulates Freighter/Stellar wallet connect/disconnect, signTransaction with gas tracking, getTotalGasUsed(), getLastTransactionGas(), and reset(). Throws on signTransaction when not connected. Includes static fromTestConfig() factory.

Test data factories (src/test/factories/)

  • meterFactory.ts - Typed Meter records (Electric/Water/Gas, Active/ Inactive/Maintenance) with unit-aware reading and consumption values, meterBatch() helper.

eadingFactory.ts - Typed Reading records with txHash, readingTimeSeries() helper that generates an ascending-timestamp series for a given meter.

  • streamFactory.ts - Typed Stream records (Real-time/Batch, Streaming/ Paused/Stopped) with uptime percentages, streamBatch() helper.

E2E specs (src/test/integration/specs/)

egisterMeter.spec.ts - 11 tests covering: page heading, subtitle, Export button, all 8 column headers, meter-001/002/003 rows, Active/ Inactive badges, TestWallet gas benchmark, and Soroban RPC snapshot (skipped when RPC unavailable).

  • createStream.spec.ts - 11 tests covering: page heading, subtitle, Export button, all 7 column headers, stream-001/002/003 rows, Streaming/Paused badges, uptime display, TestWallet gas + disconnect error + reset, and Soroban RPC snapshot.
  • submitReading.spec.ts - 14 tests covering: Dashboard heading, subtitle, Export button, all 6 summary cards (Active Meters, Total Consumption, Active Streams, Pending Bills, Gas Buffer, Monthly Spend), numeric values, trend indicators, readingFactory unit tests, readingTimeSeries ordering, gas benchmark, and Soroban RPC snapshot.
  • �illingFlow.spec.ts - 14 tests covering: Billing heading, subtitle, Export button, View Invoice toggle (show/hide), all 8 column headers, INV-2024-001/002/003 rows, Paid/Pending/Overdue badges, multi-tx gas tracking, wallet transaction history, and Soroban RPC snapshot.

Playwright config (playwright.integration.config.ts)

  • testDir points to specs/, 90s test timeout, 15s expect timeout, chromium only, webServer auto-starts Next.js dev server, trace on failure, output to test-results/playwright-integration/.

Docker test environment (docker-compose.test.yml)

  • stellar/quickstart:testing with --local --enable-stellar-rpc, health-checked on port 8000/rpc.

CI workflow (.github/workflows/integration.yml)

  • Triggers on pull_request to main and workflow_dispatch.
  • Spins up stellar service container, installs deps, installs Playwright chromium, runs npm run test:integration with correct env vars.

Supporting changes

  • package.json - Added @playwright/test ^1.52.0 devDependency and test:integration script.
  • .gitignore - Added /test-results and /playwright-report.
  • README.md - Added Integration Testing section with docker + npm run commands for local usage (bash and PowerShell).

Verification

  • All TypeScript files pass tsc with zero diagnostics (verified via IDE language server).
  • All Soroban-dependent test blocks are gated behind isSorobanRpcHealthy() and self-skip when the RPC is unavailable, so the standard CI lint/build job is not affected.
  • UI-only tests (heading, table headers, badge text, toggle interactions) run against the live Next.js dev server and assert on real DOM output from the existing page components.
  • Gas benchmark assertions use configurable thresholds from testConfig.ts, injectable via environment variables.

closes #30

…estnet and Playwright

Closes EquipChain#30

## What this PR does

Implements the complete end-to-end integration test infrastructure
requested in issue EquipChain#30, covering all seven gap areas identified:

### New files added

**Test infrastructure (src/test/integration/)**
- 	estConfig.ts - Full typed config: base URL, Soroban RPC URL, network
  passphrase, test account secret, contract IDs (meterRegistry,
  streamManager, billingLedger), tx confirmation timeout, and per-operation
  gas cost benchmarks (registerMeter, createStream, submitReading,
  processBilling).
- setupTestEnvironment.ts - isSorobanRpcHealthy() health probe,
  captureContractSnapshot() / snapshotsAreDifferent() for snapshot testing,
  deployTestContracts() placeholder wired to CONTRACT_ID_* env vars, and a
  LIFO cleanup registry (registerCleanup / runTestCleanup).
- TestWallet.ts - Mock wallet class that simulates Freighter/Stellar wallet
  connect/disconnect, signTransaction with gas tracking, getTotalGasUsed(),
  getLastTransactionGas(), and reset(). Throws on signTransaction when not
  connected. Includes static fromTestConfig() factory.

**Test data factories (src/test/factories/)**
- meterFactory.ts - Typed Meter records (Electric/Water/Gas, Active/
  Inactive/Maintenance) with unit-aware reading and consumption values,
  meterBatch() helper.
- 
eadingFactory.ts - Typed Reading records with txHash, readingTimeSeries()
  helper that generates an ascending-timestamp series for a given meter.
- streamFactory.ts - Typed Stream records (Real-time/Batch, Streaming/
  Paused/Stopped) with uptime percentages, streamBatch() helper.

**E2E specs (src/test/integration/specs/)**
- 
egisterMeter.spec.ts - 11 tests covering: page heading, subtitle,
  Export button, all 8 column headers, meter-001/002/003 rows, Active/
  Inactive badges, TestWallet gas benchmark, and Soroban RPC snapshot
  (skipped when RPC unavailable).
- createStream.spec.ts - 11 tests covering: page heading, subtitle,
  Export button, all 7 column headers, stream-001/002/003 rows,
  Streaming/Paused badges, uptime display, TestWallet gas + disconnect
  error + reset, and Soroban RPC snapshot.
- submitReading.spec.ts - 14 tests covering: Dashboard heading, subtitle,
  Export button, all 6 summary cards (Active Meters, Total Consumption,
  Active Streams, Pending Bills, Gas Buffer, Monthly Spend), numeric values,
  trend indicators, readingFactory unit tests, readingTimeSeries ordering,
  gas benchmark, and Soroban RPC snapshot.
- �illingFlow.spec.ts - 14 tests covering: Billing heading, subtitle,
  Export button, View Invoice toggle (show/hide), all 8 column headers,
  INV-2024-001/002/003 rows, Paid/Pending/Overdue badges, multi-tx gas
  tracking, wallet transaction history, and Soroban RPC snapshot.

**Playwright config (playwright.integration.config.ts)**
- testDir points to specs/, 90s test timeout, 15s expect timeout,
  chromium only, webServer auto-starts Next.js dev server, trace on failure,
  output to test-results/playwright-integration/.

**Docker test environment (docker-compose.test.yml)**
- stellar/quickstart:testing with --local --enable-stellar-rpc,
  health-checked on port 8000/rpc.

**CI workflow (.github/workflows/integration.yml)**
- Triggers on pull_request to main and workflow_dispatch.
- Spins up stellar service container, installs deps, installs Playwright
  chromium, runs npm run test:integration with correct env vars.

**Supporting changes**
- package.json - Added @playwright/test ^1.52.0 devDependency and
  test:integration script.
- .gitignore - Added /test-results and /playwright-report.
- README.md - Added Integration Testing section with docker + npm run
  commands for local usage (bash and PowerShell).

## Verification

- All TypeScript files pass tsc with zero diagnostics (verified via IDE
  language server).
- All Soroban-dependent test blocks are gated behind isSorobanRpcHealthy()
  and self-skip when the RPC is unavailable, so the standard CI lint/build
  job is not affected.
- UI-only tests (heading, table headers, badge text, toggle interactions)
  run against the live Next.js dev server and assert on real DOM output from
  the existing page components.
- Gas benchmark assertions use configurable thresholds from testConfig.ts,
  injectable via environment variables.
@KarenZita01
KarenZita01 merged commit 24a397a into EquipChain:main Jul 30, 2026
3 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.

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

3 participants