@@ -21,10 +21,10 @@ test.describe("CSV Data Validator Application", () => {
2121 // Set up page object
2222 csvValidatorPage = new CSVValidatorPage ( page ) ;
2323
24- // Set up API mocks for consistent testing
24+ // Set up API mocks for consistent testing (BEFORE navigation)
2525 await setupApiMocks ( page ) ;
2626
27- // Navigate to application
27+ // Navigate to application (AFTER mocks are set up)
2828 await csvValidatorPage . goto ( ) ;
2929 } ) ;
3030
@@ -153,8 +153,8 @@ A schema for validating data.
153153 * Test 1: Schema dropdown population and selection
154154 */
155155 test ( "should populate and allow selection from schema dropdown" , async ( ) => {
156- // Wait for schemas to load in dropdown
157- await expect ( csvValidatorPage . schemaDropdownTrigger ) . toBeEnabled ( ) ;
156+ // Wait for schemas to load and dropdown to be enabled (due to mocked API call)
157+ await expect ( csvValidatorPage . schemaDropdownTrigger ) . toBeEnabled ( { timeout : 10000 } ) ;
158158
159159 // Open dropdown and verify schemas are listed
160160 await csvValidatorPage . schemaDropdownTrigger . click ( ) ;
@@ -181,6 +181,8 @@ A schema for validating data.
181181 * Test 2: Schema documentation panel toggle and content
182182 */
183183 test ( "should toggle schema documentation panel and display content" , async ( ) => {
184+ // Wait for dropdown to be enabled
185+ await expect ( csvValidatorPage . schemaDropdownTrigger ) . toBeEnabled ( { timeout : 10000 } ) ;
184186 // First select a schema
185187 await csvValidatorPage . selectSchema ( "event" ) ;
186188
@@ -208,6 +210,8 @@ A schema for validating data.
208210 * Test 3: CSV file upload functionality
209211 */
210212 test ( "should upload and display CSV file content" , async ( ) => {
213+ // Wait for dropdown to be enabled
214+ await expect ( csvValidatorPage . schemaDropdownTrigger ) . toBeEnabled ( { timeout : 10000 } ) ;
211215 // First select a schema
212216 await csvValidatorPage . selectSchema ( "event" ) ;
213217
@@ -235,6 +239,8 @@ A schema for validating data.
235239 // Initially, validate button should be disabled
236240 await expect ( csvValidatorPage . validateButton ) . toBeDisabled ( ) ;
237241
242+ // Wait for dropdown to be enabled
243+ await expect ( csvValidatorPage . schemaDropdownTrigger ) . toBeEnabled ( { timeout : 10000 } ) ;
238244 // Select a schema, button should still be disabled
239245 await csvValidatorPage . selectSchema ( "event" ) ;
240246 await expect ( csvValidatorPage . validateButton ) . toBeDisabled ( ) ;
@@ -254,7 +260,9 @@ A schema for validating data.
254260 * Test 5: Validation results display for valid CSV
255261 */
256262 test ( "should validate and display success for valid CSV" , async ( ) => {
257- // Set up test with schema and valid CSV
263+ // Wait for dropdown to be enabled
264+ await expect ( csvValidatorPage . schemaDropdownTrigger ) . toBeEnabled ( { timeout : 10000 } ) ;
265+ // Select schema and upload valid CSV
258266 await csvValidatorPage . selectSchema ( "event" ) ;
259267 const sampleCsvPath = path . join (
260268 process . cwd ( ) ,
@@ -277,7 +285,9 @@ A schema for validating data.
277285 * Test 6: Validation results display for invalid CSV
278286 */
279287 test ( "should validate and display errors for invalid CSV" , async ( ) => {
280- // Set up test with schema and invalid CSV
288+ // Wait for dropdown to be enabled
289+ await expect ( csvValidatorPage . schemaDropdownTrigger ) . toBeEnabled ( { timeout : 10000 } ) ;
290+ // Select schema and upload invalid CSV
281291 await csvValidatorPage . selectSchema ( "event" ) ;
282292 const invalidCsvPath = path . join (
283293 process . cwd ( ) ,
@@ -305,7 +315,9 @@ A schema for validating data.
305315 * Test 7 (Optional): Error highlighting when clicking on errors
306316 */
307317 test ( "should highlight CSV line when clicking on error" , async ( ) => {
308- // Set up test with schema and invalid CSV
318+ // Wait for dropdown to be enabled
319+ await expect ( csvValidatorPage . schemaDropdownTrigger ) . toBeEnabled ( { timeout : 10000 } ) ;
320+ // Select schema, upload invalid CSV, and validate
309321 await csvValidatorPage . selectSchema ( "event" ) ;
310322 const invalidCsvPath = path . join (
311323 process . cwd ( ) ,
0 commit comments