diff --git a/.gitignore b/.gitignore index e466090..ef4eda6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules/ website/dist/ +playwright-report/ +test-results/ .env .DS_Store diff --git a/e2e/home.spec.js b/e2e/home.spec.js new file mode 100644 index 0000000..fa82216 --- /dev/null +++ b/e2e/home.spec.js @@ -0,0 +1,13 @@ +// Rôle : vérifie en navigateur que le shell principal se charge pour les diagnostics visuels. +import { expect, test } from "@playwright/test"; + +test("home page renders the application shell", async ({ page }) => { + await page.goto("/"); + + await expect(page.locator(".app-shell")).toBeVisible(); + await expect(page.locator("main")).toBeVisible(); + await expect(page).toHaveScreenshot("home.png", { + fullPage: true, + maxDiffPixelRatio: 0.03 + }); +}); diff --git a/e2e/home.spec.js-snapshots/home-chromium-linux.png b/e2e/home.spec.js-snapshots/home-chromium-linux.png new file mode 100644 index 0000000..3391ec2 Binary files /dev/null and b/e2e/home.spec.js-snapshots/home-chromium-linux.png differ diff --git a/package-lock.json b/package-lock.json index 2beb964..adc639d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ }, "devDependencies": { "@eslint/js": "^10.0.1", + "@playwright/test": "^1.62.1", "eslint": "^10.8.1", "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-refresh": "^0.5.4", @@ -857,6 +858,22 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/@playwright/test": { + "version": "1.62.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.62.1.tgz", + "integrity": "sha512-DTcUc8qii+cpHvtOwggMtBRMjKZHXYWdw8syRYu2vtzuq4Wxphqq4NfCs5Zt44L6mA8rfDfj+PHnxFc/FeK6mQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.62.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/@rolldown/binding-android-arm64": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.1.5.tgz", @@ -2328,6 +2345,53 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/playwright": { + "version": "1.62.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.62.1.tgz", + "integrity": "sha512-0M+L3LAD8/nm554LOla9Ayx0j0tmFZ0FBcoQ7F1VuVHpM/XpiC8RcDzBQB8W5+hA8L22THxELzeF+2WcUzvcLg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.62.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.62.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.62.1.tgz", + "integrity": "sha512-wPYSwEBJY9GHraISXqyqtx0na0LpO3XEX7jNDhntbex7tzUS7kLnZsOlFruFJB4Hi/rhDMjXGqHewDZ68nYZVw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/postcss": { "version": "8.5.26", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz", diff --git a/package.json b/package.json index a62bc66..26633c2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "lists:index": "node scripts/generate-list-indexes.mjs", "lint": "eslint .", "check": "node --check server.mjs && node --check vite.config.js && npm run lint && npm run lists:index && npm test && npm run build", - "test": "node --test" + "test": "node --test", + "test:e2e": "playwright test" }, "dependencies": { "@vitejs/plugin-react": "^6.0.3", @@ -21,6 +22,7 @@ }, "devDependencies": { "@eslint/js": "^10.0.1", + "@playwright/test": "^1.62.1", "eslint": "^10.8.1", "eslint-plugin-react-hooks": "^7.1.1", "eslint-plugin-react-refresh": "^0.5.4", diff --git a/playwright.config.js b/playwright.config.js new file mode 100644 index 0000000..2dafc12 --- /dev/null +++ b/playwright.config.js @@ -0,0 +1,25 @@ +// Rôle : configure les diagnostics navigateur Playwright sans les intégrer au check de prod. +import { defineConfig, devices } from "@playwright/test"; + +export default defineConfig({ + testDir: "./e2e", + fullyParallel: true, + reporter: [["list"], ["html", { open: "never" }]], + use: { + baseURL: "http://localhost:5173", + trace: "on-first-retry", + screenshot: "only-on-failure" + }, + webServer: { + command: "npm run dev", + url: "http://localhost:5173", + reuseExistingServer: true, + timeout: 120000 + }, + projects: [ + { + name: "chromium", + use: { ...devices["Desktop Chrome"] } + } + ] +});