@@ -3,6 +3,7 @@ import path from 'path'
33import os from 'os'
44import {
55 openProblemsView ,
6+ saveFile ,
67 SUSHI_SOURCE_PATH ,
78 waitForLoadedSQLMesh ,
89} from './utils'
@@ -80,11 +81,29 @@ test('noselectstar quickfix', async ({ page, sharedCodeServer }) => {
8081 . first ( )
8182 . click ( )
8283
83- // Wait for the quick fix to be applied
84- await page . waitForTimeout ( 2_000 )
84+ await saveFile ( page )
8585
86- // Assert that the model no longer contains SELECT * but SELECT id, customer_id, waiter_id, start_ts, end_ts, event_date
87- const readUpdatedFile = ( await fs . readFile ( modelPath ) ) . toString ( 'utf8' )
86+ // Wait for the quick fix to be applied and verify the change
87+ const startTime = Date . now ( )
88+ let readUpdatedFile = ''
89+ let fileUpdated = false
90+
91+ while ( Date . now ( ) - startTime < 20_000 && ! fileUpdated ) {
92+ readUpdatedFile = ( await fs . readFile ( modelPath ) ) . toString ( 'utf8' )
93+ if (
94+ ! readUpdatedFile . includes ( 'SELECT *' ) &&
95+ readUpdatedFile . includes (
96+ 'SELECT id, customer_id, waiter_id, start_ts, end_ts, event_date' ,
97+ )
98+ ) {
99+ fileUpdated = true
100+ break
101+ }
102+ await page . waitForTimeout ( 500 ) // Short pause between checks
103+ }
104+
105+ // Assert that the model was properly updated
106+ expect ( fileUpdated ) . toBeTruthy ( )
88107 expect ( readUpdatedFile ) . not . toContain ( 'SELECT *' )
89108 expect ( readUpdatedFile ) . toContain (
90109 'SELECT id, customer_id, waiter_id, start_ts, end_ts, event_date' ,
0 commit comments