Skip to content

Commit 163e637

Browse files
committed
refactor(tests): enhance E2E run page tests for comprehensive flow validation
- Update run-page.spec.ts to verify complete run flow, including landing page load, run initiation, timeline heading visibility, and screenshot capture within 20 seconds. - Remove obsolete tests and consolidate steps for clarity and efficiency. - Delete unused agent communication and development scripts to streamline the codebase.
1 parent 7f3b41a commit 163e637

File tree

4 files changed

+29
-273
lines changed

4 files changed

+29
-273
lines changed

frontend/tests/e2e/run-page.spec.ts

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
1617
test.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(/ScreenGraph/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: /detect.*drift/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(/\/run\/[a-f0-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: /run timeline/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: /cancel run/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(/ScreenGraph/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: /detect.*drift/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: /discovered screens/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

scripts/agent-comm.mjs

Lines changed: 0 additions & 196 deletions
This file was deleted.

scripts/dev-backend.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

scripts/dev-frontend.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)