Skip to content

Commit

Permalink
front: fix stdcm e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: maymanaf <[email protected]>
  • Loading branch information
Maymanaf authored and Wadjetz committed Jan 8, 2025
1 parent 5de9d7e commit 68c10f1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 33 deletions.
6 changes: 3 additions & 3 deletions front/tests/006-stdcm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ test.describe('Verify train schedule elements and filters', () => {
let infra: Infra;
let OSRDLanguage: string;
let createdTowedRollingStock: TowedRollingStock;
const UPDATED_TONNAGE = '561';
const UPDATED_TONNAGE = '1061';
const consistDetails: ConsistFields = {
tractionEngine: electricRollingStockName,
tonnage: '400',
length: '300',
tonnage: '950',
length: '567',
maxSpeed: '180',
speedLimitTag: 'HLP',
};
Expand Down
14 changes: 7 additions & 7 deletions front/tests/assets/stdcm/stdcmAllStops.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"endStop": "",
"passageStop": "",
"startStop": "00:55",
"weight": "400t",
"weight": "950t",
"refEngine": ""
},
{
Expand All @@ -23,30 +23,30 @@
"index": 3,
"operationalPoint": "Mid_East_station",
"code": "BV",
"endStop": "01:21",
"endStop": "01:22",
"passageStop": "3 min",
"startStop": "01:24",
"startStop": "01:25",
"weight": "=",
"refEngine": "="
},
{
"index": 4,
"operationalPoint": "North_station",
"code": "BV",
"endStop": "01:32",
"endStop": "01:33",
"passageStop": "4 min",
"startStop": "01:36",
"startStop": "01:37",
"weight": "=",
"refEngine": "="
},
{
"index": 5,
"operationalPoint": "South_station",
"code": "BV",
"endStop": "01:39",
"endStop": "01:41",
"passageStop": "",
"startStop": "",
"weight": "400t",
"weight": "950t",
"refEngine": ""
}
]
8 changes: 4 additions & 4 deletions front/tests/assets/stdcm/stdcmWithAllVia.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"endStop": "",
"passageStop": "",
"startStop": "20:21",
"weight": "400t",
"weight": "950t",
"refEngine": ""
},
{
Expand Down Expand Up @@ -34,7 +34,7 @@
"operationalPoint": "North_station",
"code": "BV",
"endStop": "",
"passageStop": "20:52",
"passageStop": "20:53",
"startStop": "",
"weight": "=",
"refEngine": "="
Expand All @@ -43,10 +43,10 @@
"index": 5,
"operationalPoint": "South_station",
"code": "BV",
"endStop": "20:56",
"endStop": "20:57",
"passageStop": "",
"startStop": "",
"weight": "400t",
"weight": "950t",
"refEngine": ""
}
]
6 changes: 3 additions & 3 deletions front/tests/assets/stdcm/stdcmWithoutAllVia.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"endStop": "",
"passageStop": "",
"startStop": "20:21",
"weight": "400t",
"weight": "950t",
"refEngine": ""
},
{
Expand All @@ -23,10 +23,10 @@
"index": 3,
"operationalPoint": "South_station",
"code": "BV",
"endStop": "20:56",
"endStop": "20:57",
"passageStop": "",
"startStop": "",
"weight": "400t",
"weight": "950t",
"refEngine": ""
}
]
34 changes: 18 additions & 16 deletions front/tests/pages/stdcm-page-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface ConsistFields {
speedLimitTag?: string;
}
const EXPECT_TO_PASS_TIMEOUT = 90_000; // Since toPass ignores custom expect timeouts, this timeout is set to account for all actions within the function.

const MINIMUM_SIMULATION_NUMBER = 1;
class STDCMPage {
readonly page: Page;

Expand Down Expand Up @@ -606,21 +606,23 @@ class STDCMPage {
}

// Launch the simulation and check if simulation-related elements are visible
async launchSimulation() {
await expect(async () => {
await this.launchSimulationButton.waitFor();
await expect(this.launchSimulationButton).toBeEnabled();
await this.launchSimulationButton.click({ force: true });
const simulationElements = await this.simulationList.all();
await Promise.all(simulationElements.map((simulationElement) => simulationElement.waitFor()));
expect(await this.simulationList.count()).toBeGreaterThanOrEqual(1);
// Check map result container visibility only for Chromium browser
if (this.page.context().browser()?.browserType().name() === 'chromium') {
await expect(this.mapResultContainer).toBeVisible();
}
}).toPass({
timeout: EXPECT_TO_PASS_TIMEOUT,
});
async launchSimulation(): Promise<void> {
await this.launchSimulationButton.waitFor({ state: 'visible' });
await expect(this.launchSimulationButton).toBeEnabled();
await this.launchSimulationButton.click({ force: true });
// Wait for simulation elements to load and validate their presence
await this.simulationList.waitFor({ timeout: 60_000 });
const simulationElements = await this.simulationList.all();

if (simulationElements.length < MINIMUM_SIMULATION_NUMBER) {
throw new Error(
`Expected at least ${MINIMUM_SIMULATION_NUMBER} simulation, but found ${simulationElements.length}.`
);
}
// Check map result container visibility only for Chromium browser
if (this.page.context().browser()?.browserType().name() === 'chromium') {
await expect(this.mapResultContainer).toBeVisible();
}
}

async verifyTableData(tableDataPath: string): Promise<void> {
Expand Down

0 comments on commit 68c10f1

Please sign in to comment.