From b36bb36f6874222d8b52793b75580c5f4f1b052e Mon Sep 17 00:00:00 2001 From: Emmanuel DEMEY Date: Mon, 14 Oct 2024 16:11:48 +0100 Subject: [PATCH] feat: bump Vitest dependency (#152) * feat: bump Vitest dependency * fix: remove --coverage * feat: update ESLint and Prettier configuration. And enabled them on the CI * fix: init playwright * feat: exclude playwright from vitest * feat: add HTTPS for playwright * fix: change configuration for playwright * fix: add security disable for playwright * fix: change https port * fix: change https port * fix: increate UDP size * fix: try sudo * fix: remove caddy * fix: use NPX for playwright * feat: clone queen * feat: try to clone two repositories * fix: github action * fix: change https port * fix: remove .pem file * fix: solve eslint issues * fix: revert fix * fix: remove unused parameter * fix: review playwright configuration --- .github/workflows/build.yml | 3 +- .github/workflows/playwright.yml | 39 + .gitignore | 5 + README.md | 23 + eslint.config.mjs | 36 + index.html | 5 +- package.json | 66 +- playwright.config.ts | 87 + public/manifest.json | 2 +- src/App.jsx | 2 +- src/SwipeableTabs.jsx | 2 +- src/app.css | 6 +- src/i18n/waitingMessage.js | 2 +- src/pages/Home.jsx | 2 +- src/pages/QueenPage.jsx | 2 +- src/pages/ResetData.jsx | 24 +- src/pages/SuiviPage.jsx | 2 +- src/service-worker.js | 2 - src/serviceWorkerRegistration.js | 3 - src/ui/Accordion.jsx | 1 - src/ui/FieldRow.jsx | 96 +- src/ui/Fields/CommentField.jsx | 2 - src/ui/Header.jsx | 2 +- src/ui/Header/NetworkStatus.jsx | 4 +- src/ui/Header/SynchronizeButton.jsx | 2 +- src/ui/Questionnaire/CustomChip.jsx | 4 +- src/ui/Questionnaire/HousingResident.jsx | 1 - src/ui/Questionnaire/Icons/CircleIcon.jsx | 14 +- src/ui/Questionnaire/Icons/DisturbIcon.jsx | 12 +- src/ui/Questionnaire/Icons/EditIcon.jsx | 9 +- src/ui/Questionnaire/Icons/TimeIcon.jsx | 15 +- src/ui/Questionnaire/PersonList.jsx | 6 +- src/ui/Questionnaire/QuestionnaireCard.jsx | 2 +- src/ui/Questionnaire/Questionnaires.jsx | 1 - src/ui/RadioLine.jsx | 1 - src/ui/SearchField.jsx | 1 - src/ui/Select.jsx | 3 +- src/ui/Stats/CampaignProgress.jsx | 1 - src/ui/Stats/CampaignProgressPieChart.jsx | 10 +- src/ui/Stats/PieChart.jsx | 5 +- src/ui/StatusChip.jsx | 1 - src/ui/SurveyCard.jsx | 1 - src/ui/SurveyUnit/AddressCard.jsx | 1 - src/ui/SurveyUnit/AddressForm.jsx | 1 - src/ui/SurveyUnit/CommentCard.jsx | 2 +- src/ui/SurveyUnit/CommentDialog.jsx | 2 +- src/ui/SurveyUnit/CommentForm.jsx | 3 +- src/ui/SurveyUnit/CommunicationForm.jsx | 2 +- src/ui/SurveyUnit/CommunicationsCard.jsx | 1 - src/ui/SurveyUnit/ContactAttemptForm.jsx | 2 +- src/ui/SurveyUnit/ContactOutcomeForm.jsx | 2 +- src/ui/SurveyUnit/ContactsCard.jsx | 1 - src/ui/SurveyUnit/IdentificationCard.jsx | 4 +- src/ui/SurveyUnit/PersonsCard.jsx | 2 +- src/ui/SurveyUnit/PersonsForm.jsx | 17 +- src/ui/Sync/SyncContextProvider.jsx | 4 +- src/ui/Sync/SyncDialog.jsx | 2 +- src/utils/api/fetcher.js | 2 +- .../functions/communicationFunctions.test.js | 2 +- src/utils/functions/dom.js | 8 +- .../functions/identificationFunctions.jsx | 4 +- src/utils/functions/sortOnColumn.js | 2 +- src/utils/functions/surveyUnitFunctions.js | 1 - src/utils/hooks/useNotifications.js | 2 +- src/utils/hooks/useOnline.js | 16 +- src/utils/hooks/useQueenListener.js | 1 - src/utils/hooks/useSearchFilter.js | 8 +- src/utils/icons/materialIcons.jsx | 1 - src/utils/indexeddb/schema-3.json | 4 +- tests/home.spec.ts | 17 + vite.config.js | 1 + yarn.lock | 2326 +++++++++++++---- 72 files changed, 2126 insertions(+), 822 deletions(-) create mode 100644 .github/workflows/playwright.yml create mode 100644 eslint.config.mjs create mode 100644 playwright.config.ts create mode 100644 tests/home.spec.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a61d034c..975d3bf86 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,8 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 - run: yarn - - run: yarn test + - run: yarn lint + - run: yarn test --coverage - run: yarn build - name: Upload build uses: actions/upload-artifact@v3 diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 000000000..307c6d9fc --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,39 @@ +name: Playwright Tests +on: + pull_request: + branches: [main, master] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - name: Checkout Pearl + uses: actions/checkout@v4 + with: + path: Pearl-Jam + - name: Checkout Queen + uses: actions/checkout@v4 + with: + repository: inseefr/drama-queen + path: Drama-Queen + - uses: actions/setup-node@v4 + with: + node-version: lts/* + - name: Install dependencies + run: | + npm install -g yarn + yarn --cwd Pearl-Jam + yarn --cwd Drama-Queen + - name: Install Playwright Browsers + working-directory: ./Pearl-Jam + run: npx playwright install --with-deps + - name: Run Playwright tests + working-directory: ./Pearl-Jam + run: | + npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: Pearl-Jam/playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index bd98e77ad..2a6c1de7e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,8 @@ dist-ssr *.njsproj *.sln *.sw? +coverage +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/README.md b/README.md index c181371ff..56665eab2 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,26 @@ # Pearl Jam Case management web application for Computer-Assisted Personal Interviewing (CAPI) + +## Running Unit Tests + +Unit Tests use the **Vitest** framework. You can run these tests with the following command: + +```shell +yarn test +yarn test --coverage +``` + +## Running Playwright Tests + +We can also run end-to-end test thank to **Playwright**. + +``` +npx playwright test +npx playwright test --ui +``` + +Before executing the test, we will : + +- build the project (in order to be sure that the test are running on the production-ready application) +- launch a static server (thanks to **npx serve**) diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..cebfe54f2 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,36 @@ +import globals from 'globals'; +import pluginJs from '@eslint/js'; +import tseslint from 'typescript-eslint'; +import pluginReact from 'eslint-plugin-react'; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; + +export default [ + { files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] }, + { languageOptions: { globals: globals.browser } }, + pluginJs.configs.recommended, + ...tseslint.configs.recommended, + pluginReact.configs.flat['jsx-runtime'], + eslintPluginPrettierRecommended, + { + settings: { react: { version: '18.3' } }, + rules: { + '@typescript-eslint/no-explicit-any': 'off', + 'no-undef': 'off', + '@typescript-eslint/no-unused-vars': 'off', + 'no-fallthrough': 'off', + }, + languageOptions: { + globals: { + it: 'readonly', + describe: 'readonly', + expect: 'readonly', + vi: 'readonly', + beforeEach: 'readonly', + global: 'readonly', + beforeAll: 'readonly', + afterAll: 'readonly', + test: 'readonly', + }, + }, + }, +]; diff --git a/index.html b/index.html index a785ad381..7c44fa953 100644 --- a/index.html +++ b/index.html @@ -3,10 +3,7 @@ - +