diff --git a/.github/workflows/tests.yml b/.github/workflows/client-e2e-tests.yml similarity index 57% rename from .github/workflows/tests.yml rename to .github/workflows/client-e2e-tests.yml index 8deb2d5..af65a76 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/client-e2e-tests.yml @@ -1,25 +1,10 @@ -name: Tests +name: Client e2e tests on: pull_request: jobs: - client-test-unit: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x] - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npm run test:unit -w client - - client-test-e2e: + client-e2e-tests: runs-on: ubuntu-latest env: LANDBOT_CONFIG_URL: ${{ secrets.LANDBOT_CONFIG_URL }} diff --git a/.github/workflows/client-unit-tests.yml b/.github/workflows/client-unit-tests.yml new file mode 100644 index 0000000..9ef7819 --- /dev/null +++ b/.github/workflows/client-unit-tests.yml @@ -0,0 +1,20 @@ +name: Client unit tests + +on: + pull_request: + +jobs: + client-unit-tests: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20.x] + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run test:unit -w client diff --git a/.github/workflows/lighthouse-desktop.yml b/.github/workflows/lighthouse-desktop.yml new file mode 100644 index 0000000..79fb49b --- /dev/null +++ b/.github/workflows/lighthouse-desktop.yml @@ -0,0 +1,32 @@ +name: Lighthouse desktop + +on: + pull_request: + +jobs: + lighthouse-desktop: + runs-on: ubuntu-latest + env: + LANDBOT_CONFIG_URL: ${{ secrets.LANDBOT_CONFIG_URL }} + PUBLIC_BORIS_CMS_URL: ${{ secrets.PUBLIC_BORIS_CMS_URL }} + strategy: + matrix: + node-version: [20.x] + runs-on: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build -w client + - run: npm run preview -w client & npm run lighthouse-desktop -w client + - name: Upload Lighthouse Report + if: always() + uses: actions/upload-artifact@v4 + with: + include-hidden-files: true + name: lighthouse-report-${{ matrix.runs-on }} + path: ${{ github.workspace }}/client/.lighthouseci/* diff --git a/.github/workflows/lighthouse-mobile.yml b/.github/workflows/lighthouse-mobile.yml new file mode 100644 index 0000000..141124d --- /dev/null +++ b/.github/workflows/lighthouse-mobile.yml @@ -0,0 +1,32 @@ +name: Lighthouse mobile + +on: + pull_request: + +jobs: + lighthouse-mobile: + runs-on: ubuntu-latest + env: + LANDBOT_CONFIG_URL: ${{ secrets.LANDBOT_CONFIG_URL }} + PUBLIC_BORIS_CMS_URL: ${{ secrets.PUBLIC_BORIS_CMS_URL }} + strategy: + matrix: + node-version: [20.x] + runs-on: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build -w client + - run: npm run preview -w client & npm run lighthouse-mobile -w client + - name: Upload Lighthouse Report + if: always() + uses: actions/upload-artifact@v4 + with: + include-hidden-files: true + name: lighthouse-report-${{ matrix.runs-on }} + path: ${{ github.workspace }}/client/.lighthouseci/* diff --git a/.gitignore b/.gitignore index 8b57e12..32780bd 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ node_modules /client/.svelte-kit /client/test-results/ /client/e2e/**/.setup/ +/client/.lighthouseci/ # Logs logs diff --git a/.talismanrc b/.talismanrc deleted file mode 100644 index 3ec884c..0000000 --- a/.talismanrc +++ /dev/null @@ -1,38 +0,0 @@ -fileignoreconfig: -- filename: client/.env.example - checksum: 5485a66c90dd5c80f3ff88ca6c3fd44c7d3b12e8fe4734aa94d9f1fcd4a22863 -version: "" - -fileignoreconfig: -- filename: client/.env.example - checksum: c4c0d731e14cffee9b695b7786f330e12fbf51661bbbbe17df45321795d64a08 -version: "" - -fileignoreconfig: -- filename: package-lock.json - checksum: 215df59241d790f987f59357830b074da927931017b6ff77eb1b32c7e1ce1437 -version: "" - -fileignoreconfig: -- filename: package-lock.json - checksum: 4288d656c8b0efc4302057ba71a86301971a291bc76ed77d6db36f1ed5486652 -version: "" - -fileignoreconfig: -- filename: client/src/lib/components/simuler-mon-eligibilite/table.svelte - checksum: 2db7880d3b1ced627761752d475fe0ad7bc68c3c9ed79a766012a22baf32ca01 -version: "" - -fileignoreconfig: -- filename: client/src/routes/tout-savoir-sur-le-BRS/je-cherche-des-financements/+page.svelte - checksum: 16ecdc38ed5fe2abd75a0359ac447d8251ce7280943c7c3e3842e222e3de0c96 -- filename: client/src/routes/tout-savoir-sur-le-BRS/je-deviens-proprietaire/+page.svelte - checksum: f2bdb584c881d16a7735c9f870df540891237b065a7700b9d6bd3abcd50fcde1 -- filename: client/src/routes/tout-savoir-sur-le-BRS/je-decouvre-le-dispositif/+page.svelte - checksum: ace9ada5a101d07062663b1b6440623e25d8cea32b3fe79a6dae0b1f9f1a0070 -version: "" - -fileignoreconfig: -- filename: client/src/routes/tout-savoir-sur-le-bail-reel-solidaire-brs/(etapes)/je-decouvre-le-dispositif/content.ts - checksum: 29b885be0c304ce70930fdfbfc81c1635173f6e9da538a0bb568ab82e0814d69 -version: "" diff --git a/client/.lighthouse-desktop.json b/client/.lighthouse-desktop.json new file mode 100644 index 0000000..82a6e81 --- /dev/null +++ b/client/.lighthouse-desktop.json @@ -0,0 +1,17 @@ +{ + "ci": { + "collect": { + "url": ["http://localhost:4173/"], + "numberOfRuns": 1, + "settings": { + "preset": "desktop" + } + }, + "assert": { + "assertions": { + "categories:performance": ["error", { "minScore": 0.8 }], + "categories:accessibility": ["error", { "minScore": 1 }] + } + } + } +} diff --git a/client/.lighthouse-mobile.json b/client/.lighthouse-mobile.json new file mode 100644 index 0000000..44dd076 --- /dev/null +++ b/client/.lighthouse-mobile.json @@ -0,0 +1,14 @@ +{ + "ci": { + "collect": { + "url": ["http://localhost:4173"], + "numberOfRuns": 1 + }, + "assert": { + "assertions": { + "categories:performance": ["error", { "minScore": 0.5 }], + "categories:accessibility": ["error", { "minScore": 1 }] + } + } + } +} diff --git a/client/package.json b/client/package.json index ce7a8fb..4cbe44c 100644 --- a/client/package.json +++ b/client/package.json @@ -17,21 +17,26 @@ "lint": "prettier --check . && eslint .", "format": "prettier --write .", "test:e2e": "playwright test", - "test:unit": "vitest" + "test:unit": "vitest", + "lighthouse-mobile": "lhci autorun --config=./.lighthouse-mobile.json", + "lighthouse-desktop": "lhci autorun --config=./.lighthouse-desktop.json" }, "devDependencies": { "@csstools/postcss-global-data": "^3.0.0", + "@fullhuman/postcss-purgecss": "^7.0.2", "@gouvfr/dsfr": "^1.12.1", + "@lhci/cli": "^0.14.0", "@playwright/test": "^1.28.1", "@sveltejs/adapter-node": "^5.2.9", "@sveltejs/kit": "^2.0.0", "@sveltejs/vite-plugin-svelte": "^4.0.0-next.6", + "cssnano": "^7.0.6", "eslint-plugin-svelte": "^2.36.0", "globals": "^15.0.0", "husky": "^9.1.6", "nanoid": "^5.0.8", - "postcss": "^8.4.49", "papaparse": "^5.4.1", + "postcss": "^8.4.49", "postcss-custom-media": "^11.0.5", "prettier-plugin-svelte": "^3.1.2", "svelte": "^5.16.6", diff --git a/client/postcss.config.js b/client/postcss.config.js index f96d789..16b1a64 100644 --- a/client/postcss.config.js +++ b/client/postcss.config.js @@ -1,11 +1,27 @@ import postcssCustomMedia from 'postcss-custom-media'; import postcssGlobalData from '@csstools/postcss-global-data'; +import { purgeCSSPlugin } from '@fullhuman/postcss-purgecss'; +import cssNano from 'cssnano'; -export default { - plugins: [ - postcssGlobalData({ - files: ['src/assets/styles/_vars.css'], +const plugins = [ + postcssGlobalData({ + files: ['src/assets/styles/_vars.css'], + }), + postcssCustomMedia(), + cssNano({ + preset: 'default', + }), +]; + +if (process.env.NODE_ENV !== 'development') { + plugins.push( + purgeCSSPlugin({ + content: ['./src/**/*.svelte', './src/**/*.html'], + safelist: [/svelte-/, /placement/, /modal/], }), - postcssCustomMedia(), - ], + ); +} + +export default { + plugins, }; diff --git a/client/src/assets/styles/main.css b/client/src/assets/styles/main.css index dc5e501..1a1bf97 100644 --- a/client/src/assets/styles/main.css +++ b/client/src/assets/styles/main.css @@ -26,3 +26,7 @@ html { .color-blue-primary { color: var(--color-blue-primary); } + +.background-color-white { + background-color: white; +} diff --git a/client/src/lib/components/common/Accordion.svelte b/client/src/lib/components/common/Accordion.svelte index 61d5bf2..4fbf202 100644 --- a/client/src/lib/components/common/Accordion.svelte +++ b/client/src/lib/components/common/Accordion.svelte @@ -1,4 +1,5 @@ +