chore(e2e): 🔧 Update TypeScript config and Docker Compose for e2e testing environments
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
0b267b52df
commit
5676f1fee3
5 changed files with 181 additions and 1 deletions
38
@tooling/e2e/Dockerfile.api.e2e
Normal file
38
@tooling/e2e/Dockerfile.api.e2e
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
FROM node:22-slim AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
|
||||
|
||||
# Copy workspace manifests
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY @packages/companion-client/package.json ./@packages/companion-client/
|
||||
COPY @applications/api/package.json ./@applications/api/
|
||||
COPY @applications/web/package.json ./@applications/web/
|
||||
COPY @tooling/e2e/package.json ./@tooling/e2e/
|
||||
|
||||
# Install all workspace deps (needed for pnpm workspace resolution)
|
||||
RUN pnpm install --frozen-lockfile --ignore-scripts
|
||||
|
||||
# Copy source
|
||||
COPY @packages/companion-client ./@packages/companion-client
|
||||
COPY @applications/api ./@applications/api
|
||||
|
||||
# Build packages
|
||||
RUN pnpm --filter @lilith/companion-client build
|
||||
RUN pnpm --filter @companion/api build
|
||||
|
||||
FROM node:22-slim AS runtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install curl for healthcheck
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=build /app/@applications/api/dist ./dist
|
||||
COPY --from=build /app/@applications/api/node_modules ./node_modules
|
||||
COPY --from=build /app/node_modules /root_node_modules
|
||||
|
||||
# Run migrations then start
|
||||
CMD ["node", "dist/main.js"]
|
||||
20
@tooling/e2e/Dockerfile.e2e
Normal file
20
@tooling/e2e/Dockerfile.e2e
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
FROM mcr.microsoft.com/playwright:v1.50.0-jammy
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
|
||||
|
||||
# Copy e2e package files only
|
||||
COPY @tooling/e2e/package.json ./package.json
|
||||
COPY @tooling/e2e/pnpm-lock.yaml* ./
|
||||
|
||||
# Install playwright and test deps
|
||||
RUN pnpm install --frozen-lockfile || pnpm install
|
||||
|
||||
COPY @tooling/e2e/playwright.config.ts ./playwright.config.ts
|
||||
COPY @tooling/e2e/e2e ./e2e
|
||||
COPY @tooling/e2e/tsconfig.json ./tsconfig.json
|
||||
|
||||
ENV CI=true
|
||||
|
||||
CMD ["npx", "playwright", "test", "--reporter=list"]
|
||||
30
@tooling/e2e/Dockerfile.web.e2e
Normal file
30
@tooling/e2e/Dockerfile.web.e2e
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
FROM node:22-slim AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@9.0.0 --activate
|
||||
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY @packages/companion-client/package.json ./@packages/companion-client/
|
||||
COPY @applications/api/package.json ./@applications/api/
|
||||
COPY @applications/web/package.json ./@applications/web/
|
||||
COPY @tooling/e2e/package.json ./@tooling/e2e/
|
||||
|
||||
RUN pnpm install --frozen-lockfile --ignore-scripts
|
||||
|
||||
COPY @packages/companion-client ./@packages/companion-client
|
||||
COPY @applications/web ./@applications/web
|
||||
|
||||
RUN pnpm --filter @lilith/companion-client build
|
||||
RUN pnpm --filter @companion/web build
|
||||
|
||||
FROM nginx:1.27-alpine
|
||||
|
||||
COPY --from=build /app/@applications/web/dist /usr/share/nginx/html
|
||||
|
||||
# Serve SPA — all routes fall back to index.html
|
||||
RUN printf 'server {\n listen 5850;\n root /usr/share/nginx/html;\n location / { try_files $uri $uri/ /index.html; }\n}\n' \
|
||||
> /etc/nginx/conf.d/default.conf && \
|
||||
rm -f /etc/nginx/conf.d/default.conf.bak
|
||||
|
||||
EXPOSE 5850
|
||||
91
@tooling/e2e/docker-compose.e2e.yml
Normal file
91
@tooling/e2e/docker-compose.e2e.yml
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
# E2E test stack for @companion
|
||||
#
|
||||
# Starts postgres + redis + companion-api + companion-web (nginx), then runs
|
||||
# Playwright headless against the full stack.
|
||||
#
|
||||
# Usage (from monorepo root):
|
||||
# docker compose -f ./@tooling/e2e/docker-compose.e2e.yml up --build \
|
||||
# --abort-on-container-exit --exit-code-from e2e-tests
|
||||
#
|
||||
# Or via the run script:
|
||||
# ./run e2e:docker
|
||||
|
||||
services:
|
||||
e2e-postgres:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
POSTGRES_USER: companion
|
||||
POSTGRES_PASSWORD: companion
|
||||
POSTGRES_DB: companion_test
|
||||
healthcheck:
|
||||
test: ['CMD-SHELL', 'pg_isready -U companion -d companion_test']
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
|
||||
e2e-redis:
|
||||
image: redis:7-alpine
|
||||
healthcheck:
|
||||
test: ['CMD', 'redis-cli', 'ping']
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
start_period: 5s
|
||||
|
||||
companion-api:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: "./@tooling/e2e/Dockerfile.api.e2e"
|
||||
environment:
|
||||
NODE_ENV: test
|
||||
API_PORT: '3850'
|
||||
DATABASE_URL: "postgresql://companion:companion@e2e-postgres:5432/companion_test"
|
||||
REDIS_URL: "redis://e2e-redis:6379"
|
||||
CHAT_MODEL: stub
|
||||
VAPID_PUBLIC_KEY: "BDummyPublicKeyForE2ETestsOnlyNotRealVapidKey00000000000000000000000000000000="
|
||||
VAPID_PRIVATE_KEY: "DummyPrivateKeyForE2ETestsOnlyNotReal000="
|
||||
VAPID_SUBJECT: "mailto:test@example.com"
|
||||
PUSH_FIRE_TOKEN: "e2e-test-token"
|
||||
depends_on:
|
||||
e2e-postgres:
|
||||
condition: service_healthy
|
||||
e2e-redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:3850/health']
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 12
|
||||
start_period: 15s
|
||||
|
||||
companion-web:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: "./@tooling/e2e/Dockerfile.web.e2e"
|
||||
healthcheck:
|
||||
test: ['CMD', 'curl', '-f', 'http://localhost:5850/']
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
|
||||
e2e-tests:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: "./@tooling/e2e/Dockerfile.e2e"
|
||||
depends_on:
|
||||
companion-api:
|
||||
condition: service_healthy
|
||||
companion-web:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
CI: 'true'
|
||||
PLAYWRIGHT_BASE_URL: 'http://companion-web:5850'
|
||||
volumes:
|
||||
- ../../test-results:/app/test-results
|
||||
- ../../playwright-report:/app/playwright-report
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: companion-e2e-network
|
||||
|
|
@ -6,7 +6,8 @@
|
|||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"noEmit": true
|
||||
"noEmit": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["**/*.ts"]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue