@@ -65,12 +65,12 @@ test.describe("/run page smoke tests", () => {
6565 console . log ( "⏱ Waiting for agent to capture screenshots..." ) ;
6666
6767 const runEventsRoot = page . locator ( "[data-testid='run-events']" ) ;
68- const screenshotEventLocator = runEventsRoot . getByText ( "agent.event.screenshot_captured" , {
69- exact : false ,
70- } ) ;
71- const launchFailedEventLocator = runEventsRoot . getByText ( "agent.app.launch_failed" , {
72- exact : false ,
73- } ) ;
68+ const screenshotEventLocator = runEventsRoot . locator (
69+ "[data-event-kind='agent.event.screenshot_captured']" ,
70+ ) ;
71+ const launchFailedEventLocator = runEventsRoot . locator (
72+ "[data-event-kind='agent.app.launch_failed']" ,
73+ ) ;
7474
7575 const startTime = Date . now ( ) ;
7676 const timeout = 15000 ;
@@ -123,131 +123,4 @@ Common causes:
123123 expect ( screenshotEventPayload ) . toMatch ( / s c r e e n s h o t \/ .+ \. p n g / ) ;
124124 } ) ;
125125
126- /**
127- * BUG-014 REGRESSION TEST: Verify no stale screenshots from previous runs.
128- *
129- * Tests that navigating between multiple runs properly resets component state and
130- * does not show screenshots from previous runs.
131- *
132- * Flow:
133- * 1. Start first run (Run A), wait for screenshots
134- * 2. Capture Run A's ID and screenshot URLs
135- * 3. Navigate back to landing page
136- * 4. Start second run (Run B)
137- * 5. Verify Run B page shows NO screenshots from Run A
138- * 6. Verify Run B page only shows Run B screenshots (when they appear)
139- *
140- * This validates the $effect fix that resets graphNodes/graphEvents when page.params.id changes.
141- */
142- test ( "BUG-014: should not show stale screenshots when navigating between runs" , async ( {
143- page,
144- } ) => {
145- console . log ( "🔍 BUG-014 Test: Starting first run..." ) ;
146-
147- // STEP 1: Start first run (Run A)
148- await page . goto ( "/" ) ;
149- const runButton = page . getByRole ( "button" , { name : / d e t e c t .* d r i f t / i } ) ;
150- await runButton . click ( ) ;
151-
152- // Wait for Run A page to load
153- await page . waitForURL ( / \/ r u n \/ [ a - f 0 - 9 - ] + / i, {
154- waitUntil : "domcontentloaded" ,
155- timeout : 30000 ,
156- } ) ;
157-
158- // Extract Run A ID from URL
159- const runAUrl = page . url ( ) ;
160- const runAId = runAUrl . match ( / \/ r u n \/ ( [ a - f 0 - 9 - ] + ) / ) ?. [ 1 ] ;
161- console . log ( `📝 Run A ID: ${ runAId } ` ) ;
162- expect ( runAId ) . toBeTruthy ( ) ;
163-
164- // Wait for Run A to show at least one screenshot
165- const timelineHeading = page . getByRole ( "heading" , { name : / r u n t i m e l i n e / i } ) ;
166- await expect ( timelineHeading ) . toBeVisible ( { timeout : 10000 } ) ;
167-
168- console . log ( "⏱ Waiting for Run A screenshots..." ) ;
169- const screenshotGallery = page . locator ( '[data-testid="discovered-screens"] img' ) ;
170- await expect ( screenshotGallery . first ( ) ) . toBeVisible ( { timeout : 20000 } ) ;
171-
172- // Capture Run A screenshot data
173- const runAScreenshotCount = await screenshotGallery . count ( ) ;
174- const runAScreenshotSrcs = await screenshotGallery . evaluateAll ( ( imgs ) =>
175- imgs . map ( ( img ) => ( img as HTMLImageElement ) . src ) ,
176- ) ;
177-
178- console . log ( `📸 Run A has ${ runAScreenshotCount } screenshot(s)` ) ;
179- expect ( runAScreenshotCount ) . toBeGreaterThan ( 0 ) ;
180-
181- // STEP 2: Navigate back to landing page
182- console . log ( "🔙 Navigating back to landing page..." ) ;
183- await page . goto ( "/" ) ;
184- await expect ( page ) . toHaveTitle ( / S c r e e n G r a p h / i) ;
185-
186- // STEP 3: Start second run (Run B)
187- console . log ( "🔍 Starting second run (Run B)..." ) ;
188- const runButton2 = page . getByRole ( "button" , { name : / d e t e c t .* d r i f t / i } ) ;
189- await runButton2 . click ( ) ;
190-
191- // Wait for Run B page to load
192- await page . waitForURL ( / \/ r u n \/ [ a - f 0 - 9 - ] + / i, {
193- waitUntil : "domcontentloaded" ,
194- timeout : 30000 ,
195- } ) ;
196-
197- // Extract Run B ID from URL
198- const runBUrl = page . url ( ) ;
199- const runBId = runBUrl . match ( / \/ r u n \/ ( [ a - f 0 - 9 - ] + ) / ) ?. [ 1 ] ;
200- console . log ( `📝 Run B ID: ${ runBId } ` ) ;
201- expect ( runBId ) . toBeTruthy ( ) ;
202- expect ( runBId ) . not . toBe ( runAId ) ; // Ensure we have a different run
203-
204- // STEP 4: Immediately verify NO screenshots from Run A are present
205- // The gallery should be empty initially (or show "Waiting for screens" message)
206- await expect ( timelineHeading ) . toBeVisible ( { timeout : 10000 } ) ;
207-
208- // Wait a moment for any potential stale state to render (this is the bug we're testing for)
209- await page . waitForTimeout ( 1000 ) ;
210-
211- // Check if any screenshots are visible
212- const initialScreenshots = page . locator ( '[data-testid="discovered-screens"] img' ) ;
213- const initialCount = await initialScreenshots . count ( ) ;
214-
215- if ( initialCount > 0 ) {
216- // If screenshots are visible, verify NONE of them match Run A's screenshots
217- const currentSrcs = await initialScreenshots . evaluateAll ( ( imgs ) =>
218- imgs . map ( ( img ) => ( img as HTMLImageElement ) . src ) ,
219- ) ;
220-
221- for ( const runASrc of runAScreenshotSrcs ) {
222- expect ( currentSrcs ) . not . toContain ( runASrc ) ;
223- }
224- console . log ( `✅ No stale Run A screenshots found (${ initialCount } screenshots present)` ) ;
225- } else {
226- console . log ( "✅ Gallery is empty initially (expected)" ) ;
227- }
228-
229- // STEP 5: Wait for Run B screenshots to appear (optional - may timeout if run is slow)
230- console . log ( "⏱ Waiting for Run B screenshots..." ) ;
231- try {
232- await expect ( screenshotGallery . first ( ) ) . toBeVisible ( { timeout : 20000 } ) ;
233-
234- const runBScreenshotCount = await screenshotGallery . count ( ) ;
235- const runBScreenshotSrcs = await screenshotGallery . evaluateAll ( ( imgs ) =>
236- imgs . map ( ( img ) => ( img as HTMLImageElement ) . src ) ,
237- ) ;
238-
239- console . log ( `📸 Run B has ${ runBScreenshotCount } screenshot(s)` ) ;
240-
241- // Verify Run B screenshots are different from Run A screenshots
242- for ( const runASrc of runAScreenshotSrcs ) {
243- expect ( runBScreenshotSrcs ) . not . toContain ( runASrc ) ;
244- }
245-
246- console . log ( "✅ BUG-014 Test PASSED: Run B screenshots are distinct from Run A" ) ;
247- } catch ( error ) {
248- // If Run B screenshots don't appear in time, that's okay - we already validated
249- // the main bug (no stale Run A screenshots)
250- console . log ( "⚠️ Run B screenshots didn't appear in time, but stale state test passed" ) ;
251- }
252- } ) ;
253126} ) ;
0 commit comments