-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
front: add e2e test for stdcm linked train simulation
Signed-off-by: maymanaf <[email protected]>
- Loading branch information
Showing
7 changed files
with
391 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import type { Infra, TowedRollingStock } from 'common/api/osrdEditoastApi'; | ||
|
||
import { fastRollingStockName } from './assets/project-const'; | ||
import HomePage from './pages/home-page-model'; | ||
import STDCMLinkedTrainPage from './pages/stdcm-linked-train-page-model'; | ||
import STDCMPage, { type ConsistFields } from './pages/stdcm-page-model'; | ||
import test from './test-logger'; | ||
import { waitForInfraStateToBeCached } from './utils'; | ||
import { getInfra, setTowedRollingStock } from './utils/api-setup'; | ||
|
||
test.use({ | ||
launchOptions: { | ||
slowMo: 500, // Give the interface time to update between actions | ||
}, | ||
}); | ||
test.describe('Verify stdcm simulation page', () => { | ||
test.slow(); // Mark test as slow due to multiple steps | ||
|
||
test.use({ viewport: { width: 1920, height: 1080 } }); | ||
let homePage: HomePage; | ||
let stdcmLinkedTrainPage: STDCMLinkedTrainPage; | ||
let stdcmPage: STDCMPage; | ||
let infra: Infra; | ||
let createdTowedRollingStock: TowedRollingStock; | ||
let towedConsistDetails: ConsistFields; | ||
|
||
const fastRollingStockPrefilledValues = { | ||
tonnage: '190', | ||
length: '46', | ||
maxSpeed: '220', | ||
}; | ||
const towedRollingStockPrefilledValues = { | ||
tonnage: '46', | ||
length: '26', | ||
maxSpeed: '180', | ||
}; | ||
|
||
test.beforeAll('Fetch infrastructure', async () => { | ||
infra = await getInfra(); | ||
createdTowedRollingStock = await setTowedRollingStock(); | ||
towedConsistDetails = { | ||
tractionEngine: fastRollingStockName, | ||
towedRollingStock: createdTowedRollingStock.name, | ||
}; | ||
}); | ||
|
||
test.beforeEach('Navigate to the STDCM page', async ({ page }) => { | ||
[homePage, stdcmPage, stdcmLinkedTrainPage] = [ | ||
new HomePage(page), | ||
new STDCMPage(page), | ||
new STDCMLinkedTrainPage(page), | ||
]; | ||
// Navigate to STDCM page | ||
await page.goto('/stdcm'); | ||
await page.waitForLoadState('domcontentloaded', { timeout: 30_000 }); | ||
await homePage.removeViteOverlay(); | ||
|
||
// Wait for infra to be in 'CACHED' state before proceeding | ||
await waitForInfraStateToBeCached(infra.id); | ||
}); | ||
|
||
/** *************** Test 1 **************** */ | ||
test('Verify STDCM anterior linked train', async ({ browserName }) => { | ||
await stdcmPage.fillAndVerifyConsistDetails( | ||
towedConsistDetails, | ||
fastRollingStockPrefilledValues.tonnage, | ||
fastRollingStockPrefilledValues.length, | ||
fastRollingStockPrefilledValues.maxSpeed, | ||
towedRollingStockPrefilledValues.tonnage, | ||
towedRollingStockPrefilledValues.length, | ||
towedRollingStockPrefilledValues.maxSpeed | ||
); | ||
await stdcmLinkedTrainPage.anteriorLinkedPathDetails(); | ||
await stdcmPage.fillAndVerifyViaDetails({ | ||
viaNumber: 1, | ||
ciSearchText: 'nS', | ||
}); | ||
await stdcmPage.fillDestinationDetailsLight(); | ||
await stdcmPage.launchSimulation(); | ||
await stdcmPage.verifyTableData( | ||
'./tests/assets/stdcm/linkedTrain/anteriorLinkedTrainTable.json' | ||
); | ||
await stdcmPage.retainSimulation(); | ||
await stdcmPage.downloadSimulation(browserName, true); | ||
}); | ||
|
||
/** *************** Test 2 **************** */ | ||
test('Verify STDCM posterior linked train', async ({ browserName }) => { | ||
await stdcmPage.fillAndVerifyConsistDetails( | ||
towedConsistDetails, | ||
fastRollingStockPrefilledValues.tonnage, | ||
fastRollingStockPrefilledValues.length, | ||
fastRollingStockPrefilledValues.maxSpeed, | ||
towedRollingStockPrefilledValues.tonnage, | ||
towedRollingStockPrefilledValues.length, | ||
towedRollingStockPrefilledValues.maxSpeed | ||
); | ||
await stdcmLinkedTrainPage.posteriorLinkedPathDetails(); | ||
await stdcmPage.fillAndVerifyViaDetails({ | ||
viaNumber: 1, | ||
ciSearchText: 'mid_east', | ||
}); | ||
await stdcmPage.fillOriginDetailsLight('respectDestinationSchedule', true); | ||
await stdcmPage.launchSimulation(); | ||
await stdcmPage.verifyTableData( | ||
'./tests/assets/stdcm/linkedTrain/posteriorLinkedTrainTable.json' | ||
); | ||
await stdcmPage.retainSimulation(); | ||
await stdcmPage.downloadSimulation(browserName, true); | ||
}); | ||
}); |
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,43 @@ | ||
const LINKED_TRAIN_DETAILS = { | ||
anterior: { | ||
trainName: 'Train10', | ||
trainDate: '17/10/24', | ||
trainDetails: [ | ||
{ | ||
trainName: 'Train10', | ||
segments: [ | ||
['17/10/24', '11:45', 'South_East_station', 'SES'], | ||
['17/10/24', '11:59', 'Mid_East_station', 'MES'], | ||
], | ||
}, | ||
], | ||
dynamicOriginCi: 'MES Mid_East_station', | ||
dynamicOriginCh: 'BV', | ||
originArrival: 'preciseTime', | ||
dateOriginArrival: '17/10/24', | ||
timeOriginArrival: '12:29', | ||
toleranceOriginArrival: '-30/+30', | ||
toleranceFields: { min: '-15', max: '+15', isAnterior: true }, | ||
}, | ||
posterior: { | ||
trainName: 'TrAiN14', | ||
trainDate: '17/10/24', | ||
trainDetails: [ | ||
{ | ||
trainName: 'Train14', | ||
segments: [ | ||
['17/10/24', '14:10', 'North_East_station', 'NES'], | ||
['17/10/24', '14:17', 'Mid_East_station', 'MES'], | ||
], | ||
}, | ||
], | ||
dynamicDestinationCi: 'NES North_East_station', | ||
dynamicDestinationCh: 'BV', | ||
destinationArrival: 'preciseTime', | ||
dateDestinationArrival: '17/10/24', | ||
timeDestinationArrival: '13:40', | ||
toleranceDestinationArrival: '-30/+30', | ||
toleranceFields: { min: '-05', max: '+10', isAnterior: false }, | ||
}, | ||
}; | ||
export default LINKED_TRAIN_DETAILS; |
32 changes: 32 additions & 0 deletions
32
front/tests/assets/stdcm/linkedTrain/anteriorLinkedTrainTable.json
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,32 @@ | ||
[ | ||
{ | ||
"index": 1, | ||
"operationalPoint": "Mid_East_station", | ||
"code": "BV", | ||
"endStop": "", | ||
"passageStop": "", | ||
"startStop": "12:29", | ||
"weight": "236t", | ||
"refEngine": "" | ||
}, | ||
{ | ||
"index": 2, | ||
"operationalPoint": "North_station", | ||
"code": "BV", | ||
"endStop": "13:18", | ||
"passageStop": "4 min", | ||
"startStop": "13:22", | ||
"weight": "=", | ||
"refEngine": "=" | ||
}, | ||
{ | ||
"index": 5, | ||
"operationalPoint": "South_station", | ||
"code": "BV", | ||
"endStop": "13:43", | ||
"passageStop": "", | ||
"startStop": "", | ||
"weight": "236t", | ||
"refEngine": "" | ||
} | ||
] |
32 changes: 32 additions & 0 deletions
32
front/tests/assets/stdcm/linkedTrain/posteriorLinkedTrainTable.json
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,32 @@ | ||
[ | ||
{ | ||
"index": 1, | ||
"operationalPoint": "North_West_station", | ||
"code": "BV", | ||
"endStop": "", | ||
"passageStop": "", | ||
"startStop": "11:11", | ||
"weight": "236t", | ||
"refEngine": "" | ||
}, | ||
{ | ||
"index": 2, | ||
"operationalPoint": "Mid_East_station", | ||
"code": "BV", | ||
"endStop": "12:38", | ||
"passageStop": "3 min", | ||
"startStop": "12:41", | ||
"weight": "=", | ||
"refEngine": "=" | ||
}, | ||
{ | ||
"index": 5, | ||
"operationalPoint": "North_East_station", | ||
"code": "BV", | ||
"endStop": "13:40", | ||
"passageStop": "", | ||
"startStop": "", | ||
"weight": "236t", | ||
"refEngine": "" | ||
} | ||
] |
Oops, something went wrong.