From 8a94c57c2a0d8bf4566d5fcc25571b171f57a667 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 26 Aug 2025 07:03:08 +0200 Subject: [PATCH] =?UTF-8?q?e2e:=20config=20Playwright=20+=20test=20smoke;?= =?UTF-8?q?=20CI:=20installer=20et=20ex=C3=A9cuter=20E2E;=20docs=20TESTING?= =?UTF-8?q?=20mise=20=C3=A0=20jour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 6 ++++++ docs/TESTING.md | 3 +++ package.json | 7 +++++-- playwright.config.ts | 13 +++++++++++++ tests/e2e/smoke.spec.ts | 6 ++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 playwright.config.ts create mode 100644 tests/e2e/smoke.spec.ts diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index f5541a7..6686bd4 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -46,6 +46,12 @@ jobs: - name: Build application run: npm run build + - name: Install Playwright browsers + run: npm run e2e:install + + - name: Run E2E tests + run: npm run test:e2e + - name: Test Docker build (artefacts) run: | docker build -t ihm-client:dist . diff --git a/docs/TESTING.md b/docs/TESTING.md index b625128..cee142c 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -13,17 +13,20 @@ Cette page décrit la stratégie de test, l’outillage et les conventions. Aucu - Test runner: Jest 29 (environnement `jsdom`). - TypeScript: `ts-jest` (transform TS). - Setup global: `tests/setup.ts` (polyfills Web, mocks réseau et stockage). +- E2E: Playwright (Chromium headless) avec `playwright.config.ts`. ## Organisation - `tests/unit/` : tests unitaires ciblés, rapides. - `tests/integration/` : réservé aux interactions WASM/services (à compléter si besoin). +- `tests/e2e/` : tests de bout en bout (smoke tests). ## Exécution - Lancer tous les tests: `npm run test` - Couverture: `npm run test:coverage` - Veille interactive: `npm run test:watch` +- E2E: `npm run e2e:install` puis `npm run test:e2e` ## Conventions diff --git a/package.json b/package.json index fdc169a..1f7dd4e 100755 --- a/package.json +++ b/package.json @@ -17,7 +17,9 @@ "prettify": "prettier --config ./.prettierrc --write \"src/**/*{.ts,.html,.css,.js}\"", "build:dist": "tsc -p tsconfig.build.json", "lint": "prettier -c \"src/**/*{.ts,.html,.css,.js}\"", - "type-check": "tsc -p tsconfig.json --noEmit" + "type-check": "tsc -p tsconfig.json --noEmit", + "e2e:install": "npx playwright install --with-deps", + "test:e2e": "playwright test" }, "keywords": [], "author": "", @@ -40,7 +42,8 @@ "vite-plugin-static-copy": "^1.0.6", "webpack": "^5.90.3", "webpack-cli": "^5.1.4", - "webpack-dev-server": "^5.0.2" + "webpack-dev-server": "^5.0.2", + "@playwright/test": "^1.46.0" }, "dependencies": { "@angular/elements": "^19.0.1", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..98e07ab --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,13 @@ +import { defineConfig, devices } from '@playwright/test'; + +export default defineConfig({ + testDir: './tests/e2e', + timeout: 30000, + use: { + baseURL: 'http://localhost:3000', + headless: true, + }, + projects: [ + { name: 'chromium', use: { ...devices['Desktop Chrome'] } }, + ], +}); diff --git a/tests/e2e/smoke.spec.ts b/tests/e2e/smoke.spec.ts new file mode 100644 index 0000000..d5f8060 --- /dev/null +++ b/tests/e2e/smoke.spec.ts @@ -0,0 +1,6 @@ +import { test, expect } from '@playwright/test'; + +test('charge la page d’accueil', async ({ page }) => { + await page.goto('/'); + await expect(page.locator('#containerId')).toBeVisible(); +});