From c4e88d3658f60cf1b92b3aefeea4b41a29d653c7 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Sun, 26 Apr 2026 16:37:19 -0700 Subject: [PATCH] ci: add E2E test job to PR workflow and update test scripts --- .gitea/workflows/pr.yml | 27 ++++++++++++++++++++++++++- justfile | 29 +++++++++++++++++++++++++++++ package.json | 7 ++++--- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/pr.yml b/.gitea/workflows/pr.yml index 099b130..0d9bfbc 100644 --- a/.gitea/workflows/pr.yml +++ b/.gitea/workflows/pr.yml @@ -27,9 +27,34 @@ jobs: - name: Run unit tests run: bun test src/__tests__/unit/ src/__tests__/*.test.tsx src/__tests__/auth-simple.test.ts - analyze-bump-type: + e2e-tests: runs-on: ubuntu-latest needs: unit-tests + container: + image: docker.notsosm.art/euchre-camp/ci-base:latest + options: --user root + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: bun install + + - name: Generate Prisma client + run: bun x prisma generate + env: + DATABASE_URL: postgresql://user:pass@localhost:5432/dummy + + - name: Run E2E tests + run: npm run test:acceptance:cucumber:prod + env: + DATABASE_URL: postgresql://euchre_camp:${{ secrets.DB_PASSWORD }}@dhg.lol:5432/euchre_camp_dev + DATABASE_PROVIDER: postgresql + + analyze-bump-type: + runs-on: ubuntu-latest + needs: e2e-tests steps: - name: Checkout code diff --git a/justfile b/justfile index ce44c9a..5de1e11 100644 --- a/justfile +++ b/justfile @@ -83,6 +83,35 @@ test-acceptance-postgres: @echo "Stopping Docker containers..." docker compose down +# Run Cucumber e2e tests with SQLite +test-cucumber-sqlite: + @echo "Running Cucumber e2e tests with SQLite..." + DATABASE_PROVIDER=sqlite DATABASE_URL=file:./prisma/ci.db npm run test:acceptance:cucumber + +# Run Cucumber e2e tests with PostgreSQL (uses .env.development) +test-cucumber-postgres: + @echo "Running Cucumber e2e tests with PostgreSQL..." + npm run test:acceptance:cucumber + +# Run Cucumber e2e tests with PostgreSQL against production build +# This is more reliable than dev server (no HMR, faster API responses) +test-cucumber-postgres-prod: + @echo "Building application for production..." + bun run build + @echo "Starting production server in background..." + bun run start > /tmp/next-prod.log 2>&1 & + SERVER_PID=$$! + @echo "Waiting for server to be ready..." + sleep 15 + @echo "Running Cucumber e2e tests against production build..." + npm run test:acceptance:cucumber || true + @echo "Stopping production server..." + kill $$SERVER_PID 2>/dev/null || true + @echo "Tests completed." + +# Run all e2e tests (both Playwright and Cucumber) +test-e2e: test-acceptance-sqlite test-cucumber-sqlite + # Run database migrations (Prisma) migrate: npx prisma migrate dev diff --git a/package.json b/package.json index 282b3b9..b2d2afb 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,10 @@ "test:unit:sequential": "bun test src/__tests__/unit/ --max-concurrency=1", "test:acceptance": "bun x playwright test e2e/", "test:acceptance:headed": "bun x playwright test e2e/ --headed", - "test:acceptance:cucumber": "bun cucumber-js --config e2e/cucumber/cucumber.config.ts", - "test:acceptance:cucumber:pretty": "bun cucumber-js --config e2e/cucumber/cucumber.config.ts --format pretty:cucumber-pretty", - "cucumber": "bun cucumber-js --config e2e/cucumber/cucumber.config.ts", + "test:acceptance:cucumber": "DATABASE_URL=$(grep DATABASE_URL .env.development | cut -d'=' -f2 | tr -d '\"') DATABASE_PROVIDER=postgresql bun cucumber-js --config e2e/cucumber/cucumber.config.ts", + "test:acceptance:cucumber:pretty": "DATABASE_URL=$(grep DATABASE_URL .env.development | cut -d'=' -f2 | tr -d '\"') DATABASE_PROVIDER=postgresql bun cucumber-js --config e2e/cucumber/cucumber.config.ts --format pretty:cucumber-pretty", + "test:acceptance:cucumber:prod": "bun run build && (DATABASE_URL=${DATABASE_URL:-$(grep DATABASE_URL .env.development | cut -d'=' -f2 | tr -d '\"')} DATABASE_PROVIDER=${DATABASE_PROVIDER:-postgresql} bun run start & SERVER_PID=$! && sleep 15 && npm run test:acceptance:cucumber; kill $SERVER_PID 2>/dev/null || true)", + "cucumber": "DATABASE_URL=$(grep DATABASE_URL .env.development | cut -d'=' -f2 | tr -d '\"') DATABASE_PROVIDER=postgresql bun cucumber-js --config e2e/cucumber/cucumber.config.ts", "db:switch": "bun run scripts/switch-database.js", "db:setup-postgres": "bun run scripts/setup-postgres.js", "db:setup-dev": "bun run scripts/setup-postgres.js",