deer-flow/frontend/tests/e2e/landing.spec.ts
yangzheli c6b0423558
feat(frontend): add Playwright E2E tests with CI workflow (#2279)
* feat(frontend): add Playwright E2E tests with CI workflow

Add end-to-end testing infrastructure using Playwright (Chromium only).
14 tests across 5 spec files cover landing page, chat workspace,
thread history, sidebar navigation, and agent chat — all with mocked
LangGraph/Backend APIs via network interception (zero backend dependency).

New files:
- playwright.config.ts — Chromium, 30s timeout, auto-start Next.js
- tests/e2e/utils/mock-api.ts — shared API mocks & SSE stream helpers
- tests/e2e/{landing,chat,thread-history,sidebar,agent-chat}.spec.ts
- .github/workflows/e2e-tests.yml — push main + PR trigger, paths filter

Updated: package.json, Makefile, .gitignore, CONTRIBUTING.md,
frontend/CLAUDE.md, frontend/AGENTS.md, frontend/README.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: apply Copilot suggestions

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-04-18 08:21:08 +08:00

33 lines
916 B
TypeScript

import { expect, test } from "@playwright/test";
import { mockLangGraphAPI } from "./utils/mock-api";
test.describe("Landing page", () => {
test("renders the header and hero section", async ({ page }) => {
await page.goto("/");
// Header brand name
await expect(
page.locator("header h1", { hasText: "DeerFlow" }),
).toBeVisible();
// "Get Started" call-to-action button in hero
await expect(
page.getByRole("link", { name: /get started/i }),
).toBeVisible();
});
test("Get Started link navigates to workspace", async ({ page }) => {
mockLangGraphAPI(page);
await page.goto("/");
const getStarted = page.getByRole("link", { name: /get started/i });
await getStarted.click();
// Should redirect to /workspace/chats/new
await page.waitForURL("**/workspace/chats/new");
await expect(page).toHaveURL(/\/workspace\/chats\/new/);
});
});