@@ -5,40 +5,72 @@ import {
5
5
trainScheduleScenarioName ,
6
6
trainScheduleStudyName ,
7
7
} 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' ;
8
29
import test from './logging-fixture' ;
30
+ import OperationalStudiesPage from './pages/operational-studies/operational-studies-page' ;
9
31
import ScenarioTimetableSection from './pages/operational-studies/scenario-timetable-section' ;
10
- import { waitForInfraStateToBeCached } from './utils' ;
32
+ import { getTranslations , waitForInfraStateToBeCached } from './utils' ;
11
33
import { 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' ) ;
12
46
13
47
test . describe ( 'Verify train schedule elements and filters' , ( ) => {
14
48
test . slow ( ) ;
15
49
test . use ( { viewport : { width : 1920 , height : 1080 } } ) ;
16
50
17
51
let scenarioTimetableSection : ScenarioTimetableSection ;
52
+ let operationalStudiesPage : OperationalStudiesPage ;
18
53
19
54
let project : Project ;
20
55
let study : Study ;
21
56
let scenario : Scenario ;
22
57
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 ;
32
59
33
60
test . beforeAll ( 'Fetch project, study and scenario with train schedule' , async ( ) => {
34
61
project = await getProject ( trainScheduleProjectName ) ;
35
62
study = await getStudy ( project . id , trainScheduleStudyName ) ;
36
63
scenario = await getScenario ( project . id , study . id , trainScheduleScenarioName ) ;
37
64
infra = await getInfra ( ) ;
65
+ translations = getTranslations ( {
66
+ en : { ...enScenarioTranslations , ...enCommonTranslations } ,
67
+ fr : { ...frScenarioTranslations , ...frCommonTranslations } ,
68
+ } ) ;
38
69
} ) ;
39
70
40
71
test . beforeEach ( 'Navigate to scenario page before each test' , async ( { page } ) => {
41
72
scenarioTimetableSection = new ScenarioTimetableSection ( page ) ;
73
+ operationalStudiesPage = new OperationalStudiesPage ( page ) ;
42
74
await page . goto (
43
75
`/operational-studies/projects/${ project . id } /studies/${ study . id } /scenarios/${ scenario . id } `
44
76
) ;
@@ -52,31 +84,59 @@ test.describe('Verify train schedule elements and filters', () => {
52
84
await scenarioTimetableSection . verifyTrainCount ( TOTAL_TRAINS ) ;
53
85
await scenarioTimetableSection . verifyInvalidTrainsMessageVisibility ( ) ;
54
86
await scenarioTimetableSection . checkSelectedTimetableTrain ( ) ;
55
- await scenarioTimetableSection . filterValidityAndVerifyTrainCount ( 'Valid' , VALID_TRAINS ) ;
87
+ await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
88
+ 'Valid' ,
89
+ VALID_TRAINS ,
90
+ translations
91
+ ) ;
56
92
await scenarioTimetableSection . verifyEachTrainSimulation ( ) ;
57
93
} ) ;
58
94
95
+ // TODO Paced train - remove this test in https://github.com/OpenRailAssociation/osrd/issues/10791
59
96
/** *************** Test 2 **************** */
60
97
test ( 'Filtering imported trains' , async ( ) => {
61
98
// Verify train count and apply different filters for validity and honored status
62
99
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
+ ) ;
66
115
await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
67
116
'Valid' ,
68
- VALID_AND_HONORED_TRAINS
117
+ VALID_AND_HONORED_TRAINS ,
118
+ translations
69
119
) ;
70
120
await scenarioTimetableSection . filterHonoredAndVerifyTrainCount (
71
121
'Not honored' ,
72
- NOT_HONORED_TRAINS
122
+ NOT_HONORED_TRAINS ,
123
+ translations
73
124
) ;
74
125
await scenarioTimetableSection . filterValidityAndVerifyTrainCount (
75
126
'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
77
139
) ;
78
- await scenarioTimetableSection . filterHonoredAndVerifyTrainCount ( 'All' , INVALID_TRAINS ) ;
79
- await scenarioTimetableSection . filterValidityAndVerifyTrainCount ( 'All' , TOTAL_TRAINS ) ;
80
140
81
141
// Verify train composition filters with predefined filter codes and expected counts
82
142
const compositionFilters = [
@@ -87,7 +147,99 @@ test.describe('Verify train schedule elements and filters', () => {
87
147
] ;
88
148
89
149
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
+ ) ;
91
155
}
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 ) ;
92
244
} ) ;
93
245
} ) ;
0 commit comments