@@ -5,40 +5,72 @@ import {
55 trainScheduleScenarioName ,
66 trainScheduleStudyName ,
77} from './assets/constants/project-const' ;
8+ import {
9+ HONORED_ITEMS ,
10+ HONORED_TRAINS ,
11+ INVALID_AND_NOT_HONORED_TRAINS ,
12+ INVALID_ITEMS ,
13+ INVALID_TRAINS ,
14+ ITEMS_WITH_NO_SPEED_LIMIT_TAG ,
15+ LABEL_FILTERED_ITEMS ,
16+ NAME_FILTERED_ITEMS ,
17+ NOT_HONORED_ITEMS ,
18+ NOT_HONORED_PACED_TRAINS ,
19+ NOT_HONORED_TRAINS ,
20+ ROLLING_STOCK_FILTERED_ITEMS ,
21+ TOTAL_ITEMS ,
22+ TOTAL_PACED_TRAINS ,
23+ TOTAL_TRAINS ,
24+ VALID_AND_HONORED_TRAINS ,
25+ VALID_ITEMS ,
26+ VALID_PACED_TRAINS ,
27+ VALID_TRAINS ,
28+ } from './assets/constants/timetable-items-count' ;
829import test from './logging-fixture' ;
30+ import OperationalStudiesPage from './pages/operational-studies/operational-studies-page' ;
931import ScenarioTimetableSection from './pages/operational-studies/scenario-timetable-section' ;
10- import { waitForInfraStateToBeCached } from './utils' ;
32+ import { getTranslations , waitForInfraStateToBeCached } from './utils' ;
1133import { getInfra , getProject , getScenario , getStudy } from './utils/api-utils' ;
34+ import readJsonFile from './utils/file-utils' ;
35+ import type { CommonTranslations , TimetableFilterTranslations } from './utils/types' ;
36+
37+ const enScenarioTranslations : TimetableFilterTranslations = readJsonFile (
38+ 'public/locales/en/operationalStudies/scenario.json'
39+ ) ;
40+ const frScenarioTranslations : TimetableFilterTranslations = readJsonFile (
41+ 'public/locales/fr/operationalStudies/scenario.json'
42+ ) ;
43+
44+ const enCommonTranslations : CommonTranslations = readJsonFile ( 'public/locales/en/translation.json' ) ;
45+ const frCommonTranslations : CommonTranslations = readJsonFile ( 'public/locales/fr/translation.json' ) ;
1246
1347test . describe ( 'Verify train schedule elements and filters' , ( ) => {
1448 test . slow ( ) ;
1549 test . use ( { viewport : { width : 1920 , height : 1080 } } ) ;
1650
1751 let scenarioTimetableSection : ScenarioTimetableSection ;
52+ let operationalStudiesPage : OperationalStudiesPage ;
1853
1954 let project : Project ;
2055 let study : Study ;
2156 let scenario : Scenario ;
2257 let infra : Infra ;
23-
24- // Constants for expected train counts
25- const TOTAL_TRAINS = 21 ;
26- const VALID_TRAINS = 17 ;
27- const INVALID_TRAINS = 4 ;
28- const HONORED_TRAINS = 14 ;
29- const NOT_HONORED_TRAINS = 3 ;
30- const VALID_AND_HONORED_TRAINS = 14 ;
31- const INVALID_AND_NOT_HONORED_TRAINS = 0 ;
58+ let translations : TimetableFilterTranslations & CommonTranslations ;
3259
3360 test . beforeAll ( 'Fetch project, study and scenario with train schedule' , async ( ) => {
3461 project = await getProject ( trainScheduleProjectName ) ;
3562 study = await getStudy ( project . id , trainScheduleStudyName ) ;
3663 scenario = await getScenario ( project . id , study . id , trainScheduleScenarioName ) ;
3764 infra = await getInfra ( ) ;
65+ translations = getTranslations ( {
66+ en : { ...enScenarioTranslations , ...enCommonTranslations } ,
67+ fr : { ...frScenarioTranslations , ...frCommonTranslations } ,
68+ } ) ;
3869 } ) ;
3970
4071 test . beforeEach ( 'Navigate to scenario page before each test' , async ( { page } ) => {
4172 scenarioTimetableSection = new ScenarioTimetableSection ( page ) ;
73+ operationalStudiesPage = new OperationalStudiesPage ( page ) ;
4274 await page . goto (
4375 `/operational-studies/projects/${ project . id } /studies/${ study . id } /scenarios/${ scenario . id } `
4476 ) ;
@@ -52,31 +84,59 @@ test.describe('Verify train schedule elements and filters', () => {
5284 await scenarioTimetableSection . verifyTrainCount ( TOTAL_TRAINS ) ;
5385 await scenarioTimetableSection . verifyInvalidTrainsMessageVisibility ( ) ;
5486 await scenarioTimetableSection . checkSelectedTimetableTrain ( ) ;
55- await scenarioTimetableSection . filterValidityAndVerifyTrainCount ( 'Valid' , VALID_TRAINS ) ;
87+ await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
88+ 'Valid' ,
89+ VALID_TRAINS ,
90+ translations
91+ ) ;
5692 await scenarioTimetableSection . verifyEachTrainSimulation ( ) ;
5793 } ) ;
5894
95+ // TODO Paced train - remove this test in https://github.com/OpenRailAssociation/osrd/issues/10791
5996 /** *************** Test 2 **************** */
6097 test ( 'Filtering imported trains' , async ( ) => {
6198 // Verify train count and apply different filters for validity and honored status
6299 await scenarioTimetableSection . verifyTrainCount ( TOTAL_TRAINS ) ;
63- await scenarioTimetableSection . filterValidityAndVerifyTrainCount ( 'Invalid' , INVALID_TRAINS ) ;
64- await scenarioTimetableSection . filterValidityAndVerifyTrainCount ( 'All' , TOTAL_TRAINS ) ;
65- await scenarioTimetableSection . filterHonoredAndVerifyTrainCount ( 'Honored' , HONORED_TRAINS ) ;
100+ await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
101+ 'Invalid' ,
102+ INVALID_TRAINS ,
103+ translations
104+ ) ;
105+ await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
106+ 'All' ,
107+ TOTAL_TRAINS ,
108+ translations
109+ ) ;
110+ await scenarioTimetableSection . filterHonoredAndVerifyTrainCount (
111+ 'Honored' ,
112+ HONORED_TRAINS ,
113+ translations
114+ ) ;
66115 await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
67116 'Valid' ,
68- VALID_AND_HONORED_TRAINS
117+ VALID_AND_HONORED_TRAINS ,
118+ translations
69119 ) ;
70120 await scenarioTimetableSection . filterHonoredAndVerifyTrainCount (
71121 'Not honored' ,
72- NOT_HONORED_TRAINS
122+ NOT_HONORED_TRAINS ,
123+ translations
73124 ) ;
74125 await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
75126 'Invalid' ,
76- INVALID_AND_NOT_HONORED_TRAINS
127+ INVALID_AND_NOT_HONORED_TRAINS ,
128+ translations
129+ ) ;
130+ await scenarioTimetableSection . filterHonoredAndVerifyTrainCount (
131+ 'All' ,
132+ INVALID_TRAINS ,
133+ translations
134+ ) ;
135+ await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
136+ 'All' ,
137+ TOTAL_TRAINS ,
138+ translations
77139 ) ;
78- await scenarioTimetableSection . filterHonoredAndVerifyTrainCount ( 'All' , INVALID_TRAINS ) ;
79- await scenarioTimetableSection . filterValidityAndVerifyTrainCount ( 'All' , TOTAL_TRAINS ) ;
80140
81141 // Verify train composition filters with predefined filter codes and expected counts
82142 const compositionFilters = [
@@ -87,7 +147,99 @@ test.describe('Verify train schedule elements and filters', () => {
87147 ] ;
88148
89149 for ( const filter of compositionFilters ) {
90- await scenarioTimetableSection . clickCodeCompoTrainFilterButton ( filter . code , filter . count ) ;
150+ await scenarioTimetableSection . filterSpeedLimitTagAndVerifyTrainCount (
151+ filter . code ,
152+ filter . count ,
153+ translations
154+ ) ;
91155 }
156+ await scenarioTimetableSection . verifyTrainCount ( TOTAL_TRAINS ) ;
157+ } ) ;
158+
159+ // TODO Paced train : update this test with real data in https://github.com/OpenRailAssociation/osrd/issues/10615
160+ /** *************** Test 3 **************** */
161+ test ( 'Filtering imported trains and paced trains' , async ( ) => {
162+ await operationalStudiesPage . checkPacedTrainSwitch ( ) ;
163+
164+ // While the back end for paced trains isn't ready, 3 paced trains are hardcoded and
165+ // added to the list of train schedules for testing purposes.
166+ // These 3 paced trains are copy of the first train schedule in the list (1 valid, 1 not invalid, 1 not honored).
167+ await scenarioTimetableSection . verifyTotalItemsLabel ( translations , {
168+ totalPacedTrainCount : TOTAL_PACED_TRAINS ,
169+ totalTrainScheduleCount : TOTAL_TRAINS ,
170+ } ) ;
171+
172+ await scenarioTimetableSection . checkTimetableFilterVisibilityLabelDefaultValue (
173+ translations . timetable ,
174+ { inputDefaultValue : '' , selectDefaultValue : 'both' }
175+ ) ;
176+
177+ // Name and label filter
178+ await scenarioTimetableSection . filterNameAndVerifyTrainCount (
179+ 'Paced Train 1' ,
180+ NAME_FILTERED_ITEMS
181+ ) ;
182+ await scenarioTimetableSection . filterNameAndVerifyTrainCount (
183+ 'Paced-Train-Tag-1' ,
184+ LABEL_FILTERED_ITEMS
185+ ) ;
186+
187+ // Rolling stock name and details filter
188+ await scenarioTimetableSection . filterRollingStockAndVerifyTrainCount (
189+ 'slow_rolling_stock' ,
190+ ROLLING_STOCK_FILTERED_ITEMS
191+ ) ;
192+
193+ // Validity filter
194+ await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
195+ 'Invalid' ,
196+ INVALID_ITEMS ,
197+ translations
198+ ) ;
199+ await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
200+ 'Valid' ,
201+ VALID_ITEMS ,
202+ translations
203+ ) ;
204+
205+ // Punctuality filter
206+ await scenarioTimetableSection . filterHonoredAndVerifyTrainCount (
207+ 'Honored' ,
208+ HONORED_ITEMS ,
209+ translations
210+ ) ;
211+ await scenarioTimetableSection . filterHonoredAndVerifyTrainCount (
212+ 'Not honored' ,
213+ NOT_HONORED_ITEMS ,
214+ translations
215+ ) ;
216+
217+ // Train type filter
218+ await scenarioTimetableSection . filterTrainTypeAndVerifyTrainCount (
219+ 'Service' ,
220+ NOT_HONORED_PACED_TRAINS
221+ ) ;
222+ await scenarioTimetableSection . filterHonoredAndVerifyTrainCount (
223+ 'All' ,
224+ VALID_PACED_TRAINS ,
225+ translations
226+ ) ;
227+ await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
228+ 'All' ,
229+ TOTAL_PACED_TRAINS ,
230+ translations
231+ ) ;
232+
233+ await scenarioTimetableSection . filterTrainTypeAndVerifyTrainCount ( 'Unique train' , TOTAL_TRAINS ) ;
234+ await scenarioTimetableSection . filterTrainTypeAndVerifyTrainCount ( 'All' , TOTAL_ITEMS ) ;
235+
236+ // Verify train composition filters with predefined filter codes and expected counts
237+ // TODO Paced train : add a paced train with a unique compo code in https://github.com/OpenRailAssociation/osrd/issues/10615
238+ await scenarioTimetableSection . filterSpeedLimitTagAndVerifyTrainCount (
239+ null ,
240+ ITEMS_WITH_NO_SPEED_LIMIT_TAG ,
241+ translations
242+ ) ;
243+ await scenarioTimetableSection . verifyTrainCount ( TOTAL_ITEMS ) ;
92244 } ) ;
93245} ) ;
0 commit comments