39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { type Page } from "@playwright/test";
|
|
import { TestApiClient } from "./fixtures";
|
|
|
|
const DEFAULT_E2E_NAME = "E2E User";
|
|
const DEFAULT_E2E_EMAIL = "e2e@multica.ai";
|
|
const DEFAULT_E2E_WORKSPACE = "e2e-workspace";
|
|
|
|
/**
|
|
* Log in as the default E2E user and ensure the workspace exists first.
|
|
*/
|
|
export async function loginAsDefault(page: Page) {
|
|
const api = new TestApiClient();
|
|
await api.login(DEFAULT_E2E_EMAIL, DEFAULT_E2E_NAME);
|
|
await api.ensureWorkspace("E2E Workspace", DEFAULT_E2E_WORKSPACE);
|
|
|
|
await page.goto("/login");
|
|
await page.fill('input[placeholder="Name"]', DEFAULT_E2E_NAME);
|
|
await page.fill('input[placeholder="Email"]', DEFAULT_E2E_EMAIL);
|
|
await page.click('button[type="submit"]');
|
|
await page.waitForURL("**/issues", { timeout: 10000 });
|
|
}
|
|
|
|
/**
|
|
* Create a TestApiClient logged in as the default E2E user.
|
|
* Call api.cleanup() in afterEach to remove test data created during the test.
|
|
*/
|
|
export async function createTestApi(): Promise<TestApiClient> {
|
|
const api = new TestApiClient();
|
|
await api.login(DEFAULT_E2E_EMAIL, DEFAULT_E2E_NAME);
|
|
await api.ensureWorkspace("E2E Workspace", DEFAULT_E2E_WORKSPACE);
|
|
return api;
|
|
}
|
|
|
|
export async function openWorkspaceMenu(page: Page) {
|
|
// Click the workspace switcher button (has ChevronDown icon)
|
|
await page.locator("aside button").first().click();
|
|
// Wait for dropdown to appear
|
|
await page.locator('[class*="popover"]').waitFor({ state: "visible" });
|
|
}
|