test(e2e): add post-deploy smoke tests

- Add smoke-post-deploy.spec.ts for health checks
- Add playwright.config.smoke.ts (no webServer)
- Add smoke-post-deploy job to cd.yml (runs when STAGING_URL set)
- Document procedure in e2e/README.md
This commit is contained in:
senke 2026-02-14 22:45:10 +01:00
parent d70f67f2fc
commit c2296ac1c6
4 changed files with 105 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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');
}
});
});

View file

@ -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
});