@@ -4,14 +4,15 @@ import { TEST_PACKAGE_NAME, TEST_APP_CONFIG } from "./helpers";
44/**
55 * /run page E2E regression suite
66 *
7- * Verifies core functionality:
8- * - Run page loads after starting a run
9- * - Run Timeline header is visible
7+ * Verifies complete run flow:
8+ * - Landing page loads correctly
9+ * - Run can be started successfully
10+ * - Run page displays timeline heading
11+ * - Screenshots appear within 20 seconds
1012 *
1113 * Prerequisites:
1214 * - Backend and frontend services running
1315 * - Test package from .env: ${TEST_PACKAGE_NAME}
14- * - All tests use the same package for consistency
1516 */
1617test . describe ( "/run page smoke tests" , ( ) => {
1718 test . beforeAll ( ( ) => {
@@ -23,70 +24,57 @@ test.describe("/run page smoke tests", () => {
2324 } ) ;
2425
2526 /**
26- * Verify run page opens and displays Run Timeline header.
27- * This is the baseline test for detecting UI regressions.
27+ * Complete run flow test: validates entire user journey from landing to screenshot discovery.
28+ *
29+ * Steps:
30+ * 1. Load landing page and verify it's healthy
31+ * 2. Start a new run
32+ * 3. Verify run page loads with timeline heading
33+ * 4. Wait 20 seconds for agent to explore app
34+ * 5. Verify at least one screenshot appears in gallery
2835 *
2936 * NOTE: Requires backend to be running and able to start runs.
3037 * Uses package from .env: ${TEST_PACKAGE_NAME}
3138 */
32- test ( "should open run page and show Run Timeline text " , async ( { page } ) => {
33- // Navigate to landing page
39+ test ( "should load page, start run, show heading, wait 20s, and verify screenshots " , async ( { page } ) => {
40+ // STEP 1: Navigate to landing page and verify it loads
3441 await page . goto ( "/" ) ;
35-
36- // Wait for page to fully load
3742 await expect ( page ) . toHaveTitle ( / S c r e e n G r a p h / i) ;
3843
39- // Find and click the "Detect My First Drift" button
40- // Using getByRole for accessibility-friendly selection
44+ // Verify the main CTA button exists
4145 const runButton = page . getByRole ( "button" , { name : / d e t e c t .* d r i f t / i } ) ;
4246 await expect ( runButton ) . toBeVisible ( ) ;
4347
44- // Click the button - this will call the backend API and navigate
48+ // STEP 2: Click button to start run
4549 await runButton . click ( ) ;
4650
47- // Wait for navigation to /run page (increased timeout for API call + navigation)
51+ // STEP 3: Wait for navigation to /run page
4852 await page . waitForURL ( / \/ r u n \/ [ a - f 0 - 9 - ] + / i, {
4953 waitUntil : "domcontentloaded" ,
5054 timeout : 30000
5155 } ) ;
5256
53- // Verify Run Timeline text is visible in the H1 heading
54- // This is the key regression check - if timeline UI breaks, this will fail
55- // Use getByRole to be specific and avoid strict mode violations
57+ // STEP 4: Verify Run Timeline heading is visible
5658 const timelineHeading = page . getByRole ( "heading" , { name : / r u n t i m e l i n e / i } ) ;
5759 await expect ( timelineHeading ) . toBeVisible ( { timeout : 10000 } ) ;
5860
5961 // Verify Cancel Run button exists (indicates page fully loaded)
6062 const cancelButton = page . getByRole ( "button" , { name : / c a n c e l r u n / i } ) ;
6163 await expect ( cancelButton ) . toBeVisible ( ) ;
62- } ) ;
63-
64- /**
65- * Verify landing page loads correctly before testing run flow.
66- * This is a sanity check to ensure frontend is healthy.
67- */
68- test ( "should load landing page successfully" , async ( { page } ) => {
69- await page . goto ( "/" ) ;
7064
71- // Verify page title
72- await expect ( page ) . toHaveTitle ( / S c r e e n G r a p h / i ) ;
65+ // STEP 5: Wait 20 seconds for agent to explore and capture screens
66+ await page . waitForTimeout ( 20000 ) ;
7367
74- // Verify the main CTA button exists
75- const runButton = page . getByRole ( "button" , { name : / d e t e c t .* d r i f t / i } ) ;
76- await expect ( runButton ) . toBeVisible ( ) ;
77-
78- // Verify no console errors on load
79- const consoleErrors : string [ ] = [ ] ;
80- page . on ( "console" , ( msg ) => {
81- if ( msg . type ( ) === "error" ) {
82- consoleErrors . push ( msg . text ( ) ) ;
83- }
84- } ) ;
68+ // STEP 6: Verify at least one screenshot appeared in the gallery
69+ // Look for "Discovered Screens" heading which indicates screens have loaded
70+ const discoveredHeading = page . getByRole ( "heading" , { name : / d i s c o v e r e d s c r e e n s / i } ) ;
71+ await expect ( discoveredHeading ) . toBeVisible ( { timeout : 5000 } ) ;
8572
86- await page . waitForTimeout ( 1000 ) ;
73+ // Verify at least one screenshot image is rendered
74+ const screenshots = page . locator ( 'img[alt^="Screen"]' ) ;
75+ const screenshotCount = await screenshots . count ( ) ;
8776
88- // Assert no console errors
89- expect ( consoleErrors ) . toHaveLength ( 0 ) ;
77+ expect ( screenshotCount ) . toBeGreaterThan ( 0 ) ;
9078 } ) ;
9179} ) ;
9280
0 commit comments