-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84a9d73
commit d2a4920
Showing
4 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]) | ||
} | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]) | ||
} | ||
}) |