fix tests
This commit is contained in:
@@ -62,16 +62,19 @@ Access:
|
||||
### Testing (Docker)
|
||||
The goal of Docker-backed tests is to catch *wiring* issues between Website ↔ API (wrong hostnames/ports/env vars, missing CORS for credentialed requests, etc.) in a deterministic environment.
|
||||
|
||||
- `npm run test:docker:website` - Start a dedicated test stack (ports `3100/3101`) and run Playwright smoke tests against it.
|
||||
- Uses [`docker-compose.test.yml`](docker-compose.test.yml:1).
|
||||
- Runs the Website in Docker and talks to an **API mock** container.
|
||||
- Validates that pages render and that core API fetches succeed (hostname + CORS + routing).
|
||||
- `npm run test:docker:website` - Start API/DB in Docker, run website locally via Playwright, and execute e2e tests.
|
||||
- Uses [`docker-compose.test.yml`](docker-compose.test.yml:1) for API and PostgreSQL.
|
||||
- Playwright starts the website locally via `webServer` config (not in Docker).
|
||||
- Tests run against `http://localhost:3000` (website) talking to `http://localhost:3101` (API).
|
||||
- Validates that pages render, middleware works, and API connections succeed.
|
||||
|
||||
**Important**: The website runs locally (not in Docker) to avoid Next.js SWC/compilation issues in containers.
|
||||
|
||||
Supporting scripts:
|
||||
- `npm run docker:test:deps` - Install monorepo deps inside a reusable Docker volume (one-shot).
|
||||
- `npm run docker:test:up` - Bring up the test stack.
|
||||
- `npm run docker:test:wait` - Wait for `http://localhost:3100` and `http://localhost:3101/health` to be ready.
|
||||
- `npm run docker:test:down` - Tear the test stack down (including volumes).
|
||||
- `npm run docker:test:deps` - Verify monorepo dependencies are installed.
|
||||
- `npm run docker:test:up` - Start API and PostgreSQL containers.
|
||||
- `npm run docker:test:wait` - Wait for API health check at `http://localhost:3101/health`.
|
||||
- `npm run docker:test:down` - Stop containers and clean up.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
@@ -117,16 +120,23 @@ The single source of truth for "what base URL should I use?" is [`getWebsiteApiB
|
||||
#### Test Docker defaults (docker-compose.test.yml)
|
||||
This stack is intended for deterministic smoke tests and uses different host ports to avoid colliding with `docker:dev`:
|
||||
|
||||
- Website: `http://localhost:3100`
|
||||
- API mock: `http://localhost:3101` (maps to container `api:3000`)
|
||||
- Website: `http://localhost:3000` (started by Playwright webServer, not Docker)
|
||||
- API: `http://localhost:3101` (maps to container `api:3000`)
|
||||
- PostgreSQL: `localhost:5433` (maps to container `5432`)
|
||||
- `NEXT_PUBLIC_API_BASE_URL=http://localhost:3101` (browser → host port)
|
||||
- `API_BASE_URL=http://api:3000` (website container → api container)
|
||||
- `API_BASE_URL=http://localhost:3101` (Playwright webServer → host port)
|
||||
|
||||
Important: the test stack's API is a mock server defined inline in [`docker-compose.test.yml`](docker-compose.test.yml:24). It exists to validate Website ↔ API wiring, not domain correctness.
|
||||
**Important**:
|
||||
- The website runs locally via Playwright's `webServer` config to avoid Next.js SWC compilation issues in Docker.
|
||||
- The API is a real TypeORM/PostgreSQL server (not a mock) for testing actual database interactions.
|
||||
- Playwright automatically starts the website server before running tests.
|
||||
|
||||
#### Troubleshooting
|
||||
- If `docker:dev` is running, use `npm run docker:dev:down` before `npm run test:docker:website` to avoid port conflicts.
|
||||
- If Docker volumes get stuck, run `npm run docker:test:down` (it uses `--remove-orphans` + `rm -f`).
|
||||
- **Port conflicts**: If `docker:dev` is running, use `npm run docker:dev:down` before `npm run test:docker:website` to avoid port conflicts (dev uses 3001, test uses 3101).
|
||||
- **Website not starting**: Playwright's webServer may fail if dependencies are missing. Run `npm install` first.
|
||||
- **Cookie errors**: The `WebsiteAuthManager` requires both `url` and `path` properties for cookies. Check Playwright version compatibility.
|
||||
- **Docker volumes stuck**: Run `npm run docker:test:down` (uses `--remove-orphans` + `rm -f`).
|
||||
- **SWC compilation issues**: If website fails to start in Docker, use the local webServer approach (already configured in `playwright.website.config.ts`).
|
||||
|
||||
### API "Real vs In-Memory" Mode
|
||||
|
||||
|
||||
Reference in New Issue
Block a user