@@ -115,7 +115,8 @@ class OperationalStudiesTimetablePage {
115
115
async clickCodeCompoTrainFilterButton (
116
116
selectedLanguage : string ,
117
117
filterTranslation : string ,
118
- expectedTrainCount : number
118
+ expectedTrainCount : number ,
119
+ totalTrainCount : number
119
120
) : Promise < void > {
120
121
await this . timetableFilterButton . click ( ) ;
121
122
const translations = selectedLanguage === 'English' ? enTranslations : frTranslations ;
@@ -129,31 +130,24 @@ class OperationalStudiesTimetablePage {
129
130
: this . page . getByRole ( 'button' , { name : filterTranslation } ) ;
130
131
131
132
await filterButtonLocator . click ( ) ;
132
- await this . verifyTrainCount ( expectedTrainCount , selectedLanguage ) ;
133
+ await this . verifyTrainCount ( expectedTrainCount , totalTrainCount ) ;
133
134
await filterButtonLocator . click ( ) ;
134
135
await this . timetableFilterButton . click ( ) ;
135
136
}
136
137
137
138
// Verifies that the imported train number is correct
138
- async verifyTrainCount ( trainCount : number , selectedLanguage : string ) : Promise < void > {
139
+ async verifyTrainCount ( trainCount : number , totalTrainCount : number ) : Promise < void > {
139
140
await this . page . waitForLoadState ( 'networkidle' ) ;
140
- const translations = selectedLanguage === 'English' ? enTranslations : frTranslations ;
141
141
const trainCountText = await this . trainCountText . innerText ( ) ;
142
-
143
- const translationMapping : Record < number , string > = {
144
- 0 : translations . trainCount_zero ,
145
- 1 : translations . trainCount_one ,
146
- } ;
147
- const expectedText = translationMapping [ trainCount ] || `${ trainCount } trains` ;
148
-
149
- expect ( trainCountText ) . toEqual ( expectedText ) ;
142
+ expect ( trainCountText ) . toEqual ( `${ trainCount } /${ totalTrainCount } trains` ) ;
150
143
}
151
144
152
145
// Filter trains validity and verify their count
153
146
async filterValidityAndVerifyTrainCount (
154
147
selectedLanguage : string ,
155
148
validityFilter : 'Valid' | 'Invalid' | 'All' ,
156
- expectedTrainCount : number
149
+ expectedTrainCount : number ,
150
+ totalTrainCount : number
157
151
) : Promise < void > {
158
152
const translations = selectedLanguage === 'English' ? enTranslations : frTranslations ;
159
153
await this . timetableFilterButton . click ( ) ;
@@ -166,14 +160,15 @@ class OperationalStudiesTimetablePage {
166
160
167
161
await this . clickValidityTrainFilterButton ( validityFilters [ validityFilter ] ) ;
168
162
await this . timetableFilterButton . click ( ) ;
169
- await this . verifyTrainCount ( expectedTrainCount , selectedLanguage ) ;
163
+ await this . verifyTrainCount ( expectedTrainCount , totalTrainCount ) ;
170
164
}
171
165
172
166
// Filter the honored trains and verify their count
173
167
async filterHonoredAndVerifyTrainCount (
174
168
selectedLanguage : string ,
175
169
honoredFilter : 'Honored' | 'Not honored' | 'All' ,
176
- expectedTrainCount : number
170
+ expectedTrainCount : number ,
171
+ totalTrainCount : number
177
172
) : Promise < void > {
178
173
const translations = selectedLanguage === 'English' ? enTranslations : frTranslations ;
179
174
await this . timetableFilterButton . click ( ) ;
@@ -186,24 +181,22 @@ class OperationalStudiesTimetablePage {
186
181
187
182
await this . clickHonoredTrainFilterButton ( honoredFilters [ honoredFilter ] ) ;
188
183
await this . timetableFilterButton . click ( ) ;
189
- await this . verifyTrainCount ( expectedTrainCount , selectedLanguage ) ;
184
+ await this . verifyTrainCount ( expectedTrainCount , totalTrainCount ) ;
190
185
}
191
186
192
187
// Iterate over each train element and verify the visibility of simulation results
193
188
async verifyEachTrainSimulation ( ) : Promise < void > {
194
189
const trainCount = await this . timetableTrains . count ( ) ;
195
- let currentTrainIndex = 0 ;
196
190
197
191
/* eslint-disable no-await-in-loop */
198
- while ( currentTrainIndex < trainCount ) {
192
+ for ( let currentTrainIndex = 0 ; currentTrainIndex < trainCount ; currentTrainIndex += 1 ) {
199
193
await this . page . waitForLoadState ( 'networkidle' ) ;
200
194
await this . waitForSimulationResults ( ) ;
201
195
const trainButton = OperationalStudiesTimetablePage . getTrainButton (
202
196
this . timetableTrains . nth ( currentTrainIndex )
203
197
) ;
204
198
await trainButton . click ( ) ;
205
199
await this . verifySimulationResultsVisibility ( ) ;
206
- currentTrainIndex += 1 ;
207
200
}
208
201
/* eslint-enable no-await-in-loop */
209
202
}
0 commit comments