Skip to content

Commit

Permalink
front: add download stdcm simulation sheet e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: maymanaf <[email protected]>

front: add fourth stdcm e2e test

Signed-off-by: maymanaf <[email protected]>
  • Loading branch information
Maymanaf committed Nov 20, 2024
1 parent 675e227 commit a83782f
Show file tree
Hide file tree
Showing 24 changed files with 419 additions and 144 deletions.
2 changes: 2 additions & 0 deletions front/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export default defineConfig({
trace: 'on-first-retry',
video: 'on-first-retry',

/* Set locale and timezone */
locale: 'fr',
timezoneId: 'Europe/Paris',
},
reporter: process.env.CI ? 'github' : [['line'], ['html']],

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const StcdmResultsTable = ({
<div className={cx('results-buttons', { 'simulation-retained': isSimulationRetained })}>
<div className="button-display-all-PR">
<Button
data-testid="all-via-button"
data-testid="all-vias-button"
variant="Normal"
label={
showAllOP
Expand Down
6 changes: 3 additions & 3 deletions front/tests/005-operational-studies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
Study,
} from 'common/api/osrdEditoastApi';

import { electricRollingStockName, infrastructureName } from './assets/project-const';
import { electricRollingStockName } from './assets/project-const';
import RoutePage from './pages/op-route-page-model';
import OperationalStudiesPage from './pages/operational-studies-page-model';
import RollingStockSelectorPage from './pages/rollingstock-selector-page-model';
Expand All @@ -26,9 +26,9 @@ test.describe('Verify simulation configuration in operational studies', () => {
let infra: Infra;
let rollingStock: LightRollingStock;

test.beforeAll('Fetch rolling stock ', async () => {
test.beforeAll('Fetch rolling stock and infrastructure ', async () => {
rollingStock = await getRollingStock(electricRollingStockName);
infra = await getInfra(infrastructureName);
infra = await getInfra();
});

test.beforeEach('Set up the project, study, and scenario', async () => {
Expand Down
45 changes: 40 additions & 5 deletions front/tests/006-stdcm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import type { Infra } from 'common/api/osrdEditoastApi';

import { infrastructureName } from './assets/project-const';
import HomePage from './pages/home-page-model';
import STDCMPage from './pages/stdcm-page-model';
import test from './test-logger';
import { waitForInfraStateToBeCached } from './utils';
import { getInfra } from './utils/api-setup';

test.use({
launchOptions: {
slowMo: 500, // Give the interface time to update between actions
},
});
test.describe('Verify train schedule elements and filters', () => {
test.slow(); // Mark test as slow due to multiple steps

let infra: Infra;
let OSRDLanguage: string;

test.beforeAll('Fetch infrastructure', async () => {
infra = await getInfra(infrastructureName);
infra = await getInfra();
});

test.beforeEach('Navigate to the STDCM page', async ({ page }) => {
Expand All @@ -23,12 +27,14 @@ test.describe('Verify train schedule elements and filters', () => {
await homePage.goToHomePage();
OSRDLanguage = await homePage.getOSRDLanguage();
await page.goto('/stdcm');
await page.waitForLoadState('load', { timeout: 30 * 1000 });

// Wait for infra to be in 'CACHED' state before proceeding
await waitForInfraStateToBeCached(infra.id);
});

/** *************** Test 1 **************** */
test('Empty STDCM page', async ({ page }) => {
test('Verify empty STDCM page', async ({ page }) => {
// Verify visibility of STDCM elements and handle empty via fields
const stdcmPage = new STDCMPage(page);
await stdcmPage.verifyStdcmElementsVisibility();
Expand All @@ -37,7 +43,7 @@ test.describe('Verify train schedule elements and filters', () => {
});

/** *************** Test 2 **************** */
test('STDCM simulation with all stops', async ({ page }) => {
test('Launch STDCM simulation with all stops', async ({ page }) => {
// Populate STDCM page with origin, destination, and via details, then verify
const stdcmPage = new STDCMPage(page);
await stdcmPage.fillConsistDetails();
Expand All @@ -54,7 +60,36 @@ test.describe('Verify train schedule elements and filters', () => {
}

// Launch simulation and verify output data matches expected results
await stdcmPage.launchSimulation(OSRDLanguage);
await stdcmPage.launchSimulation();
await stdcmPage.verifyTableData('./tests/assets/stdcm/stdcmAllStops.json');
});

/** *************** Test 3 **************** */
test('Verify STDCM stops and simulation sheet', async ({ page, browserName }) => {
// Populate STDCM page with origin, destination, and via details
const stdcmPage = new STDCMPage(page);
await stdcmPage.fillConsistDetails();
await stdcmPage.fillOriginDetailsLight();
await stdcmPage.fillDestinationDetailsLight();
await stdcmPage.fillAndVerifyViaDetails(1, 'mid_west');
// Verify input map markers in Chromium
if (browserName === 'chromium') {
await stdcmPage.mapMarkerVisibility();
}
// Launch simulation and verify output data matches expected results
await stdcmPage.launchSimulation();
// Verify map results markers in Chromium
if (browserName === 'chromium') {
await stdcmPage.mapMarkerResultVisibility();
}
await stdcmPage.verifyTableData('./tests/assets/stdcm/stdcmWithoutAllVia.json');
await stdcmPage.clickOnAllViaButton();
await stdcmPage.verifyTableData('./tests/assets/stdcm/stdcmWithAllVia.json');
await stdcmPage.retainSimulation();
await stdcmPage.downloadSimulation(browserName);
// Reset and verify empty fields
await stdcmPage.clickOnStartNewQueryButton();
// TODO: Uncomment the check when the bug #9533 is fixed
// await stdcmPage.verifyAllFieldsEmpty();
});
});
17 changes: 13 additions & 4 deletions front/tests/007-op-rollingstock-tab.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { expect } from '@playwright/test';

import type { LightRollingStock, Project, Scenario, Study } from 'common/api/osrdEditoastApi';
import type {
Infra,
LightRollingStock,
Project,
Scenario,
Study,
} from 'common/api/osrdEditoastApi';

import { dualModeRollingStockName, electricRollingStockName } from './assets/project-const';
import OperationalStudiesPage from './pages/operational-studies-page-model';
import RollingStockSelectorPage from './pages/rollingstock-selector-page-model';
import test from './test-logger';
import { getRollingStock } from './utils/api-setup';
import { waitForInfraStateToBeCached } from './utils';
import { getInfra, getRollingStock } from './utils/api-setup';
import createScenario from './utils/scenario';
import { deleteScenario } from './utils/teardown-utils';

Expand All @@ -15,23 +22,25 @@ test.describe('Rolling stock Tab Verification', () => {
let study: Study;
let scenario: Scenario;
let rollingStock: LightRollingStock;
let infra: Infra;

test.beforeAll('Set up a scenario before all tests', async () => {
rollingStock = await getRollingStock(electricRollingStockName);
({ project, study, scenario } = await createScenario());
infra = await getInfra();
});

test.afterAll('Delete the created scenario', async () => {
await deleteScenario(project.id, study.id, scenario.name);
});

test.beforeEach('Navigate to the scenario page', async ({ page }) => {
const operationalStudiesPage = new OperationalStudiesPage(page);
await page.goto(
`/operational-studies/projects/${project.id}/studies/${study.id}/scenarios/${scenario.id}`
);
// Ensure infrastructure is loaded before each test
await operationalStudiesPage.checkInfraLoaded();
// Wait for infra to be in 'CACHED' state before proceeding
await waitForInfraStateToBeCached(infra.id);
});

/** *************** Test 1 **************** */
Expand Down
15 changes: 7 additions & 8 deletions front/tests/008-train-schedule.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { Scenario, Project, Study, Infra } from 'common/api/osrdEditoastApi';

import {
infrastructureName,
stdcmProjectName,
stdcmScenarioName,
stdcmStudyName,
trainScheduleProjectName,
trainScheduleScenarioName,
trainScheduleStudyName,
} from './assets/project-const';
import HomePage from './pages/home-page-model';
import OperationalStudiesTimetablePage from './pages/op-timetable-page-model';
Expand All @@ -29,10 +28,10 @@ test.describe('Verify train schedule elements and filters', () => {
const VALID_AND_HONORED_TRAINS = 13;
const INVALID_AND_NOT_HONORED_TRAINS = 0;
test.beforeAll('Fetch project, study and scenario with train schedule', async () => {
project = await getProject(stdcmProjectName);
study = await getStudy(project.id, stdcmStudyName);
scenario = await getScenario(project.id, study.id, stdcmScenarioName);
infra = await getInfra(infrastructureName);
project = await getProject(trainScheduleProjectName);
study = await getStudy(project.id, trainScheduleStudyName);
scenario = await getScenario(project.id, study.id, trainScheduleScenarioName);
infra = await getInfra();
});

test.beforeEach('Navigate to scenario page before each test', async ({ page }) => {
Expand Down
10 changes: 7 additions & 3 deletions front/tests/010-op-route-tab.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type { Project, Scenario, Study } from 'common/api/osrdEditoastApi';
import type { Infra, Project, Scenario, Study } from 'common/api/osrdEditoastApi';

import { electricRollingStockName } from './assets/project-const';
import HomePage from './pages/home-page-model';
import RoutePage from './pages/op-route-page-model';
import OperationalStudiesPage from './pages/operational-studies-page-model';
import RollingStockSelectorPage from './pages/rollingstock-selector-page-model';
import test from './test-logger';
import { waitForInfraStateToBeCached } from './utils';
import { getInfra } from './utils/api-setup';
import createScenario from './utils/scenario';
import { deleteScenario } from './utils/teardown-utils';

Expand All @@ -15,9 +17,11 @@ test.describe('Route Tab Verification', () => {
let study: Study;
let scenario: Scenario;
let OSRDLanguage: string;
let infra: Infra;

test.beforeAll('Set up the scenario', async () => {
({ project, study, scenario } = await createScenario());
infra = await getInfra();
});

test.afterAll('Delete the created scenario', async () => {
Expand All @@ -40,8 +44,8 @@ test.describe('Route Tab Verification', () => {
`/operational-studies/projects/${project.id}/studies/${study.id}/scenarios/${scenario.id}`
);

// Verify that the infrastructure is correctly loaded
await operationalStudiesPage.checkInfraLoaded();
// Wait for infra to be in 'CACHED' state before proceeding
await waitForInfraStateToBeCached(infra.id);

// Click on add train button and verify tab warnings
await operationalStudiesPage.clickOnAddTrainButton();
Expand Down
4 changes: 2 additions & 2 deletions front/tests/011-op-times-and-stops-tab.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from '@playwright/test';

import type { Infra, Project, Scenario, Study } from 'common/api/osrdEditoastApi';

import { dualModeRollingStockName, infrastructureName } from './assets/project-const';
import { dualModeRollingStockName } from './assets/project-const';
import HomePage from './pages/home-page-model';
import OperationalStudiesInputTablePage from './pages/op-input-table-page-model';
import OperationalStudiesOutputTablePage from './pages/op-output-table-page-model';
Expand Down Expand Up @@ -64,7 +64,7 @@ test.describe('Times and Stops Tab Verification', () => {
type TranslationKeys = keyof typeof enTranslations;

test.beforeAll('Fetch infrastructure', async () => {
infra = await getInfra(infrastructureName);
infra = await getInfra();
});

test.beforeEach(
Expand Down
4 changes: 2 additions & 2 deletions front/tests/012-op-simulation-settings-tab.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
Study,
} from 'common/api/osrdEditoastApi';

import { improbableRollingStockName, infrastructureName } from './assets/project-const';
import { improbableRollingStockName } from './assets/project-const';
import HomePage from './pages/home-page-model';
import OperationalStudiesInputTablePage from './pages/op-input-table-page-model';
import OperationalStudiesOutputTablePage from './pages/op-output-table-page-model';
Expand Down Expand Up @@ -75,7 +75,7 @@ test.describe('Simulation Settings Tab Verification', () => {

test.beforeAll('Add electrical profile via API and fetch infrastructure', async () => {
electricalProfileSet = await setElectricalProfile();
infra = await getInfra(infrastructureName);
infra = await getInfra();
});

test.afterAll('Delete the electrical profile', async () => {
Expand Down
6 changes: 3 additions & 3 deletions front/tests/assets/project-const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export const slowRollingStockName = 'slow_rolling_stock_test_e2e';
export const fastRollingStockName = 'fast_rolling_stock_test_e2e';
export const improbableRollingStockName = 'improbable_rolling_stock_test_e2e';
export const infrastructureName = 'small_infra_test_e2e';
export const stdcmProjectName = 'STDCM_project_test_e2e';
export const trainScheduleProjectName = 'TS_project_test_e2e';
export const globalProjectName = 'project_test_e2e';
export const globalStudyName = 'study_test_e2e';
export const stdcmStudyName = 'STDCM_study_test_e2e';
export const stdcmScenarioName = 'STDCM_scenario_test_e2e';
export const trainScheduleStudyName = 'TS_study_test_e2e';
export const trainScheduleScenarioName = 'TS_scenario_test_e2e';

const ROLLING_STOCK_NAMES = [
electricRollingStockName,
Expand Down
52 changes: 52 additions & 0 deletions front/tests/assets/stdcm/stdcmWithAllVia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[
{
"index": 1,
"operationalPoint": "North_West_station",
"code": "BV",
"endStop": "",
"passageStop": "",
"startStop": "20:21",
"weight": "400t",
"refEngine": ""
},
{
"index": 2,
"operationalPoint": "Mid_West_station",
"code": "BV",
"endStop": "",
"passageStop": "20:42",
"startStop": "",
"weight": "=",
"refEngine": "="
},
{
"index": 3,
"operationalPoint": "Mid_East_station",
"code": "BV",
"endStop": "",
"passageStop": "20:47",
"startStop": "",
"weight": "=",
"refEngine": "="
},
{
"index": 4,
"operationalPoint": "North_station",
"code": "BV",
"endStop": "",
"passageStop": "20:53",
"startStop": "",
"weight": "=",
"refEngine": "="
},
{
"index": 5,
"operationalPoint": "South_station",
"code": "BV",
"endStop": "20:57",
"passageStop": "",
"startStop": "",
"weight": "400t",
"refEngine": ""
}
]
32 changes: 32 additions & 0 deletions front/tests/assets/stdcm/stdcmWithoutAllVia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"index": 1,
"operationalPoint": "North_West_station",
"code": "BV",
"endStop": "",
"passageStop": "",
"startStop": "20:21",
"weight": "400t",
"refEngine": ""
},
{
"index": 2,
"operationalPoint": "Mid_West_station",
"code": "BV",
"endStop": "",
"passageStop": "20:42",
"startStop": "",
"weight": "=",
"refEngine": "="
},
{
"index": 3,
"operationalPoint": "South_station",
"code": "BV",
"endStop": "20:57",
"passageStop": "",
"startStop": "",
"weight": "400t",
"refEngine": ""
}
]
Loading

0 comments on commit a83782f

Please sign in to comment.