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';
|
|
|
|
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';
|
|
|
|
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-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(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-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();
|
|
|
|
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
|
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();
|
|
|
|
|
|
|
|
expect(currentWorkspace.flavour).toContain('local');
|
2023-05-03 07:31:04 +03:00
|
|
|
});
|
2023-08-29 13:07:05 +03:00
|
|
|
//FIXME: this test is broken
|
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-06-07 12:31:54 +03:00
|
|
|
await waitEditorLoad(page);
|
2023-05-31 07:24:14 +03:00
|
|
|
const workspaceNameDom = await page.getByTestId('workspace-name');
|
|
|
|
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')
|
|
|
|
.type(currentWorkspaceName as string);
|
|
|
|
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();
|
|
|
|
await page.type('[data-testid="create-workspace-input"]', 'Test Workspace');
|
|
|
|
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
|
|
|
});
|