Skip to content

Commit d8eec98

Browse files
committed
front: verify rolling stock details table in e2e test
Signed-off-by: Alice Khoudli <alice.khoudli@polytechnique.org>
1 parent 18ee1f9 commit d8eec98

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

front/tests/009-rollingstock-editor.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ test.describe('Rollingstock editor page tests', () => {
9494

9595
// Verify rolling stock details
9696
await rollingStockEditorPage.searchRollingStock(uniqueRollingStockName);
97+
await rollingStockEditorPage.verifyRollingStockDetailsTable(rollingstockDetails.expectedValues);
9798
await rollingStockEditorPage.editRollingStock(uniqueRollingStockName);
9899
for (const input of rollingstockDetails.inputs) {
99100
const value = input.id === 'name' ? uniqueRollingStockName : input.value;
@@ -145,6 +146,9 @@ test.describe('Rollingstock editor page tests', () => {
145146
// Submit and verify modification
146147
await rollingStockEditorPage.submitRollingStock();
147148
await rollingStockEditorPage.searchRollingStock(uniqueUpdatedRollingStockName);
149+
await rollingStockEditorPage.verifyRollingStockDetailsTable(
150+
rollingstockDetails.updatedExpectedValues
151+
);
148152
await rollingStockEditorPage.editRollingStock(uniqueUpdatedRollingStockName);
149153
await deleteRollingStocks([uniqueUpdatedRollingStockName]);
150154
});

front/tests/assets/rollingStock/rollingstockDetails.json

+31-1
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,35 @@
6969
"additionalDetails": {
7070
"electricalPowerStartupTime": 1,
7171
"raisePantographTime": 20
72-
}
72+
},
73+
"expectedValues": [
74+
{ "id": "startupTime", "value": "5s" },
75+
{ "id": "startupAcceleration", "value": "0.1m/s²" },
76+
{ "id": "comfortAcceleration", "value": "1m/s²" },
77+
{ "id": "inertiaCoefficient", "value": "1" },
78+
{ "id": "constGamma", "value": "1m/s²" },
79+
{ "id": "basePowerClass", "value": "7" },
80+
{ "id": "rollingResistanceA", "value": "15kN" },
81+
{ "id": "rollingResistanceB", "value": "0.3kN/(km/h)" },
82+
{ "id": "rollingResistanceC", "value": "0.005kN/(km/h)²" },
83+
{ "id": "loadingGauge", "value": "GA" },
84+
{ "id": "rollingResistance", "value": "R(v) = a + bv + cv²" },
85+
{ "id": "primaryCategory", "value": "NIGHT_TRAIN", "isTranslated": true },
86+
{ "id": "otherCategories", "value": ["FREIGHT_TRAIN", "WORK_TRAIN"], "isTranslated": true }
87+
],
88+
"updatedExpectedValues": [
89+
{ "id": "startupTime", "value": "4s" },
90+
{ "id": "startupAcceleration", "value": "0.11m/s²" },
91+
{ "id": "comfortAcceleration", "value": "0.99m/s²" },
92+
{ "id": "inertiaCoefficient", "value": "1.3000000000000005" },
93+
{ "id": "constGamma", "value": "1.1m/s²" },
94+
{ "id": "basePowerClass", "value": "6" },
95+
{ "id": "rollingResistanceA", "value": "13kN" },
96+
{ "id": "rollingResistanceB", "value": "0.23kN/(km/h)" },
97+
{ "id": "rollingResistanceC", "value": "0.002kN/(km/h)²" },
98+
{ "id": "loadingGauge", "value": "G1" },
99+
{ "id": "rollingResistance", "value": "R(v) = a + bv + cv²" },
100+
{ "id": "primaryCategory", "value": "WORK_TRAIN", "isTranslated": true },
101+
{ "id": "otherCategories", "value": ["HIGH_SPEED_TRAIN"], "isTranslated": true }
102+
]
73103
}

front/tests/pages/rollingstock-editor-page-model.ts

+31
Original file line numberDiff line numberDiff line change
@@ -348,5 +348,36 @@ class RollingstockEditorPage extends CommonPage {
348348
await this.deleteRollingStockButton.click();
349349
await this.confirmModalButtonYes.click();
350350
}
351+
352+
// Verify rolling stock details table
353+
async verifyRollingStockDetailsTable(
354+
expectedValues: { id: string; value: string | string[]; isTranslated?: boolean }[]
355+
) {
356+
for (const { id, value, isTranslated } of expectedValues) {
357+
let expectedValue = value;
358+
// Convert translated fields
359+
if (isTranslated) {
360+
if (Array.isArray(value)) {
361+
expectedValue = value.map(
362+
(v) => this.translations.categoriesOptions[v] || this.translations[v]
363+
);
364+
} else {
365+
expectedValue = this.translations.categoriesOptions[value] || this.translations[value];
366+
}
367+
}
368+
369+
// Locate and verify values
370+
const row = this.page.getByRole('row', { name: this.translations[id] }).first();
371+
await expect(row).toBeVisible();
372+
373+
const valueCell = row.getByRole('cell').nth(1);
374+
await expect(valueCell).toBeVisible();
375+
376+
const actualValue = await valueCell.textContent();
377+
expect(actualValue?.trim()).toBe(
378+
Array.isArray(expectedValue) ? expectedValue.join(', ') : expectedValue.toString()
379+
);
380+
}
381+
}
351382
}
352383
export default RollingstockEditorPage;

front/tests/utils/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ export type RollingStockDetails = {
161161
speedEffortDataC1: { velocity: string; effort: string }[];
162162
speedEffortDataUpdated: { velocity: string; effort: string }[];
163163
additionalDetails: { electricalPowerStartupTime: number; raisePantographTime: number };
164+
expectedValues: { id: string; value: string | string[]; isTranslated?: boolean }[];
165+
updatedExpectedValues: { id: string; value: string | string[]; isTranslated?: boolean }[];
164166
};
165167

166168
export type ProjectData = {

0 commit comments

Comments
 (0)