# Electron E2E Testing Container
# Uses Playwright base image with Xvfb pre-configured
#
# Usage: Copy to your project's e2e/ directory and customize as needed

FROM mcr.microsoft.com/playwright:v1.57.0-noble

# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate

WORKDIR /app

# Copy package files first for layer caching
COPY package.json pnpm-lock.yaml ./

# Install dependencies (including electron)
RUN pnpm install --frozen-lockfile

# Copy source and config files
COPY . .

# Build the app
RUN pnpm build

# Set display and disable GPU for headless Electron
ENV DISPLAY=:99
ENV ELECTRON_DISABLE_GPU=1

# Run tests with Xvfb virtual display
# Override CMD in docker-compose.yml for specific test files
CMD ["sh", "-c", "Xvfb :99 -screen 0 1920x1080x24 -ac &\nsleep 2 && pnpm exec playwright test --reporter=list 2>&1"]
