2023-11-17 10:50:01 +03:00
|
|
|
import { expect, type Page } from '@playwright/test';
|
|
|
|
|
|
|
|
import { waitForEditorLoad } from './page-logic';
|
2023-04-22 04:44:29 +03:00
|
|
|
|
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) {
|
2023-09-02 08:57:04 +03:00
|
|
|
await page.getByTestId('workspace-name').click({
|
|
|
|
delay: 50,
|
|
|
|
});
|
2023-04-06 21:21:45 +03:00
|
|
|
}
|
|
|
|
|
2023-09-02 08:57:04 +03:00
|
|
|
export async function createLocalWorkspace(
|
2023-02-06 17:26:01 +03:00
|
|
|
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
|
2023-08-17 01:18:43 +03:00
|
|
|
await page.getByTestId('new-workspace').click();
|
2023-02-06 17:26:01 +03:00
|
|
|
|
2023-09-26 17:11:04 +03:00
|
|
|
// const isDesktop: boolean = await page.evaluate(() => {
|
|
|
|
// return !!window.appInfo?.electron;
|
|
|
|
// }, []);
|
2023-09-17 23:26:06 +03:00
|
|
|
|
2023-02-06 17:26:01 +03:00
|
|
|
// 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-09-17 23:26:06 +03:00
|
|
|
await page.getByRole('button', { name: 'Create' }).click({
|
2023-08-17 01:18:43 +03:00
|
|
|
delay: 500,
|
|
|
|
});
|
2023-09-17 23:26:06 +03:00
|
|
|
|
2023-11-17 10:50:01 +03:00
|
|
|
await waitForEditorLoad(page);
|
|
|
|
|
|
|
|
await expect(page.getByTestId('workspace-name')).toHaveText(params.name);
|
|
|
|
|
2023-09-26 17:11:04 +03:00
|
|
|
// if (isDesktop) {
|
|
|
|
// await page.getByTestId('create-workspace-continue-button').click();
|
|
|
|
// }
|
2023-02-06 17:26:01 +03:00
|
|
|
}
|