Merge branch 'master' into fix/lost-entrance-of-quick-search

This commit is contained in:
JimmFly
2023-02-07 10:15:30 +08:00
25 changed files with 320 additions and 386 deletions

View File

@@ -0,0 +1,24 @@
import type { Page } from '@playwright/test';
interface CreateWorkspaceParams {
name: string;
}
export async function createWorkspace(
params: CreateWorkspaceParams,
page: Page
) {
// open workspace list modal
const workspaceName = page.getByTestId('workspace-name');
await workspaceName.click();
// open create workspace modal
await page.locator('.add-icon').click();
// input workspace name
await page.getByPlaceholder('Set a Workspace name').click();
await page.getByPlaceholder('Set a Workspace name').fill(params.name);
// click create button
await page.getByRole('button', { name: 'Create' }).click();
return page.waitForTimeout(300);
}

View File

@@ -0,0 +1,40 @@
import { expect } from '@playwright/test';
import { test } from './libs/playwright.js';
import { loadPage } from './libs/load-page.js';
import { createWorkspace } from './libs/workspace-logic.js';
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();
});
test.skip('create one workspace in the workspace list', async ({ page }) => {
const newWorkspaceNameStr = 'New Workspace';
await createWorkspace({ name: newWorkspaceNameStr }, page);
// check new workspace name
const newWorkspaceName = page.getByTestId('workspace-name');
expect(await newWorkspaceName.textContent()).toBe(newWorkspaceNameStr);
});
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);
});
});

View File

@@ -5,15 +5,15 @@ import { loadPage } from './libs/load-page.js';
loadPage();
test.describe('Local first default workspace', () => {
test.skip('Default workspace name', async ({ page }) => {
test('preset workspace name', async ({ page }) => {
const workspaceName = page.getByTestId('workspace-name');
expect(await workspaceName.textContent()).toBe('AFFiNE');
expect(await workspaceName.textContent()).toBe('AFFiNE Test');
});
test.skip('Default workspace avatar', async ({ page }) => {
test('default workspace avatar', async ({ page }) => {
const workspaceAvatar = page.getByTestId('workspace-avatar');
expect(await workspaceAvatar.innerHTML()).toBe(
'<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="0.5" y="0.5" width="39" height="39" rx="19.5" stroke="#6880FF" fill="#FFF"></rect><path fillRule="evenodd" clipRule="evenodd" d="M18.6303 8.79688L11.2559 29.8393H15.5752L20.2661 15.2858L24.959 29.8393H29.2637L21.8881 8.79688H18.6303Z" fill="#6880FF"></path></svg>'
);
expect(
await workspaceAvatar.locator('img').getAttribute('src')
).not.toBeNull();
});
});

View File

@@ -75,7 +75,7 @@ test.describe('Add new page in quick search', () => {
});
test.describe('Search and select', () => {
test('Create a new page and search this page', async ({ page }) => {
test.skip('Create a new page and search this page', async ({ page }) => {
await newPage(page);
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');