Skip to content

Commit 8d34bad

Browse files
committed
front: add op simulation settings e2e test
Signed-off-by: maymanaf <[email protected]>
1 parent d768e04 commit 8d34bad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6915
-502
lines changed

front/playwright.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default defineConfig({
7373
use: {
7474
browserName: 'webkit',
7575
launchOptions: {
76-
slowMo: 50, // Slows down WebKit interactions by 50 milliseconds
76+
slowMo: 150, // Slows down WebKit interactions by 150 milliseconds
7777
},
7878
},
7979
dependencies: ['setup'],

front/src/applications/operationalStudies/components/Scenario/ScenarioContent.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const ScenarioContent = ({
124124
<div className="scenario">
125125
<div className="row scenario-container">
126126
<div
127+
data-testid="scenario-sidemenu"
127128
className={`scenario-sidemenu ${collapsedTimetable ? 'd-none' : 'col-hdp-3 col-xl-4 col-lg-5 col-md-6'}`}
128129
>
129130
<div className="scenario-sidemenu">
@@ -188,6 +189,7 @@ const ScenarioContent = ({
188189
<>
189190
<div className="scenario-timetable-collapsed">
190191
<button
192+
data-testid="timetable-collapse-button"
191193
className="timetable-collapse-button"
192194
type="button"
193195
aria-label={t('toggleTimetable')}

front/src/applications/operationalStudies/components/Scenario/ScenarioDescription.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const ScenarioDescription = ({
3737
)}
3838
<div className="flex justify-end">
3939
<button
40+
data-testid="scenario-collapse-button"
4041
type="button"
4142
className="scenario-collapse-button"
4243
aria-label={t('toggleTimetable')}

front/src/modules/trainschedule/components/Timetable/TimetableTrainCard.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ const TimetableTrainCard = ({
206206
(train.notHonoredReason === 'scheduleNotHonored' ? <Clock /> : <Flame />)}
207207
</div>
208208
{train.arrivalTime && (
209-
<div className="scenario-timetable-train-arrival" title={train.arrivalTime}>
209+
<div
210+
data-testid="train-arrival-time"
211+
className="scenario-timetable-train-arrival"
212+
title={train.arrivalTime}
213+
>
210214
{/* TODO: delete the format when the date management `PR` has been passed */}
211215
{dayjs(train.arrivalTime, 'D/MM/YYYY HH:mm:ss').format('HH:mm')}
212216
</div>

front/tests/002-project-management.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test.afterEach(async () => {
2323
await deleteApiRequest(`/api/projects/${project.id}/`);
2424
});
2525

26-
test.describe('Test if operationnal study : project workflow is working properly', () => {
26+
test.describe('Test if project workflow is working properly', () => {
2727
test('Create a new project', async ({ page }) => {
2828
const homePage = new HomePage(page);
2929
const projectPage = new ProjectPage(page);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let project: Project;
1919
let study: Study;
2020

2121
test.beforeAll(async () => {
22-
project = await getProject();
22+
project = await getProject('project_test_e2e');
2323
});
2424

2525
test.beforeEach(async () => {
@@ -31,7 +31,7 @@ test.beforeEach(async () => {
3131
});
3232
});
3333

34-
test.describe('Test if operationnal study: study creation workflow is working properly', () => {
34+
test.describe('Test if study creation workflow is working properly', () => {
3535
test('Create a new study', async ({ page }) => {
3636
const studyPage = new StudyPage(page);
3737
const commonPage = new CommonPage(page);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test.beforeEach(async () => {
1717
({ project, study, scenario } = await setupScenario());
1818
});
1919

20-
test.describe('Test if operationnal study : scenario creation workflow is working properly', () => {
20+
test.describe('Test if scenario creation workflow is working properly', () => {
2121
test('Create a new scenario', async ({ page }) => {
2222
const homePage = new HomePage(page);
2323
const scenarioPage = new ScenarioPage(page);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ let scenario: Scenario;
1414
let rollingStock: RollingStock;
1515

1616
test.beforeAll(async () => {
17-
rollingStock = await getRollingStock();
17+
rollingStock = await getRollingStock('electric_rolling_stock_test_e2e');
1818
});
1919

2020
test.beforeEach(async () => {
2121
({ project, study, scenario } = await setupScenario());
2222
});
2323

24-
test.describe('Testing if all mandatory elements simulation configuration are loaded in operationnal studies app', () => {
24+
test.describe('Testing if all mandatory elements simulation configuration are loaded in operational studies app', () => {
2525
test('Testing pathfinding with rollingstock and composition code', async ({ page }) => {
2626
// Add enough timeout to wait for the infra to be loaded
2727
test.slow();
@@ -47,7 +47,7 @@ test.describe('Testing if all mandatory elements simulation configuration are lo
4747
await expect(rollingstockModal).toBeVisible();
4848

4949
// Voluntarily add spaces and capital letters so we also test the normalization of the search functionality
50-
await rollingstockModalPage.searchRollingstock(' rollingstock_1500_25000_test_E2E ');
50+
await rollingstockModalPage.searchRollingstock(' electric_rolling_stock_test_e2e ');
5151

5252
const rollingstockCard = rollingstockModalPage.getRollingstockCardByTestID(
5353
`rollingstock-${rollingStock.name}`
@@ -72,7 +72,7 @@ test.describe('Testing if all mandatory elements simulation configuration are lo
7272

7373
await scenarioPage.getPathfindingByTriGramSearch('MWS', 'NES');
7474

75-
await scenarioPage.checkPathfindingDistance('34.000 km');
75+
await scenarioPage.checkPathfindingDistance('33.950 km');
7676

7777
// ***************** Test Add Train Schedule *****************
7878
await scenarioPage.addTrainSchedule();

front/tests/006-stdcm-page.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import manageTrainScheduleTranslation from '../public/locales/fr/operationalStud
1010
const projectName = project.name;
1111
const studyName = study.name;
1212
const scenarioName = scenario.name;
13-
const rollingStockName = 'rollingstock_1500_25000_test_e2e';
13+
const rollingStockName = 'electric_rolling_stock_test_e2e';
1414

1515
const emptyRouteTranslation = manageTrainScheduleTranslation.pathfindingNoState;
1616

1717
test.describe('STDCM page', () => {
18-
// TODO: Refacto this test for the new stdcm page
18+
// TODO: Refactor this test for the new stdcm page
1919
test.skip('should configure and launch a stdcm', async ({ page }) => {
2020
const stdcmPage = new StdcmPage(page);
2121

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ let study: Study;
1313
let scenario: Scenario;
1414
let rollingStock: RollingStock;
1515

16-
const dualModeRollingStockName = 'dual-mode_rollingstock_test_e2e';
17-
const electricRollingStockName = 'rollingstock_1500_25000_test_e2e';
16+
const dualModeRollingStockName = 'dual-mode_rolling_stock_test_e2e';
17+
const electricRollingStockName = 'electric_rolling_stock_test_e2e';
1818

1919
test.beforeAll(async () => {
20-
rollingStock = await getRollingStock();
20+
rollingStock = await getRollingStock(electricRollingStockName);
2121

2222
// Create a new scenario
2323
({ project, study, scenario } = await setupScenario());

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ test.describe('Verifying that all elements in the train schedule are loaded corr
6666
await opTimetablePage.verifyTrainCount(20);
6767
await opTimetablePage.filterValidityAndVerifyTrainCount(selectedLanguage, 'Invalid', 4);
6868
await opTimetablePage.filterValidityAndVerifyTrainCount(selectedLanguage, 'All', 20);
69-
await opTimetablePage.filterHonoredAndVerifyTrainCount(selectedLanguage, 'Honored', 13);
70-
await opTimetablePage.filterValidityAndVerifyTrainCount(selectedLanguage, 'Valid', 13);
71-
await opTimetablePage.filterHonoredAndVerifyTrainCount(selectedLanguage, 'Not honored', 3);
69+
await opTimetablePage.filterHonoredAndVerifyTrainCount(selectedLanguage, 'Honored', 12);
70+
await opTimetablePage.filterValidityAndVerifyTrainCount(selectedLanguage, 'Valid', 12);
71+
await opTimetablePage.filterHonoredAndVerifyTrainCount(selectedLanguage, 'Not honored', 4);
7272
await opTimetablePage.filterValidityAndVerifyTrainCount(selectedLanguage, 'Invalid', 0);
7373
await opTimetablePage.filterHonoredAndVerifyTrainCount(selectedLanguage, 'All', 4);
7474
await opTimetablePage.filterValidityAndVerifyTrainCount(selectedLanguage, 'All', 20);

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const rollingstockDetailsPath = path.resolve(
1919
);
2020

2121
const rollingstockDetails = readJsonFile(rollingstockDetailsPath);
22-
const dualModeRollingStockName = 'dual-mode_rollingstock_test_e2e';
23-
const electricRollingStockName = 'rollingstock_1500_25000_test_e2e';
22+
const dualModeRollingStockName = 'dual-mode_rolling_stock_test_e2e';
23+
const electricRollingStockName = 'electric_rolling_stock_test_e2e';
2424

2525
test.describe('Rollingstock editor page', () => {
2626
let uniqueRollingStockName: string;
@@ -176,7 +176,7 @@ test.describe('Rollingstock editor page', () => {
176176
});
177177
test('should correctly duplicate and delete a rolling stock', async ({ page }) => {
178178
const rollingStockEditorPage = new RollingstockEditorPage(page);
179-
179+
const rollingStockSelectorPage = new RollingStockSelectorPage(page);
180180
await rollingStockEditorPage.navigateToPage();
181181

182182
// Select the rolling stock from global-setup
@@ -196,6 +196,13 @@ test.describe('Rollingstock editor page', () => {
196196
await expect(
197197
rollingStockEditorPage.page.getByTestId(uniqueDeletedRollingStockName)
198198
).toBeHidden();
199+
200+
// Search for the deleted rolling stock
201+
await rollingStockEditorPage.searchRollingStock(uniqueDeletedRollingStockName);
202+
203+
// Verify that the count of rolling stock is 0 (No results Found)
204+
await expect(rollingStockSelectorPage.getNoRollingStockResult).toBeVisible();
205+
expect(await rollingStockSelectorPage.getRollingStockSearchNumber()).toEqual(0);
199206
});
200207
test('should correctly filter a rolling stock', async ({ page }) => {
201208
const rollingStockEditorPage = new RollingstockEditorPage(page);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let study: Study;
1212
let scenario: Scenario;
1313
let selectedLanguage: string;
1414

15-
const electricRollingStockName = 'rollingstock_1500_25000_test_e2e';
15+
const electricRollingStockName = 'electric_rolling_stock_test_e2e';
1616

1717
test.beforeAll(async () => {
1818
// Create a new scenario

front/tests/011-op-times-and-stops-tab.spec.ts

+16-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import OperationalStudiesTimetablePage from './pages/op-timetable-page-model';
99
import OperationalStudiesPage from './pages/operational-studies-page-model';
1010
import ScenarioPage from './pages/scenario-page-model';
1111
import { readJsonFile } from './utils';
12-
import { cleanWhitespace, cleanWhitespaces, type StationData } from './utils/dataNormalizer';
12+
import { cleanWhitespace, cleanWhitespaceInArray, type StationData } from './utils/dataNormalizer';
1313
import setupScenario from './utils/scenario';
1414
import scrollContainer from './utils/scrollHelper';
1515
import enTranslations from '../public/locales/en/timesStops.json';
@@ -20,7 +20,17 @@ let study: Study;
2020
let scenario: Scenario;
2121
let selectedLanguage: string;
2222

23-
const dualRollingStockName = 'dual-mode_rollingstock_test_e2e';
23+
type TranslationKeys = keyof typeof enTranslations;
24+
25+
// Define CellData interface for table cell data
26+
interface CellData {
27+
stationName: string;
28+
header: TranslationKeys;
29+
value: string;
30+
marginForm?: string;
31+
}
32+
33+
const dualRollingStockName = 'dual-mode_rolling_stock_test_e2e';
2434

2535
const initialInputsData: CellData[] = readJsonFile(
2636
'./tests/assets/operationStudies/timesAndStops/initialInputs.json'
@@ -43,16 +53,6 @@ const expectedViaValues = [
4353
{ name: 'Mid_East_station', ch: 'BV', uic: '4', km: 'KM 26.300' },
4454
];
4555

46-
type TranslationKeys = keyof typeof enTranslations;
47-
48-
// Define CellData interface for table cell data
49-
interface CellData {
50-
stationName: string;
51-
header: TranslationKeys;
52-
value: string;
53-
marginForm?: string;
54-
}
55-
5656
test.beforeEach(async ({ page }) => {
5757
// Create a new scenario
5858
({ project, study, scenario } = await setupScenario());
@@ -106,7 +106,7 @@ test.describe('Times and Stops Tab Verification', () => {
106106

107107
// Set column names based on the selected language
108108
const translations = selectedLanguage === 'English' ? enTranslations : frTranslations;
109-
const expectedColumnNames = cleanWhitespaces([
109+
const expectedColumnNames = cleanWhitespaceInArray([
110110
translations.name,
111111
'Ch',
112112
translations.arrivalTime,
@@ -117,7 +117,7 @@ test.describe('Times and Stops Tab Verification', () => {
117117
]);
118118

119119
// Verify that the actual column headers match the expected headers
120-
const actualColumnHeaders = cleanWhitespaces(
120+
const actualColumnHeaders = cleanWhitespaceInArray(
121121
await opInputTablePage.columnHeaders.allInnerTexts()
122122
);
123123
expect(actualColumnHeaders).toEqual(expectedColumnNames);
@@ -157,7 +157,8 @@ test.describe('Times and Stops Tab Verification', () => {
157157
// Add the train schedule and verify simulation results
158158
await scenarioPage.addTrainSchedule();
159159
await scenarioPage.returnSimulationResult();
160-
opTimetablePage.verifyTimeStopsDatasheetVisibility();
160+
await opTimetablePage.clickOnScenarioCollapseButton();
161+
await opTimetablePage.verifyTimeStopsDataSheetVisibility();
161162
// Scroll and extract data from output table
162163
await scrollContainer(page, '.osrd-simulation-container .time-stops-datasheet .dsg-container');
163164
await opOutputTablePage.getOutputTableData(outputExpectedCellData, selectedLanguage);

0 commit comments

Comments
 (0)