@@ -3,7 +3,6 @@ import { expect, type Locator, type Page } from '@playwright/test';
3
3
import enTranslations from '../../public/locales/en/operationalStudies/manageTrainSchedule.json' ;
4
4
import frTranslations from '../../public/locales/fr/operationalStudies/manageTrainSchedule.json' ;
5
5
import { getTranslations } from '../utils' ;
6
- import { clickWithDelay } from '../utils' ;
7
6
8
7
class RoutePage {
9
8
readonly page : Page ;
@@ -52,6 +51,8 @@ class RoutePage {
52
51
53
52
readonly missingParamMessage : Locator ;
54
53
54
+ readonly pathfindingLoader : Locator ;
55
+
55
56
constructor ( page : Page ) {
56
57
this . page = page ;
57
58
@@ -77,6 +78,7 @@ class RoutePage {
77
78
this . viaModal = page . locator ( '.manage-vias-modal' ) ;
78
79
this . closeViaModalButton = page . getByLabel ( 'Close' ) ;
79
80
this . missingParamMessage = page . getByTestId ( 'missing-params-info' ) ;
81
+ this . pathfindingLoader = page . locator ( '.dots-loader' ) ;
80
82
}
81
83
82
84
// Get the name locator of a waypoint suggestion.
@@ -196,7 +198,7 @@ class RoutePage {
196
198
const expectedDestinationTrigram =
197
199
await this . getDestinationLocatorByTrigram ( destinationTrigram ) . innerText ( ) ;
198
200
await this . clickSearchByTrigramSubmitButton ( ) ;
199
- await this . page . waitForSelector ( '.dots-loader' , { state : 'hidden' } ) ;
201
+ await this . pathfindingLoader . waitFor ( { state : 'hidden' } ) ;
200
202
await expect ( this . searchByTrigramContainer ) . not . toBeVisible ( ) ;
201
203
await expect ( this . resultPathfindingDone ) . toBeVisible ( ) ;
202
204
@@ -213,15 +215,14 @@ class RoutePage {
213
215
async clickOnDeleteOPButtons ( selectedLanguage : string ) {
214
216
// Ensure all buttons are rendered and visible before proceeding
215
217
await Promise . all ( [
216
- this . viaDeleteButton . waitFor ( { state : 'visible' } ) ,
217
- this . originDeleteButton . waitFor ( { state : 'visible' } ) ,
218
- this . destinationDeleteButton . waitFor ( { state : 'visible' } ) ,
218
+ this . viaDeleteButton . waitFor ( ) ,
219
+ this . originDeleteButton . waitFor ( ) ,
220
+ this . destinationDeleteButton . waitFor ( ) ,
219
221
] ) ;
220
222
221
- // Click the buttons sequentially with waits to ensure UI stability
222
- await clickWithDelay ( this . viaDeleteButton ) ;
223
- await clickWithDelay ( this . originDeleteButton ) ;
224
- await clickWithDelay ( this . destinationDeleteButton ) ;
223
+ await this . viaDeleteButton . click ( ) ;
224
+ await this . originDeleteButton . click ( ) ;
225
+ await this . destinationDeleteButton . click ( ) ;
225
226
const translations = getTranslations ( selectedLanguage , {
226
227
en : enTranslations ,
227
228
fr : frTranslations ,
@@ -230,15 +231,15 @@ class RoutePage {
230
231
': {{missingElements}}.' ,
231
232
''
232
233
) ;
233
- await this . missingParamMessage . waitFor ( { state : 'visible' } ) ;
234
+ await this . missingParamMessage . waitFor ( ) ;
234
235
const actualMessage = await this . missingParamMessage . innerText ( ) ;
235
236
expect ( actualMessage ) . toContain ( expectedMessage ) ;
236
237
}
237
238
238
239
// Click the add buttons for the specified via names.
239
240
async clickOnViaAddButtons ( ...viaNames : string [ ] ) {
240
241
for ( const viaName of viaNames ) {
241
- await clickWithDelay ( this . getAddButtonLocatorByViaName ( viaName ) ) ;
242
+ await this . getAddButtonLocatorByViaName ( viaName ) . click ( ) ;
242
243
await expect ( this . getDeleteButtonLocatorByViaName ( viaName ) ) . toBeVisible ( ) ;
243
244
}
244
245
}
0 commit comments