From d2a492004159985799bd39784c1670fdd6128c5e Mon Sep 17 00:00:00 2001 From: oumeimaelisbihani Date: Wed, 13 Nov 2024 14:10:12 +0100 Subject: [PATCH] fix secrets --- .github/workflows/playwright.yml | 5 ++- apps/web-e2e/src/formResults.spec.ts | 4 +- apps/web-e2e/src/programResults.spec.ts | 29 +++++++++++++ apps/web-e2e/src/projectResults.spec.ts | 55 +++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 apps/web-e2e/src/programResults.spec.ts create mode 100644 apps/web-e2e/src/projectResults.spec.ts diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index a693da902..591f24b52 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -9,6 +9,9 @@ jobs: test: timeout-minutes: 60 runs-on: ubuntu-latest + env: + PDE_API_BASEURL: '${{secrets.PDE_API_BASEURL}}' + BREVO_DEAL_PIPELINE: '${{secrets.BREVO_DEAL_PIPELINE}}' strategy: matrix: node-version: [ '20.x' ] @@ -26,8 +29,6 @@ jobs: - name: Run Playwright tests env: TEST: true - PDE_API_BASEURL: '${{secrets.PDE_API_BASEURL}}' - BREVO_DEAL_PIPELINE: '${{secrets.BREVO_DEAL_PIPELINE}}' run: npm run e2e - uses: actions/upload-artifact@v4 if: always() diff --git a/apps/web-e2e/src/formResults.spec.ts b/apps/web-e2e/src/formResults.spec.ts index b52b96193..f3832014b 100644 --- a/apps/web-e2e/src/formResults.spec.ts +++ b/apps/web-e2e/src/formResults.spec.ts @@ -41,11 +41,11 @@ tests.forEach((singleTest) => { await submitButton.click() - /* const expectedCallbackSelector = singleTest.valid + const expectedCallbackSelector = singleTest.valid ? '[teste2e-selector="success-callback-contact-form"]' : '[teste2e-selector="error-callback-contact-form"]' - await expect(page.locator(expectedCallbackSelector)).toBeVisible({ timeout: 1000 }) */ + await expect(page.locator(expectedCallbackSelector)).toBeVisible({ timeout: 1000 }) } else { await expect(submitButton).toBeDisabled() } diff --git a/apps/web-e2e/src/programResults.spec.ts b/apps/web-e2e/src/programResults.spec.ts new file mode 100644 index 000000000..6dd62be58 --- /dev/null +++ b/apps/web-e2e/src/programResults.spec.ts @@ -0,0 +1,29 @@ +import { test, expect } from '@playwright/test' +import { tests } from './programResultsData' + +/** + * Test the number of programs proposed as a result of a list of queries and their order. + */ +tests.forEach((singleTest) => { + test(`Test id ${singleTest.id} - Verify programs number and order for query ${singleTest.url}`, async ({ page }) => { + await page.goto(singleTest.url) + try { + await page.waitForSelector('.teste2e-program-target', { timeout: 3000 }) + } catch (error) { + // this is an expected error what can happen + // - if the number of results is 0 + // - in some mobile data browser + } + const elementsLocal = await page.$$eval('.teste2e-program-target', (els) => els.map((el) => el.innerHTML.trim())) + + // console.warn(singleTest.values) + // console.warn(elementsLocal) + + expect(elementsLocal.length).toBe(singleTest.count ?? singleTest.values.length) + if (singleTest.count < 100) { + for (let i = 0; i < elementsLocal.length; i++) { + expect(elementsLocal[i]).toBe(singleTest.values[i]) + } + } + }) +}) diff --git a/apps/web-e2e/src/projectResults.spec.ts b/apps/web-e2e/src/projectResults.spec.ts new file mode 100644 index 000000000..8ec4f527e --- /dev/null +++ b/apps/web-e2e/src/projectResults.spec.ts @@ -0,0 +1,55 @@ +import { test, expect } from '@playwright/test' +import { tests } from './projectResultsData' + +tests.forEach((singleTest) => { + test(`Test id ${singleTest.id} - Verify content and elements for query ${singleTest.url}`, async ({ page }) => { + await page.goto(singleTest.url) + try { + await page.waitForSelector('.teste2e-project-target', { timeout: 3000 }) + } catch (error) { + // this is an expected error that can happen + // - if the number of results is 0 + // - in some mobile data browser + } + const elementsLocal = await page.$$eval('.teste2e-project-target h3 a', (els) => els.map((el) => el.innerHTML.trim())) + + // console.warn(singleTest.values) + // console.warn(elementsLocal) + + expect(elementsLocal.length).toBe(singleTest.count ?? singleTest.values.length) + for (let i = 0; i < elementsLocal.length; i++) { + expect(elementsLocal[i]).toBe(singleTest.values[i]) + } + }) +}) + +test(`Check projects found while initially selecting different tags`, async ({ page }) => { + const urlTag1 = 'questionnaire/resultat?choix-du-parcours=j-ai-un-projet&siret=83014132100034&effectif=TPE&objectifs=mobility' + const urlTag2 = 'questionnaire/resultat?choix-du-parcours=j-ai-un-projet&siret=83014132100034&effectif=TPE&objectifs=building' + + await page.goto(urlTag1) + try { + await page.waitForSelector('.teste2e-project-target', { timeout: 3000 }) + } catch (error) { + // this is an expected error that can happen + // - if the number of results is 0 + // - in some mobile data browser + } + const elementsurlTag1 = await page.$$eval('.teste2e-project-target h3 a', (els) => els.map((el) => el.innerHTML.trim())) + await page.goto(urlTag2) + try { + await page.waitForSelector('.teste2e-project-target', { timeout: 3000 }) + } catch (error) { + // this is an expected error that can happen + // - if the number of results is 0 + // - in some mobile data browser + } + await page.click('//button[normalize-space(.)="🚲 mobilité"]') + + const elementsurlTag2 = await page.$$eval('.teste2e-project-target h3 a', (els) => els.map((el) => el.innerHTML.trim())) + + expect(elementsurlTag1.length).toBe(elementsurlTag2.length) + for (let i = 0; i < elementsurlTag2.length; i++) { + expect(elementsurlTag1[i]).toBe(elementsurlTag2[i]) + } +})