2023-04-25 06:12:48 +03:00
|
|
|
import { test } from '@affine-test/kit/playwright';
|
2023-03-05 09:51:29 +03:00
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
|
2023-03-24 01:15:40 +03:00
|
|
|
import { openHomePage } from '../libs/load-page';
|
2023-03-28 08:25:16 +03:00
|
|
|
import { waitMarkdownImported } from '../libs/page-logic';
|
2023-05-03 07:31:04 +03:00
|
|
|
import {
|
|
|
|
clickSideBarCurrentWorkspaceBanner,
|
|
|
|
clickSideBarSettingButton,
|
|
|
|
} from '../libs/sidebar';
|
2023-03-24 01:15:40 +03:00
|
|
|
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
2023-03-05 09:51:29 +03:00
|
|
|
|
2023-05-03 07:31:04 +03:00
|
|
|
test('Create new workspace, then delete it', async ({ page }) => {
|
2023-04-17 00:02:41 +03:00
|
|
|
await openHomePage(page);
|
|
|
|
await waitMarkdownImported(page);
|
2023-05-03 07:31:04 +03:00
|
|
|
await clickSideBarCurrentWorkspaceBanner(page);
|
|
|
|
await page.getByTestId('new-workspace').click();
|
|
|
|
await page
|
|
|
|
.getByTestId('create-workspace-input')
|
|
|
|
.type('Test Workspace', { delay: 50 });
|
2023-05-09 10:30:01 +03:00
|
|
|
await page.getByTestId('create-workspace-create-button').click();
|
|
|
|
|
2023-05-03 07:31:04 +03:00
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
await page.waitForSelector('[data-testid="workspace-name"]');
|
|
|
|
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
|
|
|
'Test Workspace'
|
|
|
|
);
|
2023-04-17 00:02:41 +03:00
|
|
|
await clickSideBarSettingButton(page);
|
|
|
|
await page.getByTestId('delete-workspace-button').click();
|
|
|
|
const workspaceNameDom = await page.getByTestId('workspace-name');
|
|
|
|
const currentWorkspaceName = await workspaceNameDom.evaluate(
|
|
|
|
node => node.textContent
|
|
|
|
);
|
|
|
|
await page
|
|
|
|
.getByTestId('delete-workspace-input')
|
|
|
|
.type(currentWorkspaceName as string);
|
2023-05-03 07:31:04 +03:00
|
|
|
const promise = page
|
|
|
|
.getByTestId('affine-toast')
|
|
|
|
.waitFor({ state: 'attached' });
|
2023-04-17 00:02:41 +03:00
|
|
|
await page.getByTestId('delete-workspace-confirm-button').click();
|
2023-05-03 07:31:04 +03:00
|
|
|
await promise;
|
|
|
|
await page.reload();
|
|
|
|
await page.waitForSelector('[data-testid="workspace-name"]');
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
|
|
|
'Demo Workspace'
|
|
|
|
);
|
|
|
|
await assertCurrentWorkspaceFlavour('local', page);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Should not delete the last one workspace', async ({ page }) => {
|
|
|
|
await openHomePage(page);
|
|
|
|
await waitMarkdownImported(page);
|
|
|
|
await clickSideBarSettingButton(page);
|
|
|
|
await page.getByTestId('delete-workspace-button').click();
|
|
|
|
const workspaceNameDom = await page.getByTestId('workspace-name');
|
|
|
|
const currentWorkspaceName = await workspaceNameDom.evaluate(
|
|
|
|
node => node.textContent
|
|
|
|
);
|
|
|
|
await page
|
|
|
|
.getByTestId('delete-workspace-input')
|
|
|
|
.type(currentWorkspaceName as string);
|
|
|
|
const promise = page
|
|
|
|
.getByTestId('affine-toast')
|
|
|
|
.waitFor({ state: 'attached' });
|
|
|
|
await page.getByTestId('delete-workspace-confirm-button').click();
|
|
|
|
await promise;
|
|
|
|
await page.reload();
|
|
|
|
await page.waitForSelector('[data-testid="workspace-name"]');
|
|
|
|
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
|
|
|
'Demo Workspace'
|
|
|
|
);
|
2023-04-17 00:02:41 +03:00
|
|
|
await assertCurrentWorkspaceFlavour('local', page);
|
2023-03-05 09:51:29 +03:00
|
|
|
});
|