Skip to content

Commit 1273f3a

Browse files
committed
front: refacto op tables tests
Signed-off-by: maymanaf <med.aymen.naf@gmail.com>
1 parent 0d78204 commit 1273f3a

32 files changed

+463
-457
lines changed

front/src/common/BootstrapSNCF/SelectImprovedSNCF.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function SelectImproved<T extends string | SelectOptionObject>({
171171
</div>
172172
)}
173173
<div
174-
id="-selecttoggle"
174+
id="select-toggle"
175175
className={cx('select-menu', {
176176
'add-border-top': noTogglingHeader,
177177
'position-relative': blockMenu,

front/tests/001-home-page.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,25 @@ test.describe('Home page OSRD', () => {
3737
});
3838

3939
/** *************** Test 2 **************** */
40-
test('Verify redirection to to the Operational Studies page', async () => {
40+
test('Verify redirection to the Operational Studies page', async () => {
4141
await homePage.goToOperationalStudiesPage();
4242
await expect(homePage.page).toHaveURL(/.*\/operational-studies/); // Check the URL
4343
});
4444

4545
/** *************** Test 3 **************** */
46-
test('Verify redirection toto the Map page', async () => {
46+
test('Verify redirection to the Map page', async () => {
4747
await homePage.goToCartoPage();
4848
await expect(homePage.page).toHaveURL(/.*\/map/);
4949
});
5050

5151
/** *************** Test 4 **************** */
52-
test('Verify redirection to to the Infrastructure editor page', async () => {
52+
test('Verify redirection to the Infrastructure editor page', async () => {
5353
await homePage.goToEditorPage();
5454
await expect(homePage.page).toHaveURL(/.*\/editor\/*/);
5555
});
5656

5757
/** *************** Test 5 **************** */
58-
test('Verify redirection to to the STDCM page', async ({ context }) => {
58+
test('Verify redirection to the STDCM page', async ({ context }) => {
5959
const stdcmPage = await homePage.goToSTDCMPage(context);
6060
await expect(stdcmPage).toHaveURL(/.*\/stdcm/);
6161
});

front/tests/003-study-management.spec.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ test.describe('Validate the Study creation workflow', () => {
3030
/** *************** Test 1 **************** */
3131
test('Create a new study', async ({ page }) => {
3232
const studyPage = new StudyPage(page);
33-
await page.goto(`/operational-studies/projects/${project.id}`); // Navigate to project page
33+
// Navigate to project page
34+
await page.goto(`/operational-studies/projects/${project.id}`);
3435

3536
// Set translations based on the language
3637
const translations = OSRDLanguage === 'English' ? enTranslations : frTranslations;
@@ -71,11 +72,11 @@ test.describe('Validate the Study creation workflow', () => {
7172

7273
/** *************** Test 2 **************** */
7374
test('Update an existing study', async ({ page }) => {
75+
const studyPage = new StudyPage(page);
7476
// Create a study
7577
study = await createStudy(project.id, generateUniqueName(studyData.name));
76-
const studyPage = new StudyPage(page);
77-
await page.goto(`/operational-studies/projects/${project.id}/studies/${study.id}`); // Navigate to study page
78-
78+
// Navigate to study page
79+
await page.goto(`/operational-studies/projects/${project.id}/studies/${study.id}`);
7980
const translations = OSRDLanguage === 'English' ? enTranslations : frTranslations;
8081
const tomorrowDateISO = new Date(Date.now() + 86400000).toISOString().split('T')[0]; // Get tomorrow's date in ISO format
8182
const expectedDate = formatDateToDayMonthYear(tomorrowDateISO);

front/tests/004-scenario-management.spec.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { expect } from '@playwright/test';
33
import type { ElectricalProfileSet, Project, Scenario, Study } from 'common/api/osrdEditoastApi';
44

55
import scenarioData from './assets/operationStudies/scenario.json';
6+
import { infrastructureName } from './assets/project_const';
67
import ScenarioPage from './pages/scenario-page-model';
78
import test from './test-logger';
89
import { generateUniqueName } from './utils';
@@ -39,7 +40,7 @@ test.describe('Validate the Scenario creation workflow', () => {
3940
await scenarioPage.createScenario({
4041
name: scenarioName,
4142
description: scenarioData.description,
42-
infraName: 'small_infra_test_e2e',
43+
infraName: infrastructureName,
4344
tags: scenarioData.tags,
4445
electricProfileName: electricalProfileSet.name,
4546
});
@@ -48,7 +49,7 @@ test.describe('Validate the Scenario creation workflow', () => {
4849
await scenarioPage.validateScenarioData({
4950
name: scenarioName,
5051
description: scenarioData.description,
51-
infraName: 'small_infra_test_e2e',
52+
infraName: infrastructureName,
5253
});
5354
await deleteScenario(project.id, study.id, scenarioName);
5455
});
@@ -85,7 +86,7 @@ test.describe('Validate the Scenario creation workflow', () => {
8586
await scenarioPage.validateScenarioData({
8687
name: updatedScenarioName,
8788
description: `${scenario.description} (updated)`,
88-
infraName: 'small_infra_test_e2e',
89+
infraName: infrastructureName,
8990
});
9091

9192
// Delete the scenario

front/tests/005-operational-studies.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expect } from '@playwright/test';
22

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

5+
import { electricRollingStockName } from './assets/project_const';
56
import RoutePage from './pages/op-route-page-model';
67
import OperationalStudiesPage from './pages/operational-studies-page-model';
78
import RollingStockSelectorPage from './pages/rollingstock-selector-page-model';
@@ -17,7 +18,7 @@ test.describe('Verify simulation configuration in operational studies', () => {
1718
let rollingStock: LightRollingStock;
1819

1920
test.beforeAll('Fetch rolling stock ', async () => {
20-
rollingStock = await getRollingStock('electric_rolling_stock_test_e2e');
21+
rollingStock = await getRollingStock(electricRollingStockName);
2122
});
2223

2324
test.beforeEach('Set up the project, study, and scenario', async () => {

front/tests/007-op-rollingstock-tab.spec.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { expect } from '@playwright/test';
22

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

5+
import { dualModeRollingStockName, electricRollingStockName } from './assets/project_const';
56
import OperationalStudiesPage from './pages/operational-studies-page-model';
67
import RollingStockSelectorPage from './pages/rollingstock-selector-page-model';
78
import test from './test-logger';
@@ -15,9 +16,6 @@ test.describe('Rolling stock Tab Verification', () => {
1516
let scenario: Scenario;
1617
let rollingStock: LightRollingStock;
1718

18-
const dualModeRollingStockName = 'dual-mode_rolling_stock_test_e2e';
19-
const electricRollingStockName = 'electric_rolling_stock_test_e2e';
20-
2119
test.beforeAll('Set up a scenario before all tests', async () => {
2220
rollingStock = await getRollingStock(electricRollingStockName);
2321
({ project, study, scenario } = await createScenario());
@@ -27,7 +25,7 @@ test.describe('Rolling stock Tab Verification', () => {
2725
await deleteScenario(project.id, study.id, scenario.name);
2826
});
2927

30-
test.beforeEach(' Navigate to the scenario page', async ({ page }) => {
28+
test.beforeEach('Navigate to the scenario page', async ({ page }) => {
3129
const operationalStudiesPage = new OperationalStudiesPage(page);
3230
await page.goto(
3331
`/operational-studies/projects/${project.id}/studies/${study.id}/scenarios/${scenario.id}`

front/tests/008-train-schedule.spec.ts

+39-20
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,33 @@ import test from './test-logger';
77
import { readJsonFile } from './utils';
88
import createScenario from './utils/scenario';
99
import { deleteScenario } from './utils/teardown-utils';
10-
import { postSimulation, sendTrainSchedules } from './utils/trainSchedule';
10+
import { sendTrainSchedules } from './utils/trainSchedule';
1111

1212
test.describe('Verify train schedule elements and filters', () => {
13+
test.slow();
1314
let project: Project;
1415
let study: Study;
1516
let scenario: Scenario;
1617
let OSRDLanguage: string;
1718
const trainSchedulesJson = readJsonFile('./tests/assets/trainSchedule/train_schedules.json');
19+
// Constants for expected train counts
20+
const TOTAL_TRAINS = 21;
21+
const VALID_TRAINS = 17;
22+
const INVALID_TRAINS = 4;
23+
const HONORED_TRAINS = 12;
24+
const NOT_HONORED_TRAINS = 5;
25+
const VALID_AND_HONORED_TRAINS = 12;
26+
const INVALID_AND_NOT_HONORED_TRAINS = 0;
1827

1928
test.beforeAll('Set up the scenario and post train schedules before all tests', async () => {
2029
({ project, study, scenario } = await createScenario());
2130

22-
// Post train schedule and initiate simulation
23-
const response = await sendTrainSchedules(scenario.timetable_id, trainSchedulesJson);
24-
await postSimulation(response, scenario.infra_id);
31+
// Post train schedule
32+
await sendTrainSchedules(scenario.timetable_id, trainSchedulesJson);
2533
});
2634
test.afterAll('Delete the created scenario', async () => {
2735
await deleteScenario(project.id, study.id, scenario.name);
2836
});
29-
30-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3137
test.beforeEach('Navigate to scenario page before each test', async ({ page }) => {
3238
const operationalStudiesPage = new OperationalStudiesPage(page);
3339
const homePage = new HomePage(page);
@@ -42,33 +48,46 @@ test.describe('Verify train schedule elements and filters', () => {
4248

4349
/** *************** Test 1 **************** */
4450
test('Loading trains and verifying simulation result', async ({ page }) => {
45-
test.slow();
46-
4751
const opTimetablePage = new OperationalStudiesTimetablePage(page);
4852

4953
// Verify train count, invalid train messages, and train simulation results
50-
await opTimetablePage.verifyTrainCount(21);
54+
await opTimetablePage.verifyTrainCount(TOTAL_TRAINS);
5155
await opTimetablePage.verifyInvalidTrainsMessageVisibility(OSRDLanguage);
5256
await opTimetablePage.checkSelectedTimetableTrain();
53-
await opTimetablePage.filterValidityAndVerifyTrainCount(OSRDLanguage, 'Valid', 17);
57+
await opTimetablePage.filterValidityAndVerifyTrainCount(OSRDLanguage, 'Valid', VALID_TRAINS);
5458
await opTimetablePage.verifyEachTrainSimulation();
5559
});
5660

5761
/** *************** Test 2 **************** */
5862
test('Filtering imported trains', async ({ page }) => {
59-
test.slow();
6063
const opTimetablePage = new OperationalStudiesTimetablePage(page);
6164

6265
// Verify train count and apply different filters for validity and honored status
63-
await opTimetablePage.verifyTrainCount(21); // Verify total number of trains: 21
64-
await opTimetablePage.filterValidityAndVerifyTrainCount(OSRDLanguage, 'Invalid', 4); // Verify 4 invalid trains
65-
await opTimetablePage.filterValidityAndVerifyTrainCount(OSRDLanguage, 'All', 21); // Verify all 21 trains
66-
await opTimetablePage.filterHonoredAndVerifyTrainCount(OSRDLanguage, 'Honored', 12); // Verify 13 honored trains
67-
await opTimetablePage.filterValidityAndVerifyTrainCount(OSRDLanguage, 'Valid', 12); // Verify 13 valid (honored) trains
68-
await opTimetablePage.filterHonoredAndVerifyTrainCount(OSRDLanguage, 'Not honored', 5); // Verify 4 valid but not honored trains
69-
await opTimetablePage.filterValidityAndVerifyTrainCount(OSRDLanguage, 'Invalid', 0); /// Verify 0 invalid and honored trains
70-
await opTimetablePage.filterHonoredAndVerifyTrainCount(OSRDLanguage, 'All', 4); // Verify 4 invalid trains in the honored filter
71-
await opTimetablePage.filterValidityAndVerifyTrainCount(OSRDLanguage, 'All', 21); // Verify all 21 trains
66+
await opTimetablePage.verifyTrainCount(TOTAL_TRAINS);
67+
await opTimetablePage.filterValidityAndVerifyTrainCount(
68+
OSRDLanguage,
69+
'Invalid',
70+
INVALID_TRAINS
71+
);
72+
await opTimetablePage.filterValidityAndVerifyTrainCount(OSRDLanguage, 'All', TOTAL_TRAINS);
73+
await opTimetablePage.filterHonoredAndVerifyTrainCount(OSRDLanguage, 'Honored', HONORED_TRAINS);
74+
await opTimetablePage.filterValidityAndVerifyTrainCount(
75+
OSRDLanguage,
76+
'Valid',
77+
VALID_AND_HONORED_TRAINS
78+
);
79+
await opTimetablePage.filterHonoredAndVerifyTrainCount(
80+
OSRDLanguage,
81+
'Not honored',
82+
NOT_HONORED_TRAINS
83+
);
84+
await opTimetablePage.filterValidityAndVerifyTrainCount(
85+
OSRDLanguage,
86+
'Invalid',
87+
INVALID_AND_NOT_HONORED_TRAINS
88+
);
89+
await opTimetablePage.filterHonoredAndVerifyTrainCount(OSRDLanguage, 'All', INVALID_TRAINS);
90+
await opTimetablePage.filterValidityAndVerifyTrainCount(OSRDLanguage, 'All', TOTAL_TRAINS);
7291

7392
// Verify train composition filters with predefined filter codes and expected counts
7493
const compositionFilters = [

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from '@playwright/test';
22

3+
import { dualModeRollingStockName, electricRollingStockName } from './assets/project_const';
34
import RollingstockEditorPage from './pages/rollingstock-editor-page-model';
45
import RollingStockSelectorPage from './pages/rollingstock-selector-page-model';
56
import test from './test-logger';
@@ -18,11 +19,8 @@ test.describe('Rollingstock editor page tests', () => {
1819

1920
const rollingstockDetails = readJsonFile('./tests/assets/rollingStock/rollingstockDetails.json');
2021

21-
const dualModeRollingStockName = 'dual-mode_rolling_stock_test_e2e';
22-
const electricRollingStockName = 'electric_rolling_stock_test_e2e';
23-
2422
test.beforeEach(
25-
'Generate unique names and ensure any existing RS are deleted',
23+
'Generate unique names and ensure all existing RS are deleted',
2624
async ({ page }) => {
2725
const rollingStockEditorPage = new RollingstockEditorPage(page);
2826
uniqueRollingStockName = generateUniqueName('RSN');

front/tests/010-op-route-tab.spec.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Project, Scenario, Study } from 'common/api/osrdEditoastApi';
22

3+
import { electricRollingStockName } from './assets/project_const';
34
import HomePage from './pages/home-page-model';
45
import RoutePage from './pages/op-route-page-model';
56
import OperationalStudiesPage from './pages/operational-studies-page-model';
@@ -9,11 +10,11 @@ import createScenario from './utils/scenario';
910
import { deleteScenario } from './utils/teardown-utils';
1011

1112
test.describe('Route Tab Verification', () => {
13+
test.slow();
1214
let project: Project;
1315
let study: Study;
1416
let scenario: Scenario;
1517
let OSRDLanguage: string;
16-
const electricRollingStockName = 'electric_rolling_stock_test_e2e';
1718

1819
test.beforeAll('Set up the scenario', async () => {
1920
({ project, study, scenario } = await createScenario());
@@ -106,8 +107,6 @@ test.describe('Route Tab Verification', () => {
106107
page,
107108
browserName,
108109
}) => {
109-
test.slow(browserName === 'webkit', 'This test is slow on Safari');
110-
111110
const routePage = new RoutePage(page);
112111

113112
// Perform pathfinding by station trigrams and verify map markers in Chromium

0 commit comments

Comments
 (0)