Skip to content

Commit

Permalink
front: add second stdcm e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: maymanaf <[email protected]>
  • Loading branch information
Maymanaf committed Nov 6, 2024
1 parent f210505 commit 9f409ec
Show file tree
Hide file tree
Showing 4 changed files with 412 additions and 1 deletion.
5 changes: 5 additions & 0 deletions front/src/assets/rollingStock/freightRollingStocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ const FREIGHT_ROLLING_STOCKS = [
'Y8000AG',
'Y8000AP',
'Y9000US',
'electric_rolling_stock_test_e2e',
'dual-mode_rolling_stock_test_e2e',
'slow_rolling_stock_test_e2e',
'fast_rolling_stock_test_e2e',
'improbable_rolling_stock_test_e2e',
];

export default FREIGHT_ROLLING_STOCKS;
29 changes: 28 additions & 1 deletion front/tests/006-stdcm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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';
Expand All @@ -10,13 +11,17 @@ 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);
});

test.beforeEach('Navigate to the STDCM page', async ({ page }) => {
// Navigate to STDCM page
// Retrieve OSRD language and navigate to STDCM page
const homePage = new HomePage(page);
await homePage.goToHomePage();
OSRDLanguage = await homePage.getOSRDLanguage();
await page.goto('/stdcm');
// Wait for infra to be in 'CACHED' state before proceeding
await waitForInfraStateToBeCached(infra.id);
Expand All @@ -30,4 +35,26 @@ test.describe('Verify train schedule elements and filters', () => {
await stdcmPage.verifyAllFieldsEmpty();
await stdcmPage.addAndDeleteEmptyVia();
});

/** *************** Test 2 **************** */
test('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();
await stdcmPage.fillAndVerifyOriginDetails();
await stdcmPage.fillAndVerifyDestinationDetails(OSRDLanguage);
const viaDetails = [
{ viaNumber: 1, ciSearchValue: 'mid_west' },
{ viaNumber: 2, ciSearchValue: 'mid_east' },
{ viaNumber: 3, ciSearchValue: 'nS', language: OSRDLanguage },
];

for (const { viaNumber, ciSearchValue, language } of viaDetails) {
await stdcmPage.fillAndVerifyViaDetails(viaNumber, ciSearchValue, language);
}

// Launch simulation and verify output data matches expected results
await stdcmPage.launchSimulation(OSRDLanguage);
await stdcmPage.verifyTableData('./tests/assets/stdcm/stdcmAllStops.json');
});
});
52 changes: 52 additions & 0 deletions front/tests/assets/stdcm/stdcmAllStops.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[
{
"index": 1,
"operationalPoint": "North_West_station",
"code": "BC",
"endStop": "",
"passageStop": "",
"startStop": "00:56",
"weight": "400t",
"refEngine": ""
},
{
"index": 2,
"operationalPoint": "Mid_West_station",
"code": "BV",
"endStop": "",
"passageStop": "01:17",
"startStop": "",
"weight": "=",
"refEngine": "="
},
{
"index": 3,
"operationalPoint": "Mid_East_station",
"code": "BV",
"endStop": "01:23",
"passageStop": "3 min",
"startStop": "01:26",
"weight": "=",
"refEngine": "="
},
{
"index": 4,
"operationalPoint": "North_station",
"code": "BV",
"endStop": "01:33",
"passageStop": "4 min",
"startStop": "01:37",
"weight": "=",
"refEngine": "="
},
{
"index": 5,
"operationalPoint": "South_station",
"code": "BV",
"endStop": "01:41",
"passageStop": "",
"startStop": "",
"weight": "400t",
"refEngine": ""
}
]
Loading

0 comments on commit 9f409ec

Please sign in to comment.