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