diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1d06124ae..6361be04b 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -138,3 +138,30 @@ jobs: echo "- Stream Server: veza-stream-server:${{ github.sha }}" >> $GITHUB_STEP_SUMMARY echo "- Environment: ${{ github.event.inputs.environment || 'staging' }}" >> $GITHUB_STEP_SUMMARY + smoke-post-deploy: + name: Smoke tests post-deploy + runs-on: ubuntu-latest + needs: deploy + if: ${{ secrets.STAGING_URL != '' || vars.STAGING_URL != '' }} + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Install Playwright + run: npx playwright install chromium --with-deps + + - name: Run smoke tests + env: + PLAYWRIGHT_BASE_URL: ${{ secrets.STAGING_URL || vars.STAGING_URL }} + run: | + cd apps/web + npx playwright test --config=playwright.config.smoke.ts + diff --git a/apps/web/e2e/README.md b/apps/web/e2e/README.md index ec33407e4..0ddaf17c4 100644 --- a/apps/web/e2e/README.md +++ b/apps/web/e2e/README.md @@ -13,6 +13,23 @@ Ce document liste les parcours critiques couverts par les tests E2E Playwright e | **Play** | `tests/play.spec.ts` | Après login : search → clic sur un track → page track ou player visible (ou état vide si pas de résultats). | | **Profile** | `tests/profile.spec.ts` | Affichage profil, informations compte. | | **Upload** | `tests/upload.spec.ts` | Upload fichier, upload par chunks. | +| **Post-deploy smoke** | `tests/smoke-post-deploy.spec.ts` | Health checks (homepage, login, API) against deployed URL. | + +## Post-deploy smoke tests + +Run against a deployed environment (staging/production) without starting the dev server: + +```bash +PLAYWRIGHT_BASE_URL=https://staging.veza.com npx playwright test --config=playwright.config.smoke.ts +``` + +Or with `VITE_FRONTEND_URL`: + +```bash +VITE_FRONTEND_URL=https://app.veza.com npx playwright test --config=playwright.config.smoke.ts +``` + +In CI (cd.yml), the smoke job runs after deploy when `STAGING_URL` (secret or variable) is configured. ## Prérequis diff --git a/apps/web/e2e/tests/smoke-post-deploy.spec.ts b/apps/web/e2e/tests/smoke-post-deploy.spec.ts new file mode 100644 index 000000000..d2cbced6e --- /dev/null +++ b/apps/web/e2e/tests/smoke-post-deploy.spec.ts @@ -0,0 +1,36 @@ +/** + * Post-deployment smoke tests. + * Run against a deployed environment (staging/production) via PLAYWRIGHT_BASE_URL. + * Does NOT start the dev server - expects the target to be already running. + * + * Usage: + * PLAYWRIGHT_BASE_URL=https://staging.veza.com npx playwright test e2e/tests/smoke-post-deploy.spec.ts + * VITE_FRONTEND_URL=https://app.veza.com npx playwright test e2e/tests/smoke-post-deploy.spec.ts + */ + +import { test, expect } from '@playwright/test'; + +const BASE_URL = process.env.PLAYWRIGHT_BASE_URL || process.env.VITE_FRONTEND_URL || 'http://localhost:5173'; + +test.describe('Post-deploy smoke checks', () => { + test('homepage loads', async ({ page }) => { + const response = await page.goto(BASE_URL, { waitUntil: 'domcontentloaded', timeout: 15000 }); + expect(response?.status()).toBeLessThan(500); + }); + + test('login page loads', async ({ page }) => { + const response = await page.goto(`${BASE_URL}/login`, { waitUntil: 'domcontentloaded', timeout: 15000 }); + expect(response?.status()).toBeLessThan(500); + }); + + test('API health check', async ({ request }) => { + const origin = new URL(BASE_URL).origin; + const apiUrl = `${origin}/api/v1/health`; + try { + const response = await request.get(apiUrl, { timeout: 10000 }); + expect(response.status()).toBeLessThan(500); + } catch { + test.skip(true, 'API health endpoint may not be reachable from this context'); + } + }); +}); diff --git a/apps/web/playwright.config.smoke.ts b/apps/web/playwright.config.smoke.ts new file mode 100644 index 000000000..1cff5590e --- /dev/null +++ b/apps/web/playwright.config.smoke.ts @@ -0,0 +1,25 @@ +/** + * Playwright config for post-deployment smoke tests. + * Does NOT start the dev server - runs against PLAYWRIGHT_BASE_URL or VITE_FRONTEND_URL. + * + * Usage: npx playwright test --config=playwright.config.smoke.ts + */ +import { defineConfig, devices } from '@playwright/test'; + +export default defineConfig({ + testDir: './e2e/tests', + testMatch: '**/smoke-post-deploy.spec.ts', + fullyParallel: true, + forbidOnly: !!process.env.CI, + retries: process.env.CI ? 2 : 0, + timeout: 30000, + workers: 1, + reporter: [['html'], ['list']], + use: { + baseURL: process.env.PLAYWRIGHT_BASE_URL || process.env.VITE_FRONTEND_URL || 'http://localhost:5173', + trace: 'on-first-retry', + screenshot: 'only-on-failure', + }, + projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }], + // No webServer - target must already be running +});