AFFiNE/tests/kit/utils/workspace.ts

45 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-11-17 10:50:01 +03:00
import { expect, type Page } from '@playwright/test';
import { waitForEditorLoad } from './page-logic';
interface CreateWorkspaceParams {
name: string;
}
export async function openWorkspaceListModal(page: Page) {
2023-09-02 08:57:04 +03:00
await page.getByTestId('workspace-name').click({
delay: 50,
});
}
2023-09-02 08:57:04 +03:00
export async function createLocalWorkspace(
params: CreateWorkspaceParams,
page: Page
) {
await openWorkspaceListModal(page);
// open create workspace modal
await page.getByTestId('new-workspace').click();
// const isDesktop: boolean = await page.evaluate(() => {
// return !!window.appInfo?.electron;
// }, []);
// input workspace name
await page.getByPlaceholder('Set a Workspace name').click();
await page.getByPlaceholder('Set a Workspace name').fill(params.name);
// click create button
await page.getByRole('button', { name: 'Create' }).click({
delay: 500,
});
2023-11-17 10:50:01 +03:00
await waitForEditorLoad(page);
await expect(page.getByTestId('workspace-name')).toHaveText(params.name);
// if (isDesktop) {
// await page.getByTestId('create-workspace-continue-button').click();
// }
}