From 05cf607bb0d07952190aa81a38a9a18461185882 Mon Sep 17 00:00:00 2001 From: maymanaf Date: Mon, 8 Jul 2024 12:42:39 +0200 Subject: [PATCH] front: add rolling stock selectos e2e test for operational studies --- .../BootstrapSNCF/SwitchSNCF/SwitchSNCF.tsx | 3 +- .../RollingStockCardButtons.tsx | 7 +- .../RollingStockHelpers.tsx | 6 +- .../RollingStockSelector.tsx | 4 +- front/tests/001-home-page.spec.ts | 30 ++-- front/tests/002-project-management.spec.ts | 26 +-- front/tests/003-study-management.spec.ts | 22 +-- front/tests/004-scenario-management.spec.ts | 16 +- front/tests/005-operational-studies.spec.ts | 35 ++-- front/tests/006-stdcm-page.spec.ts | 4 +- front/tests/007-op-rollingstock-tab.spec.ts | 150 ++++++++++++++++++ front/tests/008-allowances.spec.ts | 6 +- front/tests/009-rollingstock-editor.spec.ts | 53 +++---- ...tock.json => dual-mode_rolling_stock.json} | 6 +- front/tests/global-setup.ts | 8 + front/tests/global-teardown.ts | 9 +- front/tests/pages/base-page.ts | 3 +- front/tests/pages/common-page-model.ts | 7 +- front/tests/pages/home-page-model.ts | 23 ++- front/tests/pages/map-model.ts | 16 +- .../pages/operational-studies-page-model.ts | 52 ++++++ front/tests/pages/project-page-model.ts | 4 +- .../pages/rollingstock-editor-page-model.ts | 5 +- ...-page.ts => rollingstock-selector-page.ts} | 19 ++- front/tests/pages/scenario-page-model.ts | 4 +- front/tests/pages/simulation-conf-page.ts | 5 +- front/tests/pages/stdcm-page-model.ts | 3 +- front/tests/pages/study-page-model.ts | 4 +- front/tests/utils/scenario-utils.ts | 24 +-- 29 files changed, 395 insertions(+), 159 deletions(-) create mode 100644 front/tests/007-op-rollingstock-tab.spec.ts rename front/tests/assets/rollingStock/{thermal-electric_rolling_stock.json => dual-mode_rolling_stock.json} (99%) create mode 100644 front/tests/pages/operational-studies-page-model.ts rename front/tests/pages/{rolling-stock-selector-page.ts => rollingstock-selector-page.ts} (86%) diff --git a/front/src/common/BootstrapSNCF/SwitchSNCF/SwitchSNCF.tsx b/front/src/common/BootstrapSNCF/SwitchSNCF/SwitchSNCF.tsx index 8437012f9a1..bf534923f0a 100644 --- a/front/src/common/BootstrapSNCF/SwitchSNCF/SwitchSNCF.tsx +++ b/front/src/common/BootstrapSNCF/SwitchSNCF/SwitchSNCF.tsx @@ -63,7 +63,6 @@ const SwitchSNCF: FC = ({ ); case SWITCH_TYPES.options: diff --git a/front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardButtons.tsx b/front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardButtons.tsx index c4d48800090..c7ed181357c 100644 --- a/front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardButtons.tsx +++ b/front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardButtons.tsx @@ -61,7 +61,10 @@ const RollingStockCardButtons = ({ options.push({ value: 'HEATING', label: ( - + {comfort2pictogram('HEATING')} {t('comfortTypes.HEATING')} ), @@ -71,7 +74,7 @@ const RollingStockCardButtons = ({ options.push({ value: 'AC', label: ( - + {comfort2pictogram('AC')} {t('comfortTypes.AC')} ), diff --git a/front/src/modules/rollingStock/components/RollingStockSelector/RollingStockHelpers.tsx b/front/src/modules/rollingStock/components/RollingStockSelector/RollingStockHelpers.tsx index 13fd64a9970..5272d1599b1 100644 --- a/front/src/modules/rollingStock/components/RollingStockSelector/RollingStockHelpers.tsx +++ b/front/src/modules/rollingStock/components/RollingStockSelector/RollingStockHelpers.tsx @@ -63,7 +63,11 @@ export const RollingStockInfo = ({ {`${metadata.family} / ${metadata.type} / ${metadata.grouping}`} )} - {showEnd && {rollingStock.name}} + {showEnd && ( + + {rollingStock.name} + + )} ); diff --git a/front/src/modules/rollingStock/components/RollingStockSelector/RollingStockSelector.tsx b/front/src/modules/rollingStock/components/RollingStockSelector/RollingStockSelector.tsx index ac053f2a1ae..40180f99de9 100644 --- a/front/src/modules/rollingStock/components/RollingStockSelector/RollingStockSelector.tsx +++ b/front/src/modules/rollingStock/components/RollingStockSelector/RollingStockSelector.tsx @@ -74,7 +74,9 @@ const RollingStockSelector = ({ {t('comfort')} {comfort2pictogram(rollingStockComfort)} - {t(`comfortTypes.${rollingStockComfort}`)} + + {t(`comfortTypes.${rollingStockComfort}`)} + { - let playwrightHomePage: PlaywrightHomePage; + let homePage: HomePage; test.beforeEach(async ({ page }) => { - // Create an instance of the PlaywrightHomePage class - playwrightHomePage = new PlaywrightHomePage(page); + // Create an instance of the HomePage class + homePage = new HomePage(page); // Go to the home page of OSRD - await playwrightHomePage.goToHomePage(); + await homePage.goToHomePage(); }); test.afterEach(async () => { // Navigate back to the home page of OSRD - await playwrightHomePage.backToHomePage(); + await homePage.backToHomePage(); }); // Test that the home page of OSRD displays links to other pages test('should display links in the home page', async () => { - await playwrightHomePage.getDisplayLinks(); + await homePage.getDisplayLinks(); }); test('should be correctly redirected to the "Operational Studies" page after clicking on the link', async () => { // Navigate to the "Operational Studies" page - await playwrightHomePage.goToOperationalStudiesPage(); + await homePage.goToOperationalStudiesPage(); // Check that the URL of the page matches the expected pattern - await expect(playwrightHomePage.page).toHaveURL(/.*\/operational-studies/); + await expect(homePage.page).toHaveURL(/.*\/operational-studies/); }); test('should be correctly redirected to the "Map" page after clicking on the link', async () => { // Navigate to the "Map" page - await playwrightHomePage.goToCartoPage(); + await homePage.goToCartoPage(); // Check that the URL of the page matches the expected pattern - await expect(playwrightHomePage.page).toHaveURL(/.*\/map/); + await expect(homePage.page).toHaveURL(/.*\/map/); }); test('should be correctly redirected to the "Editor" page after clicking on the link', async () => { // Navigate to the "Editor" page - await playwrightHomePage.goToEditorPage(); + await homePage.goToEditorPage(); // Check that the URL of the page matches the expected pattern - await expect(playwrightHomePage.page).toHaveURL(/.*\/editor\/*/); + await expect(homePage.page).toHaveURL(/.*\/editor\/*/); }); test('should be correctly redirected to the "STDCM" page after clicking on the link', async () => { // Navigate to the "STDCM" page - await playwrightHomePage.goToSTDCMPage(); + await homePage.goToSTDCMPage(); // Check that the URL of the page matches the expected pattern - await expect(playwrightHomePage.page).toHaveURL(/.*\/stdcm/); + await expect(homePage.page).toHaveURL(/.*\/stdcm/); }); }); diff --git a/front/tests/002-project-management.spec.ts b/front/tests/002-project-management.spec.ts index d7af2910fb1..219daa2bfc6 100644 --- a/front/tests/002-project-management.spec.ts +++ b/front/tests/002-project-management.spec.ts @@ -4,10 +4,10 @@ import { v4 as uuidv4 } from 'uuid'; import type { Project } from 'common/api/osrdEditoastApi'; import projectData from './assets/operationStudies/project.json'; +import CommonPage from './pages/common-page-model'; +import HomePage from './pages/home-page-model'; +import ProjectPage from './pages/project-page-model'; import { deleteApiRequest, getApiRequest, postApiRequest } from './utils/index'; -import PlaywrightCommonPage from './pages/common-page-model'; -import { PlaywrightHomePage } from './pages/home-page-model'; -import { ProjectPage } from './pages/project-page-model'; let project: Project; @@ -25,12 +25,12 @@ test.afterEach(async () => { test.describe('Test if operationnal study : project workflow is working properly', () => { test('Create a new project', async ({ page }) => { - const playwrightHomePage = new PlaywrightHomePage(page); + const homePage = new HomePage(page); const projectPage = new ProjectPage(page); - const commonPage = new PlaywrightCommonPage(page); + const commonPage = new CommonPage(page); - await playwrightHomePage.goToHomePage(); - await playwrightHomePage.goToOperationalStudiesPage(); + await homePage.goToHomePage(); + await homePage.goToOperationalStudiesPage(); await expect(projectPage.getAddProjectBtn).toBeVisible(); await projectPage.openProjectModalCreation(); @@ -49,9 +49,9 @@ test.describe('Test if operationnal study : project workflow is working properly await commonPage.setTag(projectData.tags[1]); await commonPage.setTag(projectData.tags[2]); - const createButton = playwrightHomePage.page.getByTestId('createProject'); + const createButton = homePage.page.getByTestId('createProject'); await createButton.click(); - await playwrightHomePage.page.waitForURL('**/projects/*'); + await homePage.page.waitForURL('**/projects/*'); expect(await projectPage.getProjectName.textContent()).toContain(projectName); expect(await projectPage.getProjectDescription.textContent()).toContain( projectData.description @@ -79,9 +79,9 @@ test.describe('Test if operationnal study : project workflow is working properly }); test(' update a project', async ({ page }) => { - const playwrightHomePage = new PlaywrightHomePage(page); + const homePage = new HomePage(page); const projectPage = new ProjectPage(page); - const commonPage = new PlaywrightCommonPage(page); + const commonPage = new CommonPage(page); await page.goto('/operational-studies/projects'); @@ -103,8 +103,8 @@ test.describe('Test if operationnal study : project workflow is working properly await projectPage.clickProjectUpdateConfirmBtn(); - await playwrightHomePage.goToHomePage(); - await playwrightHomePage.goToOperationalStudiesPage(); + await homePage.goToHomePage(); + await homePage.goToOperationalStudiesPage(); await projectPage.openProjectByTestId(`${project.name} (updated)`); diff --git a/front/tests/003-study-management.spec.ts b/front/tests/003-study-management.spec.ts index 71e465a28e2..7add5986ab0 100644 --- a/front/tests/003-study-management.spec.ts +++ b/front/tests/003-study-management.spec.ts @@ -4,10 +4,10 @@ import { v4 as uuidv4 } from 'uuid'; import type { Project, Study } from 'common/api/osrdEditoastApi'; import studyData from './assets/operationStudies/study.json'; +import CommonPage from './pages/common-page-model'; +import HomePage from './pages/home-page-model'; +import StudyPage from './pages/study-page-model'; import { getProject, postApiRequest } from './utils/index'; -import PlaywrightCommonPage from './pages/common-page-model'; -import { PlaywrightHomePage } from './pages/home-page-model'; -import { StudyPage } from './pages/study-page-model'; let project: Project; let study: Study; @@ -27,9 +27,9 @@ test.beforeEach(async () => { test.describe('Test if operationnal study: study creation workflow is working properly', () => { test('Create a new study', async ({ page }) => { - const playwrightHomePage = new PlaywrightHomePage(page); + const homePage = new HomePage(page); const studyPage = new StudyPage(page); - const commonPage = new PlaywrightCommonPage(page); + const commonPage = new CommonPage(page); await page.goto(`/operational-studies/projects/${project.id}`); @@ -62,9 +62,9 @@ test.describe('Test if operationnal study: study creation workflow is working pr await commonPage.setTag(project.tags[1]); await commonPage.setTag(project.tags[2]); - const createButton = playwrightHomePage.page.getByTestId('createStudy'); + const createButton = homePage.page.getByTestId('createStudy'); await createButton.click(); - await playwrightHomePage.page.waitForURL('**/studies/*'); + await homePage.page.waitForURL('**/studies/*'); expect(await studyPage.getStudyName.textContent()).toContain(studyName); expect(await studyPage.getStudyDescription.textContent()).toContain(studyData.description); expect(await studyPage.getStudyType.textContent()).toContain(studyData.type); @@ -85,7 +85,7 @@ test.describe('Test if operationnal study: study creation workflow is working pr test(' update a study', async ({ page }) => { const studyPage = new StudyPage(page); - const commonPage = new PlaywrightCommonPage(page); + const commonPage = new CommonPage(page); await page.goto(`/operational-studies/projects/${project.id}/studies/${study.id}`); @@ -139,7 +139,7 @@ test.describe('Test if operationnal study: study creation workflow is working pr }); test('Delete a study', async ({ page }) => { - const playwrightHomePage = new PlaywrightHomePage(page); + const homePage = new HomePage(page); const studyPage = new StudyPage(page); await page.goto(`/operational-studies/projects/${project.id}/studies/${study.id}`); @@ -148,8 +148,8 @@ test.describe('Test if operationnal study: study creation workflow is working pr await studyPage.clickStudyDeleteConfirmBtn(); - await playwrightHomePage.goToHomePage(); - await playwrightHomePage.goToOperationalStudiesPage(); + await homePage.goToHomePage(); + await homePage.goToOperationalStudiesPage(); await expect(studyPage.getStudyByName(studyData.name)).not.toBeVisible(); }); diff --git a/front/tests/004-scenario-management.spec.ts b/front/tests/004-scenario-management.spec.ts index ac28d486721..85998a3d447 100644 --- a/front/tests/004-scenario-management.spec.ts +++ b/front/tests/004-scenario-management.spec.ts @@ -4,10 +4,10 @@ import { v4 as uuidv4 } from 'uuid'; import type { Infra, Project, Scenario, Study } from 'common/api/osrdEditoastApi'; import scenarioData from './assets/operationStudies/scenario.json'; -import { getInfra, getProject, getStudy, postApiRequest } from './utils/index'; -import PlaywrightCommonPage from './pages/common-page-model'; -import { PlaywrightHomePage } from './pages/home-page-model'; +import CommonPage from './pages/common-page-model'; +import HomePage from './pages/home-page-model'; import ScenarioPage from './pages/scenario-page-model'; +import { getInfra, getProject, getStudy, postApiRequest } from './utils/index'; let smallInfra: Infra; let project: Project; @@ -31,9 +31,9 @@ test.beforeEach(async () => { test.describe('Test if operationnal study : scenario creation workflow is working properly', () => { test('Create a new scenario', async ({ page }) => { - const playwrightHomePage = new PlaywrightHomePage(page); + const homePage = new HomePage(page); const scenarioPage = new ScenarioPage(page); - const commonPage = new PlaywrightCommonPage(page); + const commonPage = new CommonPage(page); await page.goto(`/operational-studies/projects/${project.id}/studies/${study.id}`); @@ -55,9 +55,9 @@ test.describe('Test if operationnal study : scenario creation workflow is workin await commonPage.setTag(scenarioData.tags[2]); await scenarioPage.setScenarioInfraByName('small_infra_test_e2e'); - const createButton = playwrightHomePage.page.getByTestId('createScenario'); + const createButton = homePage.page.getByTestId('createScenario'); await createButton.click(); - await playwrightHomePage.page.waitForURL('**/scenarios/*'); + await homePage.page.waitForURL('**/scenarios/*'); expect(await scenarioPage.getScenarioName.textContent()).toContain(scenarioName); expect(await scenarioPage.getScenarioDescription.textContent()).toContain( scenarioData.description @@ -67,7 +67,7 @@ test.describe('Test if operationnal study : scenario creation workflow is workin test('Update a scenario', async ({ page }) => { const scenarioPage = new ScenarioPage(page); - const commonPage = new PlaywrightCommonPage(page); + const commonPage = new CommonPage(page); await page.goto( `/operational-studies/projects/${project.id}/studies/${study.id}/scenarios/${scenario.id}` diff --git a/front/tests/005-operational-studies.spec.ts b/front/tests/005-operational-studies.spec.ts index a8a3e74bb98..2504d87448a 100644 --- a/front/tests/005-operational-studies.spec.ts +++ b/front/tests/005-operational-studies.spec.ts @@ -4,10 +4,10 @@ import { v4 as uuidv4 } from 'uuid'; import type { Infra, Project, RollingStock, Scenario, Study } from 'common/api/osrdEditoastApi'; import scenarioData from './assets/operationStudies/scenario.json'; +import HomePage from './pages/home-page-model'; +import RollingStockSelectorPage from './pages/rollingstock-selector-page'; +import ScenarioPage from './pages/scenario-page-model'; import { getProject, getStudy, getRollingStock, postApiRequest, getInfra } from './utils/index'; -import { PlaywrightHomePage } from './pages/home-page-model'; -import RollingStockSelectorPage from './pages/rolling-stock-selector-page'; -import PlaywrightScenarioPage from './pages/scenario-page-model'; let smallInfra: Infra; let project: Project; @@ -33,15 +33,14 @@ test.beforeEach(async () => { test.describe('Testing if all mandatory elements simulation configuration are loaded in operationnal studies app', () => { test('Testing pathfinding with rollingstock and composition code', async ({ page }) => { - const playwrightHomePage = new PlaywrightHomePage(page); - const scenarioPage = new PlaywrightScenarioPage(page); - + const homePage = new HomePage(page); + const scenarioPage = new ScenarioPage(page); await page.goto( `/operational-studies/projects/${project.id}/studies/${study.id}/scenarios/${scenario.id}` ); await scenarioPage.checkInfraLoaded(); - await playwrightHomePage.page.getByTestId('scenarios-add-train-schedule-button').click(); + await homePage.page.getByTestId('scenarios-add-train-schedule-button').click(); await scenarioPage.setTrainScheduleName('TrainSchedule'); const trainCount = '7'; @@ -49,16 +48,16 @@ test.describe('Testing if all mandatory elements simulation configuration are lo // TODO: move this test in his own file // ***************** Test Rolling Stock ***************** - const playwrightRollingstockModalPage = new RollingStockSelectorPage(playwrightHomePage.page); + const rollingstockModalPage = new RollingStockSelectorPage(homePage.page); await expect(scenarioPage.getRollingStockSelector).toBeVisible(); - await playwrightRollingstockModalPage.openRollingstockModal(); - const rollingstockModal = playwrightRollingstockModalPage.rollingStockSelectorModal; + await rollingstockModalPage.openRollingstockModal(); + const rollingstockModal = rollingstockModalPage.rollingStockSelectorModal; await expect(rollingstockModal).toBeVisible(); // Voluntarily add spaces and capital letters so we also test the normalization of the search functionality - await playwrightRollingstockModalPage.searchRollingstock(' rollingstock_1500_25000_test_E2E '); + await rollingstockModalPage.searchRollingstock(' rollingstock_1500_25000_test_E2E '); - const rollingstockCard = playwrightRollingstockModalPage.getRollingstockCardByTestID( + const rollingstockCard = rollingstockModalPage.getRollingstockCardByTestID( `rollingstock-${rollingStock.name}` ); await expect(rollingstockCard).toHaveClass(/inactive/); @@ -67,12 +66,12 @@ test.describe('Testing if all mandatory elements simulation configuration are lo await rollingstockCard.locator('button').click(); - expect( - await playwrightRollingstockModalPage.getRollingStockMiniCardInfo().first().textContent() - ).toMatch(rollingStock.name); - expect( - await playwrightRollingstockModalPage.getRollingStockInfoComfort().textContent() - ).toMatch(/ConfortSStandard/i); + expect(await rollingstockModalPage.getRollingStockMiniCardInfo().first().textContent()).toMatch( + rollingStock.name + ); + expect(await rollingstockModalPage.getRollingStockInfoComfort().textContent()).toMatch( + /ConfortSStandard/i + ); // ***************** Test choice Origin/Destination ***************** await scenarioPage.openTabByDataId('tab-pathfinding'); diff --git a/front/tests/006-stdcm-page.spec.ts b/front/tests/006-stdcm-page.spec.ts index 5a140347936..56bcb2afccb 100644 --- a/front/tests/006-stdcm-page.spec.ts +++ b/front/tests/006-stdcm-page.spec.ts @@ -3,7 +3,7 @@ import { test, expect } from '@playwright/test'; import project from './assets/operationStudies/project.json'; import scenario from './assets/operationStudies/scenario.json'; import study from './assets/operationStudies/study.json'; -import { PlaywrightHomePage } from './pages/home-page-model'; +import HomePage from './pages/home-page-model'; import StdcmPage from './pages/stdcm-page-model'; import manageTrainScheduleTranslation from '../public/locales/fr/operationalStudies/manageTrainSchedule.json'; @@ -19,7 +19,7 @@ test.describe('STDCM page', () => { const stdcmPage = new StdcmPage(page); // TODO: DROP STDCMV1: remove this part - const homePage = new PlaywrightHomePage(page); + const homePage = new HomePage(page); await homePage.goToHomePage(); await stdcmPage.toggleStdcmV1(); diff --git a/front/tests/007-op-rollingstock-tab.spec.ts b/front/tests/007-op-rollingstock-tab.spec.ts new file mode 100644 index 00000000000..74813c5d6f5 --- /dev/null +++ b/front/tests/007-op-rollingstock-tab.spec.ts @@ -0,0 +1,150 @@ +import { test, expect } from '@playwright/test'; +import { v4 as uuidv4 } from 'uuid'; + +import type { + Infra, + Project, + RollingStock, + Scenario, + Study, + Timetable, +} from 'common/api/osrdEditoastApi'; + +import scenarioData from './assets/operationStudies/scenario.json'; +import HomePage from './pages/home-page-model'; +import OperationalStudiesPage from './pages/operational-studies-page-model'; +import RollingStockSelectorPage from './pages/rollingstock-selector-page'; +import ScenarioPage from './pages/scenario-page-model'; +import { getProject, getStudy, getRollingStock, postApiRequest, getInfra } from './utils/index'; + +let smallInfra: Infra; +let project: Project; +let study: Study; +let scenario: Scenario; +let rollingStock: RollingStock; +let timetable: Timetable; + +const dualModeRollingStockName = 'dual-mode_rollingstock_test_e2e'; +const electricRollingStockName = 'rollingstock_1500_25000_test_e2e'; +test.beforeAll(async () => { + smallInfra = (await getInfra()) as Infra; + project = await getProject(); + study = await getStudy(project.id); + rollingStock = await getRollingStock(); +}); + +test.beforeEach(async () => { + timetable = await postApiRequest(`/api/v2/timetable/`, { + electrical_profile_set_id: null, + }); + scenario = await postApiRequest(`/api/v2/projects/${project.id}/studies/${study.id}/scenarios/`, { + ...scenarioData, + name: `${scenarioData.name} ${uuidv4()}`, + study_id: study.id, + infra_id: smallInfra.id, + timetable_id: timetable.id, + }); +}); + +test.describe('Verifying that all elements in the rolling stock tab are loaded correctly', () => { + test('should correctly select a rolling stock for operational study', async ({ page }) => { + const operationalStudiesPage = new OperationalStudiesPage(page); + const scenarioPage = new ScenarioPage(page); + const rollingStockSelector = new RollingStockSelectorPage(page); + // TODO: DROP TSV1: remove this part + const homePage = new HomePage(page); + await homePage.goToHomePage(); + await homePage.toggleTSV2(); + + // Navigate to the created scenario page + await page.goto( + `/operational-studies/projects/${project.id}/studies/${study.id}/scenarios/${scenario.id}` + ); + + // Verify that the infrastructure is correctly loaded + await scenarioPage.checkInfraLoaded(); + + // Click on add train button + await operationalStudiesPage.clickOnAddScenarioTrainBtn(); + + // Verify the presence of warnings in Rolling Stock and Route Tab + await operationalStudiesPage.verifyTabWarningPresence(); + + // Open Rolling Stock Selector and search for the added train + await operationalStudiesPage.openEmptyRollingStockSelector(); + await rollingStockSelector.searchRollingstock(dualModeRollingStockName); + const rollingstockCard = rollingStockSelector.getRollingstockCardByTestID( + `rollingstock-${dualModeRollingStockName}` + ); + + // Verify that the rolling stock card is inactive + await expect(rollingstockCard).toHaveClass(/inactive/); + + // Verify that the rolling stock card is active after clicking on it + await rollingstockCard.click(); + await expect(rollingstockCard).not.toHaveClass(/inactive/); + + // Select the comfort AC + const comfortACRadioText = await rollingStockSelector.comfortACButton.innerText(); + await rollingStockSelector.comfortACButton.click(); + + // Select the rolling stock + await rollingstockCard.locator('button').click(); + + // Verify that the correct comfort type is displayed + const selectedComfortACText = await rollingStockSelector.getSelectedComfortType.innerText(); + expect(selectedComfortACText).toMatch(new RegExp(comfortACRadioText, 'i')); + }); + + test('should correctly modify a rolling stock for operational study', async ({ page }) => { + const operationalStudiesPage = new OperationalStudiesPage(page); + const scenarioPage = new ScenarioPage(page); + const rollingStockSelector = new RollingStockSelectorPage(page); + // TODO: DROP TSV1: remove this part + const homePage = new HomePage(page); + await homePage.goToHomePage(); + await homePage.toggleTSV2(); + + // Navigate to the created scenario page + await page.goto( + `/operational-studies/projects/${project.id}/studies/${study.id}/scenarios/${scenario.id}` + ); + + // Verify that the infrastructure is correctly loaded + await scenarioPage.checkInfraLoaded(); + + // Click on add train button + await operationalStudiesPage.clickOnAddScenarioTrainBtn(); + + // Open Rolling Stock Selector, search for the added train, and select it + await operationalStudiesPage.openEmptyRollingStockSelector(); + await rollingStockSelector.searchRollingstock(electricRollingStockName); + const fastRollingstockCard = rollingStockSelector.getRollingstockCardByTestID( + `rollingstock-${rollingStock.name}` + ); + await fastRollingstockCard.click(); + await fastRollingstockCard.locator('button').click(); + expect(await rollingStockSelector.getSelectedRollingStockName.innerText()).toEqual( + electricRollingStockName + ); + + // Reopen the Rolling Stock selector from the selected card + await operationalStudiesPage.openRollingStockSelector(); + + // Apply thermal and electrical filters + await rollingStockSelector.thermalRollingStockFilter(); + await rollingStockSelector.electricRollingStockFilter(); + + // Select the dual mode rolling stock + const dualModeRollingstockCard = rollingStockSelector.getRollingstockCardByTestID( + `rollingstock-${dualModeRollingStockName}` + ); + await dualModeRollingstockCard.click(); + await dualModeRollingstockCard.locator('button').click(); + + // Verify that the correct rolling stock name is displayed + expect(await rollingStockSelector.getSelectedRollingStockName.innerText()).toEqual( + dualModeRollingStockName + ); + }); +}); diff --git a/front/tests/008-allowances.spec.ts b/front/tests/008-allowances.spec.ts index ed42048c6a7..45dbd87e6c1 100644 --- a/front/tests/008-allowances.spec.ts +++ b/front/tests/008-allowances.spec.ts @@ -1,15 +1,15 @@ import { test } from '@playwright/test'; import { v4 as uuidv4 } from 'uuid'; +import ScenarioPage from './pages/scenario-page-model'; import createCompleteScenario, { allowancesManagement } from './utils/scenario-utils'; -import PlaywrightScenarioPage from './pages/scenario-page-model'; let scenarioName: string; -let scenarioPage: PlaywrightScenarioPage; +let scenarioPage: ScenarioPage; test.describe('Testing if all mandatory elements simulation configuration are loaded in operationnal studies app', () => { test.beforeEach(async ({ page }) => { - scenarioPage = new PlaywrightScenarioPage(page); + scenarioPage = new ScenarioPage(page); scenarioName = `Train_Schedule_${uuidv4().slice(0, 5)}`; await createCompleteScenario(page, scenarioName, '1', '15'); }); diff --git a/front/tests/009-rollingstock-editor.spec.ts b/front/tests/009-rollingstock-editor.spec.ts index c3d87a481f5..9e807cf924c 100644 --- a/front/tests/009-rollingstock-editor.spec.ts +++ b/front/tests/009-rollingstock-editor.spec.ts @@ -3,29 +3,24 @@ import path from 'path'; import { test, expect } from '@playwright/test'; +import RollingstockEditorPage from './pages/rollingstock-editor-page-model'; +import RollingStockSelectorPage from './pages/rollingstock-selector-page'; import { findAndDeleteRollingStocks, generateUniqueName, verifyAndCheckInputById, fillAndCheckInputById, - addRollingStock, } from './utils/index'; -import RollingStockSelectorPage from './pages/rolling-stock-selector-page'; -import PlaywrightRollingstockEditorPage from './pages/rollingstock-editor-page-model'; // Correct path to load rolling stock details from JSON const rollingstockDetailsPath = path.resolve( __dirname, '../tests/assets/rollingStock/rollingstockDetails.json' ); -// Correct path to load electrical and themal rolling stock from JSON -const rollingstockPath = path.resolve( - __dirname, - '../tests/assets/rollingStock/thermal-electric_rolling_stock.json' -); + const rollingstockDetails = JSON.parse(fs.readFileSync(rollingstockDetailsPath, 'utf-8')); -const rollingStockJson = JSON.parse(fs.readFileSync(rollingstockPath, 'utf8')); -const thermalElectricRollingStockName = 'thermal-electric_rolling_stock'; +const dualModeRollingStockName = 'dual-mode_rollingstock_test_e2e'; +const electricRollingStockName = 'rollingstock_1500_25000_test_e2e'; test.describe('Rollingstock editor page', () => { let uniqueRollingStockName: string; @@ -42,7 +37,6 @@ test.describe('Rollingstock editor page', () => { uniqueRollingStockName, uniqueUpdatedRollingStockName, uniqueDeletedRollingStockName, - thermalElectricRollingStockName, ]); }); @@ -52,12 +46,11 @@ test.describe('Rollingstock editor page', () => { uniqueRollingStockName, uniqueUpdatedRollingStockName, uniqueDeletedRollingStockName, - thermalElectricRollingStockName, ]); }); test('should correctly create a new rolling stock', async ({ page }) => { - const rollingStockEditorPage = new PlaywrightRollingstockEditorPage(page); + const rollingStockEditorPage = new RollingstockEditorPage(page); // Navigate to the page await rollingStockEditorPage.navigateToPage(); @@ -128,13 +121,12 @@ test.describe('Rollingstock editor page', () => { }); test('should correctly duplicate and modify a rolling stock', async ({ page }) => { - const rollingStockEditorPage = new PlaywrightRollingstockEditorPage(page); - const addedRollingStockName = 'rollingstock_1500_25000_test_e2e'; + const rollingStockEditorPage = new RollingstockEditorPage(page); await rollingStockEditorPage.navigateToPage(); // Select the rolling stock from global-setup - await rollingStockEditorPage.selectRollingStock(addedRollingStockName); + await rollingStockEditorPage.selectRollingStock(electricRollingStockName); // Duplicate rolling stock await rollingStockEditorPage.duplicateRollingStock(); @@ -158,8 +150,8 @@ test.describe('Rollingstock editor page', () => { await rollingStockEditorPage.submitRollingStock(); // Confirm the presence of the original RS - await rollingStockEditorPage.searchRollingStock(addedRollingStockName); - expect(rollingStockEditorPage.page.getByTestId(addedRollingStockName)).toBeDefined(); + await rollingStockEditorPage.searchRollingStock(electricRollingStockName); + expect(rollingStockEditorPage.page.getByTestId(electricRollingStockName)).toBeDefined(); await rollingStockEditorPage.clearSearchRollingStock(); // Get to details page of the new rolling stock @@ -181,13 +173,12 @@ test.describe('Rollingstock editor page', () => { ); }); test('should correctly duplicate and delete a rolling stock', async ({ page }) => { - const rollingStockEditorPage = new PlaywrightRollingstockEditorPage(page); - const addedRollingStockName = 'rollingstock_1500_25000_test_e2e'; + const rollingStockEditorPage = new RollingstockEditorPage(page); await rollingStockEditorPage.navigateToPage(); // Select the rolling stock from global-setup - await rollingStockEditorPage.selectRollingStock(addedRollingStockName); + await rollingStockEditorPage.selectRollingStock(electricRollingStockName); // Duplicate and change the rolling stock name await rollingStockEditorPage.duplicateRollingStock(); @@ -205,7 +196,7 @@ test.describe('Rollingstock editor page', () => { ).toBeHidden(); }); test('should correctly filter a rolling stock', async ({ page }) => { - const rollingStockEditorPage = new PlaywrightRollingstockEditorPage(page); + const rollingStockEditorPage = new RollingstockEditorPage(page); const rollingStockSelectorPage = new RollingStockSelectorPage(page); // Navigate to rolling stock editor page await rollingStockEditorPage.navigateToPage(); @@ -233,11 +224,11 @@ test.describe('Rollingstock editor page', () => { await rollingStockSelectorPage.getRollingStockSearchNumber() ); - // Perform a filtering action for combined thermal-electric rolling stock + // Perform a filtering action for dual-mode rolling stock await rollingStockSelectorPage.electricRollingStockFilter(); // Verify that filtering reduces the count and all the RS have thermal and electric icons - expect(await rollingStockSelectorPage.getThermalElectricRollingStockIcons.count()).toEqual( + expect(await rollingStockSelectorPage.getDualModeRollingStockIcons.count()).toEqual( await rollingStockSelectorPage.getRollingStockSearchNumber() ); @@ -252,10 +243,8 @@ test.describe('Rollingstock editor page', () => { }); test('should correctly search for a rolling stock', async ({ page }) => { - const rollingStockEditorPage = new PlaywrightRollingstockEditorPage(page); + const rollingStockEditorPage = new RollingstockEditorPage(page); const rollingStockSelectorPage = new RollingStockSelectorPage(page); - // Add a rolling stock via postAPI - await addRollingStock(thermalElectricRollingStockName, rollingStockJson); // Navigate to rolling stock editor page await rollingStockEditorPage.navigateToPage(); @@ -265,11 +254,9 @@ test.describe('Rollingstock editor page', () => { await rollingStockSelectorPage.getRollingStockSearchNumber(); // Search for the specific rolling stock - await rollingStockEditorPage.searchRollingStock(thermalElectricRollingStockName); + await rollingStockEditorPage.searchRollingStock(dualModeRollingStockName); expect( - rollingStockEditorPage.page.getByTestId( - `rollingstock-thermal-${thermalElectricRollingStockName}` - ) + rollingStockEditorPage.page.getByTestId(`rollingstock-${dualModeRollingStockName}`) ).toBeDefined(); // Verify that the first rolling stock has the thermal and electric icon @@ -284,9 +271,7 @@ test.describe('Rollingstock editor page', () => { initialRollingStockFoundNumber ); // Search for a non existing rolling stock - await rollingStockEditorPage.searchRollingStock( - `${thermalElectricRollingStockName}-no-results` - ); + await rollingStockEditorPage.searchRollingStock(`${dualModeRollingStockName}-no-results`); // Verify that the count of rolling stock is 0 (No results Found) await expect(rollingStockSelectorPage.getNoRollingStockResult).toBeVisible(); diff --git a/front/tests/assets/rollingStock/thermal-electric_rolling_stock.json b/front/tests/assets/rollingStock/dual-mode_rolling_stock.json similarity index 99% rename from front/tests/assets/rollingStock/thermal-electric_rolling_stock.json rename to front/tests/assets/rollingStock/dual-mode_rolling_stock.json index 33b21da0a70..74d56ae2f6a 100644 --- a/front/tests/assets/rollingStock/thermal-electric_rolling_stock.json +++ b/front/tests/assets/rollingStock/dual-mode_rolling_stock.json @@ -1,6 +1,6 @@ { "railjson_version": "3.2", - "name": "thermal-electric_rolling_stock", + "name": "dual-mode_rollingstock_test_e2e", "effort_curves": { "modes": { "25000V": { @@ -404,7 +404,7 @@ "default_mode": "thermal" }, "metadata": { - "detail": "thermo-electric", + "detail": "dual-mode", "family": "", "type": "", "grouping": "", @@ -412,7 +412,7 @@ "subseries": "", "unit": "", "number": "", - "reference": "thermo-electric" + "reference": "dual-mode" }, "length": 350.0, "max_speed": 44.44444444444444, diff --git a/front/tests/global-setup.ts b/front/tests/global-setup.ts index 837d607eaa3..4fd96ce026b 100644 --- a/front/tests/global-setup.ts +++ b/front/tests/global-setup.ts @@ -24,6 +24,10 @@ async function createDataForTests() { fs.readFileSync('../tests/data/rolling_stocks/electric_rolling_stock.json', 'utf8') ); + const dualModeRollingStockJson = JSON.parse( + fs.readFileSync('./tests/assets/rollingStock/dual-mode_rolling_stock.json', 'utf8') + ); + const createdInfra: PostInfraRailjsonApiResponse = await postApiRequest( `/api/infra/railjson/`, { @@ -41,6 +45,10 @@ async function createDataForTests() { ...rollingStockJson, name: 'rollingstock_1500_25000_test_e2e', }); + await postApiRequest('/api/rolling_stock/', { + ...dualModeRollingStockJson, + name: 'dual-mode_rollingstock_test_e2e', + }); const project = await postApiRequest('/api/projects/', { ...projectData, diff --git a/front/tests/global-teardown.ts b/front/tests/global-teardown.ts index 530ffb8a506..f4e3592dcb6 100644 --- a/front/tests/global-teardown.ts +++ b/front/tests/global-teardown.ts @@ -12,11 +12,14 @@ setup('teardown', async () => { const project = projects.results.find((p: Project) => p.name === 'project_test_e2e'); const rollingStocks = await getApiRequest(`/api/light_rolling_stock/`, { page_size: 500 }); - const rollingStock: RollingStock = await rollingStocks.results.find( + const electricRollingStock: RollingStock = await rollingStocks.results.find( (r: RollingStock) => r.name === 'rollingstock_1500_25000_test_e2e' ); - + const dualModeRollingStock: RollingStock = await rollingStocks.results.find( + (r: RollingStock) => r.name === 'dual-mode_rollingstock_test_e2e' + ); await deleteApiRequest(`/api/infra/${infra.id}/`); await deleteApiRequest(`/api/projects/${project.id}/`); - await deleteApiRequest(`/api/rolling_stock/${rollingStock.id}/`); + await deleteApiRequest(`/api/rolling_stock/${electricRollingStock.id}/`); + await deleteApiRequest(`/api/rolling_stock/${dualModeRollingStock.id}/`); }); diff --git a/front/tests/pages/base-page.ts b/front/tests/pages/base-page.ts index 701842a0d3e..6d630496878 100644 --- a/front/tests/pages/base-page.ts +++ b/front/tests/pages/base-page.ts @@ -1,6 +1,6 @@ import { expect, type Locator, type Page } from '@playwright/test'; -export default class BasePage { +class BasePage { public page: Page; private backToHomePageButton: Locator; @@ -40,3 +40,4 @@ export default class BasePage { await this.page.getByRole('button', { name }).click(); } } +export default BasePage; diff --git a/front/tests/pages/common-page-model.ts b/front/tests/pages/common-page-model.ts index 3d4deb18d50..ae9f07bbafd 100644 --- a/front/tests/pages/common-page-model.ts +++ b/front/tests/pages/common-page-model.ts @@ -1,10 +1,9 @@ -import { expect } from '@playwright/test'; -import type { Locator, Page } from '@playwright/test'; +import { expect, type Locator, type Page } from '@playwright/test'; import BasePage from './base-page'; import rollingstockTranslation from '../../public/locales/fr/rollingstock.json'; -class PlaywrightCommonPage extends BasePage { +class CommonPage extends BasePage { readonly rollingstockTranslation: typeof rollingstockTranslation; readonly getToastSNCF: Locator; @@ -33,4 +32,4 @@ class PlaywrightCommonPage extends BasePage { } } -export default PlaywrightCommonPage; +export default CommonPage; diff --git a/front/tests/pages/home-page-model.ts b/front/tests/pages/home-page-model.ts index cd578cb6b62..1d679d9a861 100644 --- a/front/tests/pages/home-page-model.ts +++ b/front/tests/pages/home-page-model.ts @@ -1,9 +1,8 @@ -/* eslint-disable import/prefer-default-export */ import { expect, type Locator, type Page } from '@playwright/test'; import home from '../../public/locales/fr/home/home.json'; -export class PlaywrightHomePage { +class HomePage { // The current page object readonly page: Page; @@ -31,6 +30,12 @@ export class PlaywrightHomePage { readonly getViteOverlay: Locator; + readonly TSV2Switch: Locator; + + readonly dropDown: Locator; + + readonly userSettings: Locator; + constructor(page: Page) { this.page = page; // Initialize locators using roles and text content @@ -46,6 +51,9 @@ export class PlaywrightHomePage { this.getBody = page.locator('body'); this.translation = home; this.getViteOverlay = page.locator('vite-plugin-checker-error-overlay'); + this.TSV2Switch = page.getByTestId('train-schedule-version-switch'); + this.dropDown = page.getByTestId('dropdown-sncf'); + this.userSettings = page.getByTestId('user-settings-btn'); } // Completly remove VITE button & sign @@ -101,4 +109,15 @@ export class PlaywrightHomePage { getTranslations(key: keyof typeof home) { return this.translation[key]; } + + // TODO : Delete after drop V1 + // Check Stdcm Version + async toggleTSV2() { + await this.dropDown.click(); + await this.userSettings.click(); + if (!(await this.TSV2Switch.isChecked()) && (await this.TSV2Switch.isVisible())) { + await this.TSV2Switch.click(); + } + } } +export default HomePage; diff --git a/front/tests/pages/map-model.ts b/front/tests/pages/map-model.ts index ce5f2d04a62..a99e14328ae 100644 --- a/front/tests/pages/map-model.ts +++ b/front/tests/pages/map-model.ts @@ -1,6 +1,6 @@ import { type Locator, type Page, expect } from '@playwright/test'; -import { PlaywrightHomePage } from './home-page-model'; +import HomePage from './home-page-model'; export interface selectPointOnMapProps { stationName: string; @@ -8,7 +8,7 @@ export interface selectPointOnMapProps { positionClick: { x: number; y: number }; } -class PlaywrightMap { +class MapPage { readonly getBtnShearch: Locator; readonly getBtnCloseShearch: Locator; @@ -23,7 +23,7 @@ class PlaywrightMap { readonly getPathFindingResult: Locator; - readonly playwrightHomePage: PlaywrightHomePage; + readonly homePage: HomePage; constructor(readonly page: Page) { this.getBtnShearch = page.getByRole('button', { name: 'Search' }); @@ -35,7 +35,7 @@ class PlaywrightMap { .locator('.map-popup-click-select') .getByTestId('map-destination-button'); this.getPathFindingResult = page.locator('.pathfinding-done'); - this.playwrightHomePage = new PlaywrightHomePage(page); + this.homePage = new HomePage(page); } async disableLayers() { @@ -80,10 +80,7 @@ class PlaywrightMap { const { stationName, stationItemName, isOrigin } = args; await this.openMapSearch(); await this.searchStation(stationName); - await this.playwrightHomePage.page - .getByRole('button', { name: stationItemName }) - .first() - .click(); + await this.homePage.page.getByRole('button', { name: stationItemName }).first().click(); await this.clickOnMap(); // We don't use ternaries here, as eslint warns us about rule no-unused-expressions if (isOrigin) { @@ -101,5 +98,4 @@ class PlaywrightMap { await this.selectPointOnMap({ ...props, isOrigin: false }); } } - -export default PlaywrightMap; +export default MapPage; diff --git a/front/tests/pages/operational-studies-page-model.ts b/front/tests/pages/operational-studies-page-model.ts new file mode 100644 index 00000000000..e27a8685f4e --- /dev/null +++ b/front/tests/pages/operational-studies-page-model.ts @@ -0,0 +1,52 @@ +import { expect, type Locator, type Page } from '@playwright/test'; + +class OperationalStudiesPage { + readonly addScenarioTrainBtn: Locator; + + readonly getRollingStockTab: Locator; + + readonly getRouteTab: Locator; + + readonly getRollingStockSelector: Locator; + + readonly getEmptyRollingStockSelector: Locator; + + constructor(readonly page: Page) { + this.page = page; + this.addScenarioTrainBtn = page.getByTestId('scenarios-add-train-schedule-button'); + this.getRollingStockTab = page.getByTestId('tab-rollingstock'); + this.getRouteTab = page.getByTestId('tab-pathfinding'); + this.getEmptyRollingStockSelector = page.getByTestId('rollingstock-selector-empty'); + this.getRollingStockSelector = page.getByTestId('rollingstock-selector'); + } + + // Methods + + // Clicks on the button to add a scenario train. + async clickOnAddScenarioTrainBtn() { + await this.addScenarioTrainBtn.click(); + } + + // Verifies that the Rolling Stock and Route tabs have warning classes. + async verifyTabWarningPresence() { + await expect(this.getRollingStockTab).toHaveClass(/warning/); + await expect(this.getRouteTab).toHaveClass(/warning/); + } + + // Verifies that the Rolling Stock and Route tabs do not have warning classes. + async verifyTabWarningAbsence() { + await expect(this.getRollingStockTab).not.toHaveClass(/warning/); + await expect(this.getRouteTab).not.toHaveClass(/warning/); + } + + // Clicks to open the empty rolling stock selector. + async openEmptyRollingStockSelector() { + await this.getEmptyRollingStockSelector.click(); + } + + // Clicks to open the rolling stock selector + async openRollingStockSelector() { + await this.getRollingStockSelector.click(); + } +} +export default OperationalStudiesPage; diff --git a/front/tests/pages/project-page-model.ts b/front/tests/pages/project-page-model.ts index 31df092fc57..1c0680c2e2e 100644 --- a/front/tests/pages/project-page-model.ts +++ b/front/tests/pages/project-page-model.ts @@ -1,9 +1,8 @@ -/* eslint-disable import/prefer-default-export */ import { expect, type Locator, type Page } from '@playwright/test'; import project from '../../public/locales/fr/operationalStudies/project.json'; -export class ProjectPage { +class ProjectPage { // The current page object readonly page: Page; @@ -162,3 +161,4 @@ export class ProjectPage { await this.getProjectDeleteConfirmBtn.click(); } } +export default ProjectPage; diff --git a/front/tests/pages/rollingstock-editor-page-model.ts b/front/tests/pages/rollingstock-editor-page-model.ts index 62e4cd9e1f8..fdb007c3c51 100644 --- a/front/tests/pages/rollingstock-editor-page-model.ts +++ b/front/tests/pages/rollingstock-editor-page-model.ts @@ -1,9 +1,9 @@ import { expect, type Locator, type Page } from '@playwright/test'; -import PlaywrightCommonPage from './common-page-model'; +import CommonPage from './common-page-model'; import { fillAndCheckInputById } from '../utils/index'; -export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPage { +class RollingstockEditorPage extends CommonPage { readonly getNewRollingstockButton: Locator; readonly getSubmitRollingstockButton: Locator; @@ -298,3 +298,4 @@ export default class PlaywrightRollingstockEditorPage extends PlaywrightCommonPa await this.getConfirmModalButtonYes.click(); } } +export default RollingstockEditorPage; diff --git a/front/tests/pages/rolling-stock-selector-page.ts b/front/tests/pages/rollingstock-selector-page.ts similarity index 86% rename from front/tests/pages/rolling-stock-selector-page.ts rename to front/tests/pages/rollingstock-selector-page.ts index 965f92acf16..1baed213696 100644 --- a/front/tests/pages/rolling-stock-selector-page.ts +++ b/front/tests/pages/rollingstock-selector-page.ts @@ -3,7 +3,7 @@ import { type Locator, type Page, expect } from '@playwright/test'; import BasePage from './base-page'; import { extractNumberFromString } from '../utils/index'; -export default class RollingStockSelectorPage extends BasePage { +class RollingStockSelectorPage extends BasePage { readonly rollingStockSelectorButton: Locator; readonly rollingStockSelectorModal: Locator; @@ -36,10 +36,18 @@ export default class RollingStockSelectorPage extends BasePage { readonly getRollingStockList: Locator; - readonly getThermalElectricRollingStockIcons: Locator; + readonly getDualModeRollingStockIcons: Locator; readonly getNoRollingStockResult: Locator; + readonly comfortHeatingButton: Locator; + + readonly comfortACButton: Locator; + + readonly getSelectedComfortType: Locator; + + readonly getSelectedRollingStockName: Locator; + constructor(page: Page) { super(page); this.rollingStockSelectorButton = page.getByTestId('rollingstock-selector'); @@ -57,7 +65,7 @@ export default class RollingStockSelectorPage extends BasePage { this.getRollingStockSearchResult = page.getByTestId('search-results-text'); this.getThermalRollingStockIcons = page.locator('.rollingstock-footer-specs .text-pink'); this.getElectricRollingStockIcons = page.locator('.rollingstock-footer-specs .text-primary'); - this.getThermalElectricRollingStockIcons = page + this.getDualModeRollingStockIcons = page .locator('.rollingstock-footer-specs .rollingstock-tractionmode:has(.text-pink)') .filter({ has: page.locator('.text-primary'), @@ -66,6 +74,10 @@ export default class RollingStockSelectorPage extends BasePage { this.getThermalRollingStockFirstIcon = this.getThermalRollingStockIcons.first(); this.getRollingStockList = page.locator('.rollingstock-editor-list .rollingstock-title'); this.getNoRollingStockResult = page.locator('.rollingstock-empty'); + this.comfortHeatingButton = page.getByTestId('comfort-heating-button'); + this.comfortACButton = page.getByTestId('comfort-ac-button'); + this.getSelectedComfortType = page.getByTestId('selected-comfort-type-info'); + this.getSelectedRollingStockName = page.getByTestId('selected-rolling-stock-info'); } async openRollingstockModal() { @@ -119,3 +131,4 @@ export default class RollingStockSelectorPage extends BasePage { return extractNumberFromString(await this.getRollingStockSearchResult.innerText()); } } +export default RollingStockSelectorPage; diff --git a/front/tests/pages/scenario-page-model.ts b/front/tests/pages/scenario-page-model.ts index 75acb2987ae..900ba9e0aee 100644 --- a/front/tests/pages/scenario-page-model.ts +++ b/front/tests/pages/scenario-page-model.ts @@ -6,7 +6,7 @@ import manageTrainScheduleTranslation from '../../public/locales/fr/operationalS const trainAddedTranslation = manageTrainScheduleTranslation.trainAdded; // TODO: extends simulation-conf-page -class PlaywrightScenarioPage extends BasePage { +class ScenarioPage extends BasePage { readonly getScenarioUpdateBtn: Locator; readonly getScenarioDeleteConfirmBtn: Locator; @@ -320,4 +320,4 @@ class PlaywrightScenarioPage extends BasePage { } } -export default PlaywrightScenarioPage; +export default ScenarioPage; diff --git a/front/tests/pages/simulation-conf-page.ts b/front/tests/pages/simulation-conf-page.ts index c004883e0b7..816d4fe4d51 100644 --- a/front/tests/pages/simulation-conf-page.ts +++ b/front/tests/pages/simulation-conf-page.ts @@ -1,8 +1,8 @@ import { type Locator, type Page, expect } from '@playwright/test'; -import RollingStockSelectorPage from './rolling-stock-selector-page'; +import RollingStockSelectorPage from './rollingstock-selector-page'; -export default class SimulationConfPage extends RollingStockSelectorPage { +class SimulationConfPage extends RollingStockSelectorPage { readonly infraLoadingState: Locator; readonly pathfindingState: Locator; @@ -57,3 +57,4 @@ export default class SimulationConfPage extends RollingStockSelectorPage { await expect(this.pathfindingDoneLabel).toBeVisible(); } } +export default SimulationConfPage; diff --git a/front/tests/pages/stdcm-page-model.ts b/front/tests/pages/stdcm-page-model.ts index 344454a4cb0..e994f1aa5fc 100644 --- a/front/tests/pages/stdcm-page-model.ts +++ b/front/tests/pages/stdcm-page-model.ts @@ -2,7 +2,7 @@ import { expect, type Locator, type Page } from '@playwright/test'; import SimulationConfPage from './simulation-conf-page'; -export default class StdcmPage extends SimulationConfPage { +class StdcmPage extends SimulationConfPage { readonly missingParams: Locator; // Scenario Explorator @@ -72,3 +72,4 @@ export default class StdcmPage extends SimulationConfPage { }); } } +export default StdcmPage; diff --git a/front/tests/pages/study-page-model.ts b/front/tests/pages/study-page-model.ts index 91c8df2d9a0..3e652b1d84b 100644 --- a/front/tests/pages/study-page-model.ts +++ b/front/tests/pages/study-page-model.ts @@ -1,9 +1,8 @@ -/* eslint-disable import/prefer-default-export */ import { expect, type Locator, type Page } from '@playwright/test'; import study from '../../public/locales/fr/operationalStudies/study.json'; -export class StudyPage { +class StudyPage { // The current page object readonly page: Page; @@ -161,3 +160,4 @@ export class StudyPage { await this.getStudyDeleteConfirmBtn.click(); } } +export default StudyPage; diff --git a/front/tests/utils/scenario-utils.ts b/front/tests/utils/scenario-utils.ts index 2dba5487988..92d85d2aa09 100644 --- a/front/tests/utils/scenario-utils.ts +++ b/front/tests/utils/scenario-utils.ts @@ -1,11 +1,11 @@ import { type Page, expect } from '@playwright/test'; import { v4 as uuidv4 } from 'uuid'; -import scenarioData from '../assets/operationStudies/scenario.json'; import { getInfra, getProject, getRollingStock, getStudy, postApiRequest } from '.'; -import { PlaywrightHomePage } from '../pages/home-page-model'; -import RollingStockSelectorPage from '../pages/rolling-stock-selector-page'; -import PlaywrightScenarioPage from '../pages/scenario-page-model'; +import scenarioData from '../assets/operationStudies/scenario.json'; +import HomePage from '../pages/home-page-model'; +import RollingStockSelectorPage from '../pages/rollingstock-selector-page'; +import ScenarioPage from '../pages/scenario-page-model'; // Scenario creation export default async function createCompleteScenario( @@ -29,26 +29,26 @@ export default async function createCompleteScenario( } ); - const playwrightHomePage = new PlaywrightHomePage(page); - const scenarioPage = new PlaywrightScenarioPage(page); + const homePage = new HomePage(page); + const scenarioPage = new ScenarioPage(page); await page.goto( `/operational-studies/projects/${project.id}/studies/${study.id}/scenarios/${scenario.id}` ); - await playwrightHomePage.page.getByTestId('scenarios-add-train-schedule-button').click(); + await homePage.page.getByTestId('scenarios-add-train-schedule-button').click(); await scenarioPage.setTrainScheduleName(trainScheduleName); await scenarioPage.setNumberOfTrains(trainCount); await scenarioPage.setDelta(delta); // ***************** Select Rolling Stock ***************** - const playwrightRollingstockModalPage = new RollingStockSelectorPage(playwrightHomePage.page); - await playwrightRollingstockModalPage.openRollingstockModal(); + const rollingstockModalPage = new RollingStockSelectorPage(homePage.page); + await rollingstockModalPage.openRollingstockModal(); - await playwrightRollingstockModalPage.searchRollingstock('rollingstock_1500_25000_test_e2e'); + await rollingstockModalPage.searchRollingstock('rollingstock_1500_25000_test_e2e'); - const rollingstockCard = playwrightRollingstockModalPage.getRollingstockCardByTestID( + const rollingstockCard = rollingstockModalPage.getRollingstockCardByTestID( `rollingstock-${rollingStock.name}` ); @@ -69,7 +69,7 @@ export default async function createCompleteScenario( // Allowances management export async function allowancesManagement( - scenarioPage: PlaywrightScenarioPage, + scenarioPage: ScenarioPage, scenarioName: string, allowanceType: 'standard' | 'engineering' ) {