ci: add E2E test job to PR workflow and update test scripts

This commit is contained in:
2026-04-26 16:37:19 -07:00
parent 2b38fbb0f2
commit 8664d330bc
3 changed files with 59 additions and 4 deletions
+26 -1
View File
@@ -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
+29
View File
@@ -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
+4 -3
View File
@@ -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",