mirror of
https://github.com/getpaseo/paseo.git
synced 2026-08-14 12:23:16 +00:00
Random host-local project IDs replaced the remote-derived value that had also served as grouping identity. Persist a separate opaque group key and let normal boot reconciliation backfill older records without a migration.
85 lines
2.7 KiB
TypeScript
85 lines
2.7 KiB
TypeScript
import { expect, type Locator, type Page } from "@playwright/test";
|
|
|
|
export type AddProjectFlowPage =
|
|
| "host"
|
|
| "method"
|
|
| "directory-search"
|
|
| "github-search"
|
|
| "github-location"
|
|
| "new-directory-parent"
|
|
| "new-directory-name";
|
|
|
|
export type AddProjectMethod = "directory-search" | "browse" | "github" | "new-directory";
|
|
|
|
const METHOD_DESTINATIONS: Record<Exclude<AddProjectMethod, "browse">, AddProjectFlowPage> = {
|
|
"directory-search": "directory-search",
|
|
github: "github-search",
|
|
"new-directory": "new-directory-parent",
|
|
};
|
|
|
|
export function addProjectFlow(page: Page): Locator {
|
|
return page.getByTestId("add-project-flow");
|
|
}
|
|
|
|
export function addProjectFlowInput(page: Page): Locator {
|
|
return page.getByTestId("add-project-flow-input");
|
|
}
|
|
|
|
export function addProjectFlowBack(page: Page): Locator {
|
|
return page.getByTestId("add-project-flow-back");
|
|
}
|
|
|
|
export function addProjectFlowHost(page: Page, serverId: string): Locator {
|
|
return page.getByTestId(`add-project-flow-host-${serverId}`);
|
|
}
|
|
|
|
export function addProjectFlowMethod(page: Page, method: AddProjectMethod): Locator {
|
|
return page.getByTestId(`add-project-flow-method-${method}`);
|
|
}
|
|
|
|
export async function expectAddProjectPage(page: Page, kind: AddProjectFlowPage): Promise<Locator> {
|
|
const currentPage = page.getByTestId(`add-project-flow-page-${kind}`);
|
|
await expect(currentPage).toBeVisible({ timeout: 30_000 });
|
|
return currentPage;
|
|
}
|
|
|
|
export async function openAddProjectFlow(
|
|
page: Page,
|
|
expectedPage: "host" | "method" = "method",
|
|
): Promise<void> {
|
|
await page.getByTestId("sidebar-add-project").click();
|
|
await expect(addProjectFlow(page)).toBeVisible({ timeout: 30_000 });
|
|
await expectAddProjectPage(page, expectedPage);
|
|
await expect(addProjectFlowInput(page)).toBeFocused();
|
|
}
|
|
|
|
export async function chooseAddProjectMethod(page: Page, method: AddProjectMethod): Promise<void> {
|
|
const option = addProjectFlowMethod(page, method);
|
|
await expect(option).toBeVisible();
|
|
await option.click();
|
|
if (method !== "browse") {
|
|
await expectAddProjectPage(page, METHOD_DESTINATIONS[method]);
|
|
}
|
|
}
|
|
|
|
export async function expectNewWorkspaceForAddedProject(
|
|
page: Page,
|
|
input: {
|
|
serverId: string;
|
|
projectId: string;
|
|
projectName: string;
|
|
projectPath: string;
|
|
},
|
|
): Promise<void> {
|
|
await expect(page).toHaveURL(/\/new\?.*projectId=/u, { timeout: 30_000 });
|
|
const url = new URL(page.url());
|
|
expect(url.pathname).toBe("/new");
|
|
expect(url.searchParams.get("serverId")).toBe(input.serverId);
|
|
expect(url.searchParams.get("projectId")).toBe(input.projectId);
|
|
expect(url.searchParams.get("dir")).toBe(input.projectPath);
|
|
await expect(page.getByRole("button", { name: "Workspace project" })).toContainText(
|
|
input.projectName,
|
|
{ timeout: 30_000 },
|
|
);
|
|
}
|