Skip to content

Commit

Permalink
front: fix: e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Richard authored and Mathieu Richard committed Nov 9, 2023
1 parent 29d7ffa commit bdce16c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 48 deletions.
2 changes: 1 addition & 1 deletion front/tests/002-project-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test.describe('Test if operationnal study : project workflow is working properl

const createButton = playwrightHomePage.page.getByTestId('createProject');
await createButton.click();
await playwrightHomePage.page.waitForURL('**/project');
await playwrightHomePage.page.waitForURL('**/projects/*');
expect(await projectPage.getProjectName.textContent()).toContain(projectName);
expect(await projectPage.getProjectDescription.textContent()).toContain(project.description);
const objectives = await projectPage.getProjectObjectives.textContent();
Expand Down
32 changes: 13 additions & 19 deletions front/tests/003-study-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test.describe('Test if operationnal study: study creation workflow is working pr

const createButton = playwrightHomePage.page.getByTestId('createStudy');
await createButton.click();
await playwrightHomePage.page.waitForURL('**/study');
await playwrightHomePage.page.waitForURL('**/studies/*');
expect(await studyPage.getStudyName.textContent()).toContain(studyName);
expect(await studyPage.getStudyDescription.textContent()).toContain(study.description);
expect(await studyPage.getStudyType.textContent()).toContain(study.type);
Expand All @@ -86,15 +86,12 @@ test.describe('Test if operationnal study: study creation workflow is working pr
});

test(' update a study', async ({ page }) => {
const newStudyData: Study = await postApiRequest(
`/projects/${newProjectData.id}/studies/`,
{
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project: newProjectData.id,
}
);
const newStudyData: Study = await postApiRequest(`/projects/${newProjectData.id}/studies/`, {
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project: newProjectData.id,
});

const playwrightHomePage = new PlaywrightHomePage(page);
const studyPage = new StudyPage(page);
Expand Down Expand Up @@ -161,15 +158,12 @@ test.describe('Test if operationnal study: study creation workflow is working pr
});

test('Delete a study', async ({ page }) => {
const newStudyData: Study = await postApiRequest(
`/projects/${newProjectData.id}/studies/`,
{
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project: newProjectData.id,
}
);
const newStudyData: Study = await postApiRequest(`/projects/${newProjectData.id}/studies/`, {
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project: newProjectData.id,
});

const playwrightHomePage = new PlaywrightHomePage(page);
const studyPage = new StudyPage(page);
Expand Down
47 changes: 19 additions & 28 deletions front/tests/004-scenario-management.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@ test.describe('Test if operationnal study : scenario creation workflow is workin
const scenarioPage = new ScenarioPage(page);
const commonPage = new PlaywrightCommonPage(page);

const newStudyData: Study = await postApiRequest(
`/projects/${newProjectData.id}/studies`,
{
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project_id: newProjectData.id,
}
);
const newStudyData: Study = await postApiRequest(`/projects/${newProjectData.id}/studies`, {
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project_id: newProjectData.id,
});

await playwrightHomePage.goToHomePage();
await playwrightHomePage.goToOperationalStudiesPage();
Expand All @@ -79,22 +76,19 @@ test.describe('Test if operationnal study : scenario creation workflow is workin
await scenarioPage.setScenarioInfraByName(VARIABLES.infraName);
const createButton = playwrightHomePage.page.getByTestId('createScenario');
await createButton.click();
await playwrightHomePage.page.waitForURL('**/scenario');
await playwrightHomePage.page.waitForURL('**/scenarios/*');
expect(await scenarioPage.getScenarioName.textContent()).toContain(scenarioName);
expect(await scenarioPage.getScenarioDescription.textContent()).toContain(scenario.description);
expect(await scenarioPage.getScenarioInfraName.textContent()).toContain(VARIABLES.infraName);
});

test('Update a scenario', async ({ page }) => {
const newStudyData: Study = await postApiRequest(
`/projects/${newProjectData.id}/studies`,
{
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project_id: newProjectData.id,
}
);
const newStudyData: Study = await postApiRequest(`/projects/${newProjectData.id}/studies`, {
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project_id: newProjectData.id,
});

const newScenarioData: ScenarioResult = await postApiRequest(
`/projects/${newProjectData.id}/studies/${newStudyData.id}/scenarios`,
Expand Down Expand Up @@ -146,15 +140,12 @@ test.describe('Test if operationnal study : scenario creation workflow is workin
});

test('Delete a scenario', async ({ page }) => {
const newStudyData: Study = await postApiRequest(
`/projects/${newProjectData.id}/studies`,
{
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project_id: newProjectData.id,
}
);
const newStudyData: Study = await postApiRequest(`/projects/${newProjectData.id}/studies`, {
...study,
name: `${study.name} ${uuidv4()}`,
budget: 1234567890,
project_id: newProjectData.id,
});

const newScenarioData: ScenarioResult = await postApiRequest(
`/projects/${newProjectData.id}/studies/${newStudyData.id}/scenarios`,
Expand Down

0 comments on commit bdce16c

Please sign in to comment.