test: comprehensive contract, backend, socket, and E2E test suites - #215
Open
devfoma wants to merge 3 commits into
Open
test: comprehensive contract, backend, socket, and E2E test suites#215devfoma wants to merge 3 commits into
devfoma wants to merge 3 commits into
Conversation
…scrow The existing test.rs had a corrupted section (~800 lines of scrambled, non-compiling test bodies with mismatched braces and duplicate function signatures) between the early working tests and the intact pause/unpause suite at the end. Reconstructed that section and substantially expanded coverage: unauthorized coordinator-only calls, join edge cases, invalid wager limits, non-whitelisted token rejection, the dispute lifecycle (raise/resolve, 48h timelock blocking resolve/forfeit/claim-refund, duplicate/non-participant disputes), atomic batch resolution edge cases, double-resolution, invalid winner, side-bet edge cases, and overflow-safe fee calculation near i128::MAX. 113 tests total, all cross-checked against the real contract API in lib.rs. Note: this environment's Rust toolchain cannot link natively (missing Windows SDK libs), so `cargo test` could not be executed here. Verified via manual cross-reference against lib.rs's public API and error enum, and structural checks (brace balance, no duplicate test names). CI should be treated as the authoritative pass/fail signal for this file. Refs Kaycee276#85 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…d Socket.io tests
- backend/tests/gameRoutes.test.js: comprehensive Supertest coverage for
every /api/games and /api/escrow endpoint (success paths, validation
errors, 400/404/500 branches, socket broadcast side effects). 51 tests,
all passing.
- backend/tests/socket.test.js: boots the real server.js on an ephemeral
port and drives it with real socket.io-client connections to test
concurrent joins, room-scoped presence/chat/game-update broadcasts, and
room isolation (a client in room B never observes room A's events).
11 tests, all passing, no leaked handles.
- backend/server.js: added `module.exports = { app, server, io }` at the
end (purely additive — no behavior change) so tests can drive the real
Express app and Socket.io server and cleanly tear it down afterward.
- backend/package.json: added socket.io-client as a devDependency.
Refs Kaycee276#86, Kaycee276#87
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…heckmate)
- frontend/e2e/gameplay.spec.ts: two independent browser contexts create,
join, and play a full game through the real GameLobby/ChessBoard UI to a
real checkmate ("Fool's Mate", 1.f3 e5 2.g4 Qh4#), verifying real-time
socket-driven board sync and the correct win/lose banner on both sides.
A second test verifies room isolation (an unrelated game never sees
another game's moves). Both pass consistently.
- frontend/e2e/mock-backend/server.cjs: a small in-memory REST + Socket.io
fixture server matching the real backend's contract (src/api/gameApi.ts,
src/api/socket.ts) exactly. The real backend needs live Supabase/Soroban
credentials this environment doesn't have, so this fixture lets the e2e
suite drive the *real* frontend end to end without them.
- frontend/e2e/stubs/freighterApiStub.ts + vite.config.ts: swaps
@stellar/freighter-api for a deterministic stub, only when VITE_E2E=true
(set by playwright.config.ts) — there's no real Freighter browser
extension under Playwright. The stub reads a fake address from
localStorage that the spec sets via page.addInitScript before navigating,
so wallet "connection" is driven per-context without touching any
application/wallet source.
- Added data-testid attributes to GameLobby (connect/create/join controls)
and ChessBoard (board squares, game code display, game-over banner) —
the only production-file touches, purely additive selectors.
- Fixed a pre-existing syntax bug in SpectatorPage.tsx (`{TrendingUp .../>`
missing its `<`) discovered while getting the app to build for e2e — it
broke the entire Vite bundle since App.tsx imports SpectatorPage eagerly.
- vite.config.ts: excluded e2e/** from Vitest's own test globs (it was
picking up gameplay.spec.ts and failing since it's a Playwright file).
Closes Kaycee276#88
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
@Obiajulu-gif is attempting to deploy a commit to the kaycee276's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@devfoma Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds real, passing test coverage across all four testing domains requested in issues #85-88.
contracts/soroban/contracts/escrow/src/test.rs (#85)
The existing test file had a corrupted section (~800 lines of scrambled, non-compiling test bodies with mismatched braces and duplicate function names) between the early working tests and the intact pause/unpause suite at the end. Reconstructed that section and substantially expanded coverage: unauthorized coordinator-only calls, join edge cases, invalid wager limits, non-whitelisted token rejection, the full dispute lifecycle (raise/resolve, 48h timelock blocking resolve/forfeit/claim-refund, duplicate/non-participant disputes), atomic batch resolution edge cases, double-resolution, invalid winner, side-bet edge cases, and overflow-safe fee calculation near
i128::MAX. 113 tests total, cross-checked against the real contract API inlib.rs(function signatures, error enum). Note: this sandbox's Rust toolchain can't link natively (missing Windows SDK libs), socargo testcouldn't be executed here — verified via manual cross-reference and structural checks instead; CI is the authoritative signal for this file.backend/tests/gameRoutes.test.js (#86)
Comprehensive Supertest coverage for every
/api/gamesand/api/escrowendpoint — success paths, validation errors, 400/404/500 branches, and socket broadcast side effects. 51 tests, all passing.backend/tests/socket.test.js (#87)
Boots the real
server.json an ephemeral port and drives it with realsocket.io-clientconnections to test concurrent joins, room-scoped presence/chat/game-update broadcasts, and room isolation (a client in one room never observes another room's events). 11 tests, all passing, no leaked handles. Required one small additive change tobackend/server.js(module.exports = { app, server, io }at the end — no behavior change) so tests can drive the real server and tear it down cleanly.frontend/e2e/gameplay.spec.ts + playwright.config.ts (#88)
Two independent browser contexts create, join, and play a full game through the real
GameLobby/ChessBoardUI to an actual checkmate ("Fool's Mate": 1.f3 e5 2.g4 Qh4#), verifying real-time socket-driven board sync and the correct win/lose banner on both sides, plus a room-isolation test. Both pass consistently.frontend/e2e/mock-backend/server.cjs: a small in-memory REST + Socket.io fixture matching the real backend's contract exactly — the real backend needs live Supabase/Soroban credentials this environment doesn't have, so this lets the suite drive the real frontend end-to-end without them.frontend/e2e/stubs/freighterApiStub.ts: swaps@stellar/freighter-apifor a deterministic stub, only whenVITE_E2E=true— there's no real Freighter extension under Playwright. Driven per-browser-context vialocalStorage+page.addInitScript.data-testidattributes toGameLobbyandChessBoard(board squares, game code, game-over banner) — the only production-file touches, purely additive selectors.SpectatorPage.tsx({TrendingUp .../>missing its<) that broke the entire Vite bundle, discovered while getting the app to build for e2e.Test plan
cargo generate-lockfile-independent manual verification oftest.rs(structural + API cross-check) — CIcargo testshould confirmnpx jest tests/gameRoutes.test.js— 51/51 passingnpx jest tests/socket.test.js— 11/11 passing, clean exit (no--forceExitneeded)npx playwright test— 2/2 passing, run twice for stabilitynpm run test(Vitest) in frontend still passes after config changesCloses #85
Closes #86
Closes #87
Closes #88
🤖 Generated with Claude Code