2.9 KiB
Integration Tests (Initialization Flow)
This document describes the end-to-end integration test that exercises the gateway, game-api, and game-engine initialization flow.
Scope
The initialization integration test validates:
- database reset and schema readiness
- bootstrap admin creation
- demo user provisioning (10 accounts)
- scenario install for
chewithscenario_2and 1-minute ticks - deterministic seeding (via env)
- auto admin general creation
- general creation for demo users with constrained city selection
- reserved turn submission (uprising, founding, appointment)
- running three turns and validating founding outcomes
The test runs real Postgres and Redis, and talks to the API servers via tRPC.
Files
tools/integration-tests/test/initialization.test.tstools/integration-tests/vitest.config.ts
Prerequisites
- Postgres and Redis are running and reachable.
.env.ciis present at the repo root and contains:- Postgres and Redis connection settings.
GAME_TOKEN_SECRET,KAKAO_REST_KEY,KAKAO_REDIRECT_URIGATEWAY_BOOTSTRAP_TOKENGATEWAY_API_HOST,GATEWAY_API_PORT,GAME_API_HOST,GAME_API_PORTGATEWAY_TRPC_PATH,GAME_TRPC_PATH,GAME_API_EVENTS_PATHPROFILE=che,SCENARIO=2
pnpm installandpnpm buildhave already completed.
Safety
The test truncates the public and che schemas and flushes Redis. Use a
dedicated CI/local database and Redis instance.
Running
Use the root helper script:
pnpm test:integration
Or run the package script directly:
pnpm --filter @sammo-ts/integration-tests test:integration
Environment Flags
INTEGRATION_WORLD_SEED: injected into world meta ashiddenSeedfor deterministic RNG.INTEGRATION_JOIN_ALLOW_CITY=true: allows test-only city selection when creating generals (still restricted to level 5/6 cities).
These are loaded from .env.ci and can be overridden per run.
The HTTP lifecycle fixtures explicitly set
localAccountGeneralCreationGraceDays on their disposable profile before
issuing game sessions for locally provisioned users. This keeps the test on the
same profile-policy path as production instead of bypassing Kakao eligibility in
the game API. The PM2 orchestrator fixture also uses a temporary PM2_HOME and
deletes all five profile roles before stopping that dedicated daemon. Cleanup
verifies the temporary daemon PID and command line, waits for its exit, and only
then removes PM2_HOME, so it does not share the operator's global PM2 daemon
or retain processes and paths from an older worktree.
Notes
auth.bootstrapLocalonly works when no users exist; the test resets the DB to satisfy this precondition.profiles.installNowseeds the scenario and auto-creates the admin general.- The test runs turn processing via administrator-authorized
turnDaemon.runand validates founding rules at the third turn.