diff --git a/.github/workflows/e2e-staging.yml b/.github/workflows/e2e-staging.yml new file mode 100644 index 0000000..47ec5ae --- /dev/null +++ b/.github/workflows/e2e-staging.yml @@ -0,0 +1,49 @@ +name: Staging E2E Tests + +# Runs only on direct pushes to main (i.e. after a PR is merged). +# Not triggered on pull_request to avoid running against staging on every PR. +on: + push: + branches: + - main + paths: + - 'frontend/**' + +jobs: + e2e-staging: + name: Playwright — Staging + runs-on: ubuntu-latest + + defaults: + run: + working-directory: frontend + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Install Playwright browsers + run: npx playwright install --with-deps chromium + + - name: Run staging E2E suite + run: npx playwright test --project=staging + env: + STAGING_URL: ${{ secrets.STAGING_URL }} + CI: 'true' + + - name: Upload Playwright report + if: always() + uses: actions/upload-artifact@v4 + with: + name: playwright-staging-report + path: frontend/playwright-report/ + retention-days: 14 diff --git a/frontend/playwright.config.ts b/frontend/playwright.config.ts index 424cbf4..c86e157 100644 --- a/frontend/playwright.config.ts +++ b/frontend/playwright.config.ts @@ -25,29 +25,51 @@ export default defineConfig({ video: 'retain-on-failure', }, projects: [ + // ------------------------------------------------------------------ + // Local / PR projects (default) + // ------------------------------------------------------------------ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, + testIgnore: isStaging ? '**' : undefined, }, { name: 'firefox', use: { ...devices['Desktop Firefox'] }, + testIgnore: isStaging ? '**' : undefined, }, { name: 'webkit', use: { ...devices['Desktop Safari'] }, + testIgnore: isStaging ? '**' : undefined, }, { name: 'mobile-chrome', use: { ...devices['Pixel 5'] }, + testIgnore: isStaging ? '**' : undefined, }, { name: 'mobile-safari', use: { ...devices['iPhone 12'] }, + testIgnore: isStaging ? '**' : undefined, }, { name: 'tablet', use: { ...devices['iPad Pro'] }, + testIgnore: isStaging ? '**' : undefined, + }, + + // ------------------------------------------------------------------ + // Staging project — activated when STAGING_URL is set. + // Runs against a real API; no local web server is started. + // ------------------------------------------------------------------ + { + name: 'staging', + use: { + ...devices['Desktop Chrome'], + baseURL: process.env.STAGING_URL, + }, + testIgnore: isStaging ? undefined : '**', }, // Staging project: runs only the market-creation spec against the staging URL. // Activated when BASE_URL points to staging (or STAGING=true).