2023-02-06 17:26:01 +03:00
|
|
|
import type { Page } from '@playwright/test';
|
2023-03-23 07:22:29 +03:00
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
|
2023-04-22 04:44:29 +03:00
|
|
|
import { clickCollaborationPanel } from './setting';
|
|
|
|
import { clickSideBarSettingButton } from './sidebar';
|
|
|
|
|
2023-02-06 17:26:01 +03:00
|
|
|
interface CreateWorkspaceParams {
|
|
|
|
name: string;
|
|
|
|
}
|
2023-04-06 21:21:45 +03:00
|
|
|
|
|
|
|
export async function openWorkspaceListModal(page: Page) {
|
|
|
|
const workspaceName = page.getByTestId('workspace-name');
|
|
|
|
await workspaceName.click();
|
|
|
|
}
|
|
|
|
|
2023-02-06 17:26:01 +03:00
|
|
|
export async function createWorkspace(
|
|
|
|
params: CreateWorkspaceParams,
|
|
|
|
page: Page
|
|
|
|
) {
|
2023-04-06 21:21:45 +03:00
|
|
|
await openWorkspaceListModal(page);
|
2023-02-06 17:26:01 +03:00
|
|
|
|
|
|
|
// open create workspace modal
|
|
|
|
await page.locator('.add-icon').click();
|
|
|
|
|
|
|
|
// input workspace name
|
|
|
|
await page.getByPlaceholder('Set a Workspace name').click();
|
|
|
|
await page.getByPlaceholder('Set a Workspace name').fill(params.name);
|
|
|
|
|
|
|
|
// click create button
|
2023-02-08 12:48:03 +03:00
|
|
|
return page.getByRole('button', { name: 'Create' }).click();
|
2023-02-06 17:26:01 +03:00
|
|
|
}
|
2023-03-23 07:22:29 +03:00
|
|
|
|
|
|
|
export async function assertCurrentWorkspaceFlavour(
|
|
|
|
flavour: 'affine' | 'local',
|
|
|
|
page: Page
|
|
|
|
) {
|
|
|
|
const actual = await page.evaluate(() => globalThis.currentWorkspace.flavour);
|
|
|
|
expect(actual).toBe(flavour);
|
|
|
|
}
|
2023-04-22 04:44:29 +03:00
|
|
|
|
|
|
|
export async function enableAffineCloudWorkspace(page: Page) {
|
|
|
|
await clickSideBarSettingButton(page);
|
|
|
|
await page.waitForTimeout(50);
|
|
|
|
await clickCollaborationPanel(page);
|
|
|
|
await page.getByTestId('local-workspace-enable-cloud-button').click();
|
|
|
|
await page.getByTestId('confirm-enable-cloud-button').click();
|
|
|
|
await page.waitForSelector("[data-testid='member-length']", {
|
|
|
|
timeout: 20000,
|
|
|
|
});
|
|
|
|
}
|