AFFiNE/tests/affine-local/e2e/local-first-delete-workspace.spec.ts

84 lines
3.3 KiB
TypeScript
Raw Normal View History

import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import {
openSettingModal,
openWorkspaceSettingPanel,
} from '@affine-test/kit/utils/setting';
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
import { expect } from '@playwright/test';
2023-07-13 15:41:46 +03:00
test('Create new workspace, then delete it', async ({ page, workspace }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await clickSideBarCurrentWorkspaceBanner(page);
await page.getByTestId('new-workspace').click();
2024-08-29 07:01:35 +03:00
await page.waitForTimeout(1000);
await page
.getByTestId('create-workspace-input')
.pressSequentially('Test Workspace', { delay: 50 });
chore: bump blocksuite (#7696) ## Features - https://github.com/toeverything/BlockSuite/pull/7807 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/7786 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/7797 @donteatfriedrice ## Bugfix - https://github.com/toeverything/BlockSuite/pull/7814 @fundon - https://github.com/toeverything/BlockSuite/pull/7812 @L-Sun - https://github.com/toeverything/BlockSuite/pull/7792 @fundon - https://github.com/toeverything/BlockSuite/pull/7788 @fundon - https://github.com/toeverything/BlockSuite/pull/7805 @doouding - https://github.com/toeverything/BlockSuite/pull/7810 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/7802 @L-Sun - https://github.com/toeverything/BlockSuite/pull/7804 @L-Sun - https://github.com/toeverything/BlockSuite/pull/7799 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/7753 @CatsJuice - https://github.com/toeverything/BlockSuite/pull/7798 @zzj3720 - https://github.com/toeverything/BlockSuite/pull/7796 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/7793 @doouding - https://github.com/toeverything/BlockSuite/pull/7795 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/7791 @fundon - https://github.com/toeverything/BlockSuite/pull/7747 @doouding - https://github.com/toeverything/BlockSuite/pull/7785 @fundon - https://github.com/toeverything/BlockSuite/pull/7784 @akumatus ## Misc - https://github.com/toeverything/BlockSuite/pull/7800 @Saul-Mirone - https://github.com/toeverything/BlockSuite/pull/7790 @fourdim
2024-08-02 04:29:10 +03:00
const createButton = page.getByTestId('create-workspace-create-button');
await createButton.click();
await createButton.waitFor({ state: 'hidden' });
await page.waitForSelector('[data-testid="workspace-name"]');
expect(await page.getByTestId('workspace-name').textContent()).toBe(
'Test Workspace'
);
await openSettingModal(page);
await openWorkspaceSettingPanel(page, 'Test Workspace');
await page.getByTestId('delete-workspace-button').click();
await expect(
page.locator('.affine-notification-center').first()
).not.toBeVisible();
const workspaceNameDom = page.getByTestId('workspace-name');
const currentWorkspaceName = (await workspaceNameDom.evaluate(
node => node.textContent
)) as string;
expect(currentWorkspaceName).toBeDefined();
await page
.getByTestId('delete-workspace-input')
.pressSequentially(currentWorkspaceName);
const promise = page
.locator('.affine-notification-center')
.first()
.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'
);
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');
});
test('Delete last workspace', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
const workspaceNameDom = page.getByTestId('workspace-name');
const currentWorkspaceName = await workspaceNameDom.evaluate(
node => node.textContent
);
await openSettingModal(page);
await openWorkspaceSettingPanel(page, currentWorkspaceName as string);
await page.getByTestId('delete-workspace-button').click();
await page
.getByTestId('delete-workspace-input')
.pressSequentially(currentWorkspaceName as string);
await page.getByTestId('delete-workspace-confirm-button').click();
await openHomePage(page);
await expect(page.getByTestId('new-workspace')).toBeVisible();
await page.getByTestId('new-workspace').click();
await page
.locator('[data-testid="create-workspace-input"]')
.pressSequentially('Test Workspace');
await page.getByTestId('create-workspace-create-button').click();
await page.waitForTimeout(1000);
await page.waitForSelector('[data-testid="workspace-name"]');
2024-04-17 09:12:29 +03:00
await expect(page.getByTestId('workspace-name')).toHaveText('Test Workspace');
});