mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-13 01:32:40 +02:00
test(web): add shared Playwright E2E helpers and search-space fixture
This commit is contained in:
parent
a2976ee0b6
commit
ae0caad292
10 changed files with 673 additions and 0 deletions
34
surfsense_web/tests/helpers/ui/connector-popup.ts
Normal file
34
surfsense_web/tests/helpers/ui/connector-popup.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import type { Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
|
||||
/**
|
||||
* Page-object-style helpers for the connector dialog rendered by
|
||||
* components/assistant-ui/connector-popup.tsx.
|
||||
*
|
||||
* Kept minimal in Phase 1: most spec interactions go through API
|
||||
* fixtures for determinism. UI-driven coverage of every connector card
|
||||
* is a Phase 2 task and will use this helper as the entry point.
|
||||
*/
|
||||
|
||||
export async function openConnectorPopup(page: Page): Promise<void> {
|
||||
// Label depends on whether the user already has connectors.
|
||||
const trigger = page
|
||||
.getByRole("button", { name: "Manage connectors" })
|
||||
.or(page.getByRole("button", { name: "Connect your connectors" }))
|
||||
.first();
|
||||
|
||||
// Long timeout absorbs Next.js dev cold-compile of the new-chat route.
|
||||
await expect(trigger).toBeVisible({ timeout: 60_000 });
|
||||
await trigger.click();
|
||||
|
||||
await expect(page.getByRole("dialog", { name: "Manage Connectors" })).toBeVisible();
|
||||
}
|
||||
|
||||
export async function clickComposioDriveCard(page: Page): Promise<void> {
|
||||
const composioDriveCard = page.getByText("Search your Drive files via Composio");
|
||||
await composioDriveCard.scrollIntoViewIfNeeded();
|
||||
const card = composioDriveCard
|
||||
.locator("xpath=ancestor::*[self::article or self::div][1]")
|
||||
.first();
|
||||
await card.getByRole("button", { name: "Connect" }).click();
|
||||
}
|
||||
21
surfsense_web/tests/helpers/ui/dashboard.ts
Normal file
21
surfsense_web/tests/helpers/ui/dashboard.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import type { Page } from "@playwright/test";
|
||||
import { expect } from "@playwright/test";
|
||||
|
||||
/**
|
||||
* Navigation helpers for dashboard routes. Centralized so that future
|
||||
* route changes only require an update in one place.
|
||||
*/
|
||||
|
||||
export function newChatUrl(searchSpaceId: number): string {
|
||||
return `/dashboard/${searchSpaceId}/new-chat`;
|
||||
}
|
||||
|
||||
export function connectorsCallbackUrl(searchSpaceId: number): string {
|
||||
return `/dashboard/${searchSpaceId}/connectors/callback`;
|
||||
}
|
||||
|
||||
export async function gotoNewChat(page: Page, searchSpaceId: number): Promise<void> {
|
||||
const target = newChatUrl(searchSpaceId);
|
||||
await page.goto(target, { waitUntil: "domcontentloaded" });
|
||||
await expect(page).toHaveURL((url) => url.pathname === target);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue