refactor!: next generation AFFiNE code structure (#1176)

This commit is contained in:
Himself65
2023-03-01 01:40:01 -06:00
committed by GitHub
parent 2dcccc772c
commit e0481d29ad
270 changed files with 8308 additions and 6829 deletions

View File

@@ -40,7 +40,7 @@ test.describe('Change page mode(Paper or Edgeless)', () => {
test('Convert to edgeless by editor header items', async ({ page }) => {
await clickPageMoreActions(page);
const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless');
await menusEdgelessItem.click();
await menusEdgelessItem.click({ delay: 100 });
const edgeless = page.locator('affine-edgeless-page');
expect(await edgeless.isVisible()).toBe(true);

View File

@@ -1,24 +0,0 @@
import { expect } from '@playwright/test';
import fs from 'fs';
import path from 'path';
import { loadPage } from './libs/load-page';
import { test } from './libs/playwright';
const pkgPath = path.join(__dirname, '../apps/web/package.json');
const record = fs.readFileSync(pkgPath, 'utf8');
const temp = JSON.parse(record);
loadPage();
declare global {
// eslint-disable-next-line no-var
var __editoVersion: unknown;
}
test.describe('web console', () => {
test('editor version', async ({ page }) => {
const pkgEditorVersion = temp.dependencies['@blocksuite/editor'];
const editoVersion = await page.evaluate(() => window.__editoVersion);
expect(editoVersion).toBe(pkgEditorVersion);
});
});

View File

@@ -1,13 +1,16 @@
import type { Page } from '@playwright/test';
export async function newPage(page: Page) {
return page.getByTestId('sliderBar').getByText('New Page').click();
// fixme(himself65): if too fast, the page will crash
await page.getByTestId('sliderBar').getByText('New Page').click({
delay: 100,
});
await page.waitForTimeout(100);
}
export async function clickPageMoreActions(page: Page) {
return page
.getByTestId('editor-header-items')
.getByRole('button')
.nth(1)
.getByTestId('editor-option-menu')
.click();
}

View File

@@ -37,12 +37,12 @@ test.describe('Local first workspace list', () => {
await page.waitForTimeout(1000);
const pageList = page.locator('[data-testid=page-list-item]');
const result = await pageList.count();
expect(result).toBe(1);
expect(result).toBe(0);
await page.reload();
await page.waitForTimeout(1000);
const pageList1 = page.locator('[data-testid=page-list-item]');
const result1 = await pageList1.count();
expect(result1).toBe(1);
expect(result1).toBe(0);
});
test('create multi workspace in the workspace list', async ({ page }) => {

View File

@@ -8,15 +8,15 @@ loadPage();
test.describe('Local first default workspace', () => {
test('preset workspace name', async ({ page }) => {
const workspaceName = page.getByTestId('workspace-name');
expect(await workspaceName.textContent()).toBe('Demo Workspace');
expect(await workspaceName.textContent()).toBe('Untitled Workspace');
});
test('default workspace avatar', async ({ page }) => {
const workspaceAvatar = page.getByTestId('workspace-avatar');
expect(
await workspaceAvatar.locator('img').getAttribute('src')
).not.toBeNull();
});
// test('default workspace avatar', async ({ page }) => {
// const workspaceAvatar = page.getByTestId('workspace-avatar');
// expect(
// await workspaceAvatar.locator('img').getAttribute('src')
// ).not.toBeNull();
// });
});
test.describe('Language switch', () => {
test('Open language switch menu', async ({ page }) => {

View File

@@ -34,7 +34,7 @@ test.describe('Open quick search', () => {
test('Click slider bar button', async ({ page }) => {
await newPage(page);
const quickSearchButton = page.locator(
'[data-testid=sliderBar-quickSearchButton]'
'[data-testid=slider-bar-quick-search-button]'
);
await quickSearchButton.click();
const quickSearch = page.locator('[data-testid=quickSearch]');
@@ -44,7 +44,7 @@ test.describe('Open quick search', () => {
test('Click arrowDown icon after title', async ({ page }) => {
await newPage(page);
const quickSearchButton = page.locator(
'[data-testid=header-quickSearchButton]'
'[data-testid=slider-bar-quick-search-button]'
);
await quickSearchButton.click();
const quickSearch = page.locator('[data-testid=quickSearch]');
@@ -63,7 +63,7 @@ test.describe('Add new page in quick search', () => {
test('Create a new page without keyword', async ({ page }) => {
await newPage(page);
await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]');
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
await addNewPage.click();
await page.waitForTimeout(300);
await assertTitle(page, '');
@@ -73,7 +73,7 @@ test.describe('Add new page in quick search', () => {
await newPage(page);
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');
const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]');
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
await addNewPage.click();
await page.waitForTimeout(300);
await assertTitle(page, 'test123456');
@@ -92,13 +92,14 @@ test.describe('Search and select', () => {
await newPage(page);
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');
const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]');
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
await addNewPage.click();
await page.waitForTimeout(300);
await assertTitle(page, 'test123456');
await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456');
await assertResultList(page, ['test123456']);
await page.waitForTimeout(50);
await assertResultList(page, ["New 'test123456' page"]);
await page.keyboard.press('Enter');
await page.waitForTimeout(300);
await assertTitle(page, 'test123456');
@@ -144,7 +145,7 @@ test.describe('Focus event for quick search', () => {
test('Focus title after creating a new page', async ({ page }) => {
await newPage(page);
await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quickSearch-addNewPage]');
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
await addNewPage.click();
await titleIsFocused(page);
});

View File

@@ -6,7 +6,8 @@ import { test } from './libs/playwright';
loadPage();
test.describe('Change Theme', () => {
test('default white', async ({ page }) => {
// default could be anything according to the system
test.skip('default white', async ({ page }) => {
await page.waitForSelector('html');
const root = page.locator('html');
const themeMode = await root.evaluate(element =>