2023-02-06 17:26:01 +03:00
|
|
|
import { expect } from '@playwright/test';
|
2023-02-17 10:33:32 +03:00
|
|
|
|
2023-02-17 05:43:52 +03:00
|
|
|
import { loadPage } from './libs/load-page';
|
2023-02-17 10:33:32 +03:00
|
|
|
import { test } from './libs/playwright';
|
2023-02-17 05:43:52 +03:00
|
|
|
import { createWorkspace } from './libs/workspace-logic';
|
2023-02-06 17:26:01 +03:00
|
|
|
loadPage();
|
|
|
|
|
|
|
|
test.describe('Local first workspace list', () => {
|
|
|
|
test('just one item in the workspace list at first', async ({ page }) => {
|
|
|
|
const workspaceName = page.getByTestId('workspace-name');
|
|
|
|
await workspaceName.click();
|
|
|
|
expect(
|
|
|
|
page
|
|
|
|
.locator('div')
|
|
|
|
.filter({ hasText: 'AFFiNE TestLocal WorkspaceAvailable Offline' })
|
|
|
|
.nth(3)
|
|
|
|
).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
2023-02-08 12:48:03 +03:00
|
|
|
test('create one workspace in the workspace list', async ({ page }) => {
|
2023-02-06 17:26:01 +03:00
|
|
|
const newWorkspaceNameStr = 'New Workspace';
|
|
|
|
await createWorkspace({ name: newWorkspaceNameStr }, page);
|
|
|
|
|
|
|
|
// check new workspace name
|
|
|
|
const newWorkspaceName = page.getByTestId('workspace-name');
|
2023-02-08 12:48:03 +03:00
|
|
|
await newWorkspaceName.click();
|
|
|
|
|
|
|
|
//check workspace list length
|
|
|
|
const workspaceCards = await page.$$('data-testid=workspace-card');
|
|
|
|
expect(workspaceCards.length).toBe(2);
|
2023-02-09 11:28:01 +03:00
|
|
|
|
|
|
|
//check page list length
|
|
|
|
const closeWorkspaceModal = page.getByTestId('close-workspace-modal');
|
|
|
|
await closeWorkspaceModal.click();
|
|
|
|
const allPageButton = page.getByTestId('all-pages');
|
|
|
|
await allPageButton.click();
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
const pageList = page.locator('[data-testid=page-list-item]');
|
|
|
|
const result = await pageList.count();
|
2023-03-01 10:40:01 +03:00
|
|
|
expect(result).toBe(0);
|
2023-02-09 11:28:01 +03:00
|
|
|
await page.reload();
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
const pageList1 = page.locator('[data-testid=page-list-item]');
|
|
|
|
const result1 = await pageList1.count();
|
2023-03-01 10:40:01 +03:00
|
|
|
expect(result1).toBe(0);
|
2023-02-06 17:26:01 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
test('create multi workspace in the workspace list', async ({ page }) => {
|
|
|
|
await createWorkspace({ name: 'New Workspace 2' }, page);
|
|
|
|
await createWorkspace({ name: 'New Workspace 3' }, page);
|
|
|
|
|
|
|
|
// show workspace list
|
|
|
|
const workspaceName = page.getByTestId('workspace-name');
|
|
|
|
await workspaceName.click();
|
|
|
|
|
|
|
|
//check workspace list length
|
|
|
|
const workspaceCards = await page.$$('data-testid=workspace-card');
|
|
|
|
expect(workspaceCards.length).toBe(3);
|
|
|
|
});
|
|
|
|
});
|