2023-04-25 06:12:48 +03:00
|
|
|
import { test } from '@affine-test/kit/playwright';
|
2023-07-13 12:05:01 +03:00
|
|
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
2023-09-02 06:31:07 +03:00
|
|
|
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
|
2023-07-13 12:05:01 +03:00
|
|
|
import { openWorkspaceSettingPanel } from '@affine-test/kit/utils/setting';
|
|
|
|
import { openSettingModal } from '@affine-test/kit/utils/setting';
|
|
|
|
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
|
2023-03-05 09:51:29 +03:00
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
|
2023-07-13 15:41:46 +03:00
|
|
|
test('Create new workspace, then delete it', async ({ page, workspace }) => {
|
2023-04-17 00:02:41 +03:00
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-05-03 07:31:04 +03:00
|
|
|
await clickSideBarCurrentWorkspaceBanner(page);
|
|
|
|
await page.getByTestId('new-workspace').click();
|
|
|
|
await page
|
|
|
|
.getByTestId('create-workspace-input')
|
2023-10-11 09:05:06 +03:00
|
|
|
.pressSequentially('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-06-29 15:54:45 +03:00
|
|
|
await openSettingModal(page);
|
|
|
|
await openWorkspaceSettingPanel(page, 'Test Workspace');
|
2023-04-17 00:02:41 +03:00
|
|
|
await page.getByTestId('delete-workspace-button').click();
|
2023-10-12 08:04:58 +03:00
|
|
|
const workspaceNameDom = page.getByTestId('workspace-name');
|
2023-10-11 09:05:06 +03:00
|
|
|
const currentWorkspaceName = (await workspaceNameDom.evaluate(
|
2023-04-17 00:02:41 +03:00
|
|
|
node => node.textContent
|
2023-10-11 09:05:06 +03:00
|
|
|
)) as string;
|
|
|
|
expect(currentWorkspaceName).toBeDefined();
|
2023-04-17 00:02:41 +03:00
|
|
|
await page
|
|
|
|
.getByTestId('delete-workspace-input')
|
2023-10-11 09:05:06 +03:00
|
|
|
.pressSequentially(currentWorkspaceName);
|
2023-05-03 07:31:04 +03:00
|
|
|
const promise = page
|
2023-08-29 13:07:05 +03:00
|
|
|
.getByTestId('affine-notification')
|
2023-05-03 07:31:04 +03:00
|
|
|
.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'
|
|
|
|
);
|
2023-07-13 15:41:46 +03:00
|
|
|
const currentWorkspace = await workspace.current();
|
|
|
|
|
2023-12-15 10:20:50 +03:00
|
|
|
expect(currentWorkspace.meta.flavour).toContain('local');
|
2023-05-03 07:31:04 +03:00
|
|
|
});
|
2023-10-11 09:05:06 +03:00
|
|
|
|
2023-05-31 07:24:14 +03:00
|
|
|
test('Delete last workspace', async ({ page }) => {
|
2023-05-03 07:31:04 +03:00
|
|
|
await openHomePage(page);
|
2023-09-02 06:31:07 +03:00
|
|
|
await waitForEditorLoad(page);
|
2023-10-12 08:04:58 +03:00
|
|
|
const workspaceNameDom = page.getByTestId('workspace-name');
|
2023-05-31 07:24:14 +03:00
|
|
|
const currentWorkspaceName = await workspaceNameDom.evaluate(
|
|
|
|
node => node.textContent
|
|
|
|
);
|
2023-06-29 15:54:45 +03:00
|
|
|
await openSettingModal(page);
|
|
|
|
await openWorkspaceSettingPanel(page, currentWorkspaceName as string);
|
|
|
|
await page.getByTestId('delete-workspace-button').click();
|
2023-05-31 07:24:14 +03:00
|
|
|
await page
|
|
|
|
.getByTestId('delete-workspace-input')
|
2023-10-11 09:05:06 +03:00
|
|
|
.pressSequentially(currentWorkspaceName as string);
|
2023-05-31 07:24:14 +03:00
|
|
|
await page.getByTestId('delete-workspace-confirm-button').click();
|
2023-08-29 13:07:05 +03:00
|
|
|
await openHomePage(page);
|
2023-05-31 07:24:14 +03:00
|
|
|
await expect(page.getByTestId('new-workspace')).toBeVisible();
|
|
|
|
await page.getByTestId('new-workspace').click();
|
2023-10-11 09:05:06 +03:00
|
|
|
await page
|
|
|
|
.locator('[data-testid="create-workspace-input"]')
|
|
|
|
.pressSequentially('Test Workspace');
|
2023-05-31 07:24:14 +03:00
|
|
|
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'
|
|
|
|
);
|
2023-03-05 09:51:29 +03:00
|
|
|
});
|