mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-01 11:35:20 +03:00
7c2574b1ca
Co-authored-by: Himself65 <himself65@outlook.com>
74 lines
2.7 KiB
TypeScript
74 lines
2.7 KiB
TypeScript
import { test } from '@affine-test/kit/playwright';
|
|
import { expect } from '@playwright/test';
|
|
|
|
import { openHomePage } from '../libs/load-page';
|
|
import { waitMarkdownImported } from '../libs/page-logic';
|
|
import {
|
|
clickSideBarCurrentWorkspaceBanner,
|
|
clickSideBarSettingButton,
|
|
} from '../libs/sidebar';
|
|
import { assertCurrentWorkspaceFlavour } from '../libs/workspace';
|
|
|
|
test('Create new workspace, then delete it', async ({ page }) => {
|
|
await openHomePage(page);
|
|
await waitMarkdownImported(page);
|
|
await clickSideBarCurrentWorkspaceBanner(page);
|
|
await page.getByTestId('new-workspace').click();
|
|
await page
|
|
.getByTestId('create-workspace-input')
|
|
.type('Test Workspace', { delay: 50 });
|
|
await page.getByTestId('create-workspace-create-button').click();
|
|
|
|
await page.waitForTimeout(1000);
|
|
await page.waitForSelector('[data-testid="workspace-name"]');
|
|
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
|
'Test Workspace'
|
|
);
|
|
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"]');
|
|
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'
|
|
);
|
|
await assertCurrentWorkspaceFlavour('local', page);
|
|
});
|