snapshot of https://github.com/toeverything/AFFiNE.git (canary, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
Some checks failed
Build & Test / Analyze (javascript, affine) (push) Failing after 4s
Build & Test / Analyze (typescript, affine) (push) Failing after 3s
Build & Test / Rust test filter (push) Failing after 4s
Build & Test / Check yarn binary (push) Failing after 3s
Build & Test / E2E BlockSuite Test (3) (push) Failing after 3s
Build & Test / Analyze (javascript, blocksuite) (push) Failing after 3s
Build & Test / Analyze (typescript, blocksuite) (push) Failing after 3s
Build & Test / Mobile native build filter (push) Failing after 3s
Build & Test / E2E BlockSuite Test (1) (push) Failing after 4s
Build & Test / E2E BlockSuite Test (2) (push) Failing after 4s
Build & Test / E2E Mobile Test (1) (push) Failing after 3s
Build & Test / Unit Test (1) (push) Has been skipped
Build & Test / Unit Test (2) (push) Has been skipped
Build & Test / Unit Test (3) (push) Has been skipped
Build & Test / Unit Test (4) (push) Has been skipped
Build & Test / Unit Test (5) (push) Has been skipped
Build & Test / Native Unit Test (push) Has been skipped
Build & Test / E2E BlockSuite Test (4) (push) Failing after 3s
Build & Test / E2E BlockSuite Test (5) (push) Failing after 3s
Build & Test / E2E BlockSuite Cross Browser Test (push) Failing after 3s
Build & Test / E2E Mobile Test (2) (push) Failing after 3s
Build & Test / Build AFFiNE native (x86_64-unknown-linux-gnu) (push) Failing after 3s
Build & Test / Build Server native (push) Failing after 3s
Build & Test / Check Git Status (push) Has been skipped
Build & Test / Server Test (0, 4) (push) Has been skipped
Build & Test / Server Test (1, 4) (push) Has been skipped
Build & Test / Server Test (2, 4) (push) Has been skipped
Build & Test / Server Test (3, 4) (push) Has been skipped
Build & Test / Server Test with Elasticsearch (push) Has been skipped
Build & Test / Build @affine/electron renderer (push) Failing after 3s
Build & Test / Copilot test filter (push) Failing after 4s
Build & Test / Lint Rust (push) Has been skipped
Build & Test / Server Test with Embedded Search (push) Has been skipped
Build & Test / Server Test with Manticore Search (push) Has been skipped
Build & Test / Server E2E Test (push) Has been skipped
Build & Test / Cloud Desktop E2E Test (push) Has been skipped
Build & Test / Cloud E2E Test 1/2 (push) Has been skipped
Build & Test / Cloud E2E Test 2/2 (push) Has been skipped
Build & Test / Build Android app (push) Has been skipped
Build & Test / Test Android app (push) Has been skipped
Build & Test / Run native tests (push) Has been skipped
Build & Test / Server Copilot Api Test (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (1, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (2, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (3, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (4, 5) (push) Has been skipped
Build & Test / Frontend Copilot E2E Test (5, 5) (push) Has been skipped
Release / Canary Gate (push) Has been skipped
Build & Test / Build AFFiNE native (aarch64-apple-darwin) (push) Has been cancelled
Build & Test / Lint (push) Has been cancelled
Build & Test / Typecheck (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-apple-darwin) (push) Has been cancelled
Build & Test / Desktop Test (ubuntu-latest, linux, x64, x86_64-unknown-linux-gnu, true) (push) Has been cancelled
Build & Test / Desktop Test (windows-latest, windows, x64, x86_64-pc-windows-msvc, true) (push) Has been cancelled
Build & Test / E2E Test (1) (push) Has been cancelled
Build & Test / E2E Test (2) (push) Has been cancelled
Build & Test / E2E Test (3) (push) Has been cancelled
Build & Test / E2E Test (4) (push) Has been cancelled
Build & Test / E2E Test (5) (push) Has been cancelled
Build & Test / Build AFFiNE native (aarch64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Build AFFiNE native (x86_64-pc-windows-msvc) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, arm64, aarch64-apple-darwin, true) (push) Has been cancelled
Build & Test / Desktop Test (macos-latest, macos, x64, x86_64-apple-darwin, false) (push) Has been cancelled
Build & Test / 3, 2, 1 Launch (push) Has been cancelled
Build & Test / Build iOS app (push) Has been cancelled
Copilot Test Automatically / Setup Test (push) Failing after 1s
Release / Prepare (push) Failing after 2s
Release / Release Cloud (push) Has been skipped
Release / Release Desktop (push) Has been skipped
Release / Release Docker Image (push) Has been skipped
Release / Release Mobile (push) Has been skipped
This commit is contained in:
174
tests/affine-desktop/e2e/basic.spec.ts
Normal file
174
tests/affine-desktop/e2e/basic.spec.ts
Normal file
@@ -0,0 +1,174 @@
|
||||
import { test } from '@affine-test/kit/electron';
|
||||
import {
|
||||
ensureInEdgelessMode,
|
||||
ensureInPageMode,
|
||||
} from '@affine-test/kit/utils/editor';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
getBlockSuiteEditorTitle,
|
||||
waitForEditorLoad,
|
||||
} from '@affine-test/kit/utils/page-logic';
|
||||
import { clickSideBarSettingButton } from '@affine-test/kit/utils/sidebar';
|
||||
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
const historyShortcut = async (page: Page, command: 'goBack' | 'goForward') => {
|
||||
await page.keyboard.press(
|
||||
command === 'goBack' ? 'ControlOrMeta+[' : 'ControlOrMeta+]'
|
||||
);
|
||||
};
|
||||
|
||||
const setNewDocDefaultMode = async (
|
||||
page: Page,
|
||||
mode: 'page' | 'edgeless' | 'ask'
|
||||
) => {
|
||||
const modeTriggerByValue = {
|
||||
page: 'page-mode-trigger',
|
||||
edgeless: 'edgeless-mode-trigger',
|
||||
ask: 'ask-every-time-trigger',
|
||||
} as const;
|
||||
|
||||
await clickSideBarSettingButton(page);
|
||||
await page.getByTestId('editor-panel-trigger').click();
|
||||
await page.getByTestId('new-doc-default-mode-trigger').click();
|
||||
await page.getByTestId(modeTriggerByValue[mode]).click();
|
||||
await page.getByTestId('modal-close-button').click();
|
||||
};
|
||||
|
||||
test('new page', async ({ page, workspace }) => {
|
||||
await clickNewPageButton(page);
|
||||
const flavour = (await workspace.current()).meta.flavour;
|
||||
expect(flavour).toBe('local');
|
||||
});
|
||||
|
||||
test('application menu respects default new doc mode', async ({
|
||||
electronApp,
|
||||
page,
|
||||
}) => {
|
||||
await waitForEditorLoad(page);
|
||||
await ensureInPageMode(page);
|
||||
|
||||
await setNewDocDefaultMode(page, 'edgeless');
|
||||
await electronApp.evaluate(({ BrowserWindow, Menu }) => {
|
||||
const menuItem =
|
||||
Menu.getApplicationMenu()?.getMenuItemById('affine:new-page');
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
|
||||
if (!menuItem) {
|
||||
throw new Error('Missing application menu item: affine:new-page');
|
||||
}
|
||||
if (!focusedWindow) {
|
||||
throw new Error('Missing focused window for application menu dispatch');
|
||||
}
|
||||
|
||||
menuItem.click(undefined, focusedWindow, focusedWindow.webContents);
|
||||
});
|
||||
|
||||
await ensureInEdgelessMode(page);
|
||||
});
|
||||
|
||||
test('app sidebar router forward/back', async ({ page }) => {
|
||||
// create pages
|
||||
await page.waitForTimeout(500);
|
||||
await clickNewPageButton(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.focus();
|
||||
await title.pressSequentially('test1', {
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForTimeout(500);
|
||||
await clickNewPageButton(page);
|
||||
|
||||
await title.focus();
|
||||
await title.pressSequentially('test2', {
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForTimeout(500);
|
||||
await clickNewPageButton(page);
|
||||
await title.focus();
|
||||
await title.pressSequentially('test3', {
|
||||
delay: 100,
|
||||
});
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test3');
|
||||
|
||||
await page.click('[data-testid="app-navigation-button-back"]');
|
||||
await page.click('[data-testid="app-navigation-button-back"]');
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test1');
|
||||
await page.click('[data-testid="app-navigation-button-forward"]');
|
||||
await page.click('[data-testid="app-navigation-button-forward"]');
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test3');
|
||||
await historyShortcut(page, 'goBack');
|
||||
await historyShortcut(page, 'goBack');
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test1');
|
||||
await historyShortcut(page, 'goForward');
|
||||
await historyShortcut(page, 'goForward');
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test3');
|
||||
});
|
||||
|
||||
test('clientBorder value should disable by default on window', async ({
|
||||
page,
|
||||
}) => {
|
||||
await clickSideBarSettingButton(page);
|
||||
await page.waitForTimeout(1000);
|
||||
const settingItem = page.locator(
|
||||
'[data-testid="client-border-style-trigger"]'
|
||||
);
|
||||
expect(await settingItem.locator('input').inputValue()).toEqual(
|
||||
process.platform === 'win32' ? 'off' : 'on'
|
||||
);
|
||||
});
|
||||
|
||||
test('app theme', async ({ page, electronApp }) => {
|
||||
const root = page.locator('html');
|
||||
{
|
||||
const themeMode = await root.evaluate(element => element.dataset.theme);
|
||||
expect(themeMode).toBe('light');
|
||||
|
||||
const theme = await electronApp.evaluate(({ nativeTheme }) => {
|
||||
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||
});
|
||||
|
||||
expect(theme).toBe('light');
|
||||
}
|
||||
|
||||
{
|
||||
await page.getByTestId('settings-modal-trigger').click();
|
||||
await page.getByTestId('appearance-panel-trigger').click();
|
||||
await page.waitForTimeout(50);
|
||||
await page.getByTestId('dark-theme-trigger').click();
|
||||
const themeMode = await root.evaluate(element => element.dataset.theme);
|
||||
expect(themeMode).toBe('dark');
|
||||
const theme = await electronApp.evaluate(({ nativeTheme }) => {
|
||||
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||
});
|
||||
expect(theme).toBe('dark');
|
||||
}
|
||||
});
|
||||
|
||||
test('windows only check', async ({ page }) => {
|
||||
const windowOnlyUI = page.locator('[data-platform-target=win32]');
|
||||
if (process.platform === 'win32') {
|
||||
await expect(windowOnlyUI.first()).toBeVisible();
|
||||
} else {
|
||||
await expect(windowOnlyUI.first()).not.toBeVisible();
|
||||
}
|
||||
});
|
||||
|
||||
test('delete workspace', async ({ page }) => {
|
||||
await clickNewPageButton(page);
|
||||
|
||||
await createLocalWorkspace({ name: 'Delete Me' }, page);
|
||||
await page.waitForTimeout(1000);
|
||||
await clickSideBarSettingButton(page);
|
||||
await page.getByTestId('workspace-setting:preference').click();
|
||||
await expect(page.getByTestId('workspace-name-input')).toHaveValue(
|
||||
'Delete Me'
|
||||
);
|
||||
await page.getByTestId('delete-workspace-button').click();
|
||||
await page.getByTestId('delete-workspace-input').fill('Delete Me');
|
||||
await page.getByTestId('delete-workspace-confirm-button').click();
|
||||
await expect(page.getByTestId('workspace-name')).toContainText(
|
||||
'Demo Workspace'
|
||||
);
|
||||
});
|
||||
53
tests/affine-desktop/e2e/image.spec.ts
Normal file
53
tests/affine-desktop/e2e/image.spec.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { test } from '@affine-test/kit/electron';
|
||||
import { importImage } from '@affine-test/kit/utils/image';
|
||||
import { pasteByKeyboard } from '@affine-test/kit/utils/keyboard';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
getBlockSuiteEditorTitle,
|
||||
} from '@affine-test/kit/utils/page-logic';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
test('should be able to insert SVG images', async ({ page }) => {
|
||||
await page.waitForTimeout(500);
|
||||
await clickNewPageButton(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.focus();
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await importImage(page, 'affine.svg');
|
||||
|
||||
const svg = page.locator('affine-image').first();
|
||||
await expect(svg).toBeVisible();
|
||||
});
|
||||
|
||||
test('should paste it as PNG after copying SVG', async ({ page }) => {
|
||||
await page.waitForTimeout(500);
|
||||
await clickNewPageButton(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.focus();
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
await importImage(page, 'affine.svg');
|
||||
|
||||
const svg = page.locator('affine-image').first();
|
||||
await expect(svg).toBeVisible();
|
||||
|
||||
await svg.hover();
|
||||
|
||||
await page.waitForTimeout(500);
|
||||
const toolbar = page.locator('affine-toolbar-widget editor-toolbar');
|
||||
await expect(toolbar).toBeVisible();
|
||||
|
||||
const moreMenu = toolbar.getByLabel('More menu');
|
||||
await moreMenu.click();
|
||||
|
||||
await moreMenu.getByRole('button', { name: /^Copy$/ }).click();
|
||||
|
||||
await svg.click();
|
||||
|
||||
await page.keyboard.press('Enter');
|
||||
await pasteByKeyboard(page);
|
||||
|
||||
const png = page.locator('affine-image').nth(1);
|
||||
await expect(png).toBeVisible();
|
||||
});
|
||||
135
tests/affine-desktop/e2e/split-view.spec.ts
Normal file
135
tests/affine-desktop/e2e/split-view.spec.ts
Normal file
@@ -0,0 +1,135 @@
|
||||
import { test } from '@affine-test/kit/electron';
|
||||
import {
|
||||
expectActiveTab,
|
||||
expectTabTitle,
|
||||
} from '@affine-test/kit/utils/app-tabs';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
createLinkedPage,
|
||||
dragTo,
|
||||
getPageByTitle,
|
||||
waitForAllPagesLoad,
|
||||
} from '@affine-test/kit/utils/page-logic';
|
||||
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
const SPLIT_VIEW_READY_TIMEOUT = 30_000;
|
||||
|
||||
test('open split view', async ({ page }) => {
|
||||
await clickNewPageButton(page);
|
||||
await page.waitForTimeout(500);
|
||||
await page.keyboard.press('Enter');
|
||||
await createLinkedPage(page, 'hi from another page');
|
||||
await page
|
||||
.locator('.affine-reference-title:has-text("hi from another page")')
|
||||
.click({
|
||||
modifiers: ['ControlOrMeta', 'Alt'],
|
||||
});
|
||||
await expect(page.locator('.doc-title-container')).toHaveCount(2, {
|
||||
timeout: SPLIT_VIEW_READY_TIMEOUT,
|
||||
});
|
||||
|
||||
// check tab title
|
||||
await expect(page.getByTestId('split-view-label')).toHaveCount(2, {
|
||||
timeout: SPLIT_VIEW_READY_TIMEOUT,
|
||||
});
|
||||
await expectTabTitle(
|
||||
page,
|
||||
0,
|
||||
['Untitled', 'hi from another page'],
|
||||
SPLIT_VIEW_READY_TIMEOUT
|
||||
);
|
||||
|
||||
// the first split view should be active
|
||||
await expectActiveTab(page, 0, 0);
|
||||
|
||||
// by clicking the first split view label, the first split view should be active
|
||||
await page.getByTestId('split-view-label').nth(0).click();
|
||||
await expectActiveTab(page, 0, 0);
|
||||
await expect(page.getByTestId('split-view-indicator').nth(0)).toHaveAttribute(
|
||||
'data-active',
|
||||
'true'
|
||||
);
|
||||
|
||||
const firstDragHandle = page
|
||||
.getByTestId('split-view-panel')
|
||||
.first()
|
||||
.getByTestId('split-view-indicator');
|
||||
|
||||
await dragTo(
|
||||
page,
|
||||
firstDragHandle,
|
||||
page.getByTestId('split-view-panel').last(),
|
||||
'center',
|
||||
true
|
||||
);
|
||||
|
||||
await expectTabTitle(
|
||||
page,
|
||||
0,
|
||||
['hi from another page', 'Untitled'],
|
||||
SPLIT_VIEW_READY_TIMEOUT
|
||||
);
|
||||
});
|
||||
|
||||
test('open split view in all docs (operations button)', async ({ page }) => {
|
||||
const testTitle = 'test-page';
|
||||
await clickNewPageButton(page, testTitle);
|
||||
await clickSideBarAllPageButton(page);
|
||||
await waitForAllPagesLoad(page);
|
||||
await getPageByTitle(page, testTitle)
|
||||
.getByTestId('doc-list-operation-button')
|
||||
.click();
|
||||
await page.getByRole('menuitem', { name: 'Open in split view' }).click();
|
||||
await expect(page.getByTestId('split-view-panel')).toHaveCount(2, {
|
||||
timeout: SPLIT_VIEW_READY_TIMEOUT,
|
||||
});
|
||||
const targetPage = page.getByTestId('split-view-panel').last();
|
||||
await expect(targetPage).toHaveAttribute('data-is-active', 'true');
|
||||
await expect(targetPage.locator('.doc-title-container')).toBeVisible({
|
||||
timeout: SPLIT_VIEW_READY_TIMEOUT,
|
||||
});
|
||||
await expect(targetPage.locator('.doc-title-container')).toContainText(
|
||||
testTitle,
|
||||
{ timeout: SPLIT_VIEW_READY_TIMEOUT }
|
||||
);
|
||||
});
|
||||
|
||||
test('open split view in all docs (drag to resize handle)', async ({
|
||||
page,
|
||||
}) => {
|
||||
const testTitle = 'test-page';
|
||||
await clickNewPageButton(page, testTitle);
|
||||
await clickSideBarAllPageButton(page);
|
||||
await waitForAllPagesLoad(page);
|
||||
|
||||
const pageItem = getPageByTitle(page, testTitle);
|
||||
|
||||
const leftResizeHandle = page.getByTestId('resize-handle').first();
|
||||
|
||||
await dragTo(page, pageItem, leftResizeHandle, 'center');
|
||||
await expectTabTitle(
|
||||
page,
|
||||
0,
|
||||
['test-page', 'All docs'],
|
||||
SPLIT_VIEW_READY_TIMEOUT
|
||||
);
|
||||
});
|
||||
|
||||
test('creating split view by dragging sidebar journals', async ({ page }) => {
|
||||
const journalButton = page.getByTestId('slider-bar-journals-button');
|
||||
const leftResizeHandle = page.getByTestId('resize-handle').first();
|
||||
|
||||
await dragTo(page, journalButton, leftResizeHandle, 'center');
|
||||
await expect(page.getByTestId('split-view-panel')).toHaveCount(2, {
|
||||
timeout: SPLIT_VIEW_READY_TIMEOUT,
|
||||
});
|
||||
await expect(
|
||||
page
|
||||
.getByTestId('split-view-panel')
|
||||
.filter({
|
||||
has: page.locator('[data-is-first="true"]'),
|
||||
})
|
||||
.getByTestId('date-today-label')
|
||||
).toBeVisible({ timeout: SPLIT_VIEW_READY_TIMEOUT });
|
||||
});
|
||||
153
tests/affine-desktop/e2e/tabs.spec.ts
Normal file
153
tests/affine-desktop/e2e/tabs.spec.ts
Normal file
@@ -0,0 +1,153 @@
|
||||
import { test } from '@affine-test/kit/electron';
|
||||
import {
|
||||
closeTab,
|
||||
expectActiveTab,
|
||||
expectTabCount,
|
||||
expectTabTitle,
|
||||
} from '@affine-test/kit/utils/app-tabs';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
createLinkedPage,
|
||||
dragTo,
|
||||
getPageByTitle,
|
||||
} from '@affine-test/kit/utils/page-logic';
|
||||
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
test('create new tab', async ({ views }) => {
|
||||
let page = await views.getActive();
|
||||
|
||||
await page.getByTestId('add-tab-view-button').click();
|
||||
await expectTabCount(page, 2);
|
||||
// new tab title should be All docs
|
||||
await expectTabTitle(page, 1, 'All docs');
|
||||
await expectActiveTab(page, 1);
|
||||
});
|
||||
|
||||
test('can switch & close tab by clicking', async ({ page }) => {
|
||||
await page.getByTestId('add-tab-view-button').click();
|
||||
|
||||
await expectActiveTab(page, 1);
|
||||
|
||||
// switch to the previous tab by clicking on it
|
||||
await page.getByTestId('workbench-tab').nth(0).click();
|
||||
await expectActiveTab(page, 0);
|
||||
|
||||
// switch to the next tab by clicking on it
|
||||
await page.getByTestId('workbench-tab').nth(1).click();
|
||||
await expectActiveTab(page, 1);
|
||||
|
||||
// close the current tab
|
||||
await closeTab(page, 1);
|
||||
|
||||
// the first tab should be active
|
||||
await expectActiveTab(page, 0);
|
||||
await expectTabCount(page, 1);
|
||||
});
|
||||
|
||||
test('Collapse Sidebar', async ({ page }) => {
|
||||
await page
|
||||
.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]')
|
||||
.click();
|
||||
const sliderBarArea = page.getByTestId('app-sidebar');
|
||||
await expect(sliderBarArea).not.toBeInViewport();
|
||||
});
|
||||
|
||||
test('Expand Sidebar', async ({ page }) => {
|
||||
await page
|
||||
.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]')
|
||||
.click();
|
||||
const sliderBarArea = page.getByTestId('app-sidebar');
|
||||
await expect(sliderBarArea).not.toBeInViewport();
|
||||
|
||||
await page
|
||||
.locator('[data-testid=app-sidebar-arrow-button-expand][data-show=true]')
|
||||
.click();
|
||||
await expect(sliderBarArea).toBeInViewport();
|
||||
});
|
||||
|
||||
test('tab title will change when navigating', async ({ page }) => {
|
||||
await expectTabTitle(page, 0, 'Getting Started');
|
||||
|
||||
// create new page
|
||||
await clickNewPageButton(page);
|
||||
await expectTabTitle(page, 0, 'Untitled');
|
||||
|
||||
// go to all page
|
||||
await page.getByTestId('all-pages').click();
|
||||
await expectTabTitle(page, 0, 'All docs');
|
||||
|
||||
// go to today's journal
|
||||
await page.getByTestId('slider-bar-journals-button').click();
|
||||
await page.getByTestId('confirm-create-journal-button').click();
|
||||
await expect(page.locator('.doc-title-container')).toContainText('Today');
|
||||
const dateString = await page
|
||||
.locator('.doc-title-container > span:first-of-type')
|
||||
.textContent();
|
||||
|
||||
if (dateString) {
|
||||
await expectTabTitle(page, 0, dateString);
|
||||
}
|
||||
});
|
||||
|
||||
test('open new tab via cmd+click page link', async ({ page }) => {
|
||||
await clickNewPageButton(page);
|
||||
await page.waitForTimeout(500);
|
||||
await page.keyboard.press('Enter');
|
||||
await createLinkedPage(page, 'hi from another page');
|
||||
await page
|
||||
.locator('.affine-reference-title:has-text("hi from another page")')
|
||||
.click({
|
||||
modifiers: ['ControlOrMeta'],
|
||||
});
|
||||
await expectTabCount(page, 2);
|
||||
await expectTabTitle(page, 0, 'Untitled');
|
||||
await expectTabTitle(page, 1, 'hi from another page');
|
||||
await expectActiveTab(page, 0);
|
||||
});
|
||||
|
||||
test('drag a page from "All pages" list to tabs header', async ({ page }) => {
|
||||
const title = 'this is a new page to drag';
|
||||
await clickNewPageButton(page, title);
|
||||
await clickSideBarAllPageButton(page);
|
||||
|
||||
await dragTo(
|
||||
page,
|
||||
getPageByTitle(page, title),
|
||||
page.getByTestId('add-tab-view-button')
|
||||
);
|
||||
|
||||
await expectTabCount(page, 2);
|
||||
await expectTabTitle(page, 1, title);
|
||||
await expectActiveTab(page, 1);
|
||||
});
|
||||
|
||||
test('reorder tabs', async ({ page }) => {
|
||||
await clickNewPageButton(page);
|
||||
await page.waitForTimeout(500);
|
||||
await page.keyboard.press('Enter');
|
||||
const titles = ['aaa', 'bbb'];
|
||||
await createLinkedPage(page, titles[0]);
|
||||
await createLinkedPage(page, titles[1]);
|
||||
await page.locator(`.affine-reference-title:has-text("${titles[0]}")`).click({
|
||||
modifiers: ['ControlOrMeta'],
|
||||
});
|
||||
await page.locator(`.affine-reference-title:has-text("${titles[1]}")`).click({
|
||||
modifiers: ['ControlOrMeta'],
|
||||
});
|
||||
|
||||
await expectTabTitle(page, 0, 'Untitled');
|
||||
await expectTabTitle(page, 1, titles[0]);
|
||||
await expectTabTitle(page, 2, titles[1]);
|
||||
|
||||
await dragTo(
|
||||
page,
|
||||
page.getByTestId('workbench-tab').nth(0),
|
||||
page.getByTestId('workbench-tab').nth(1),
|
||||
'right'
|
||||
);
|
||||
|
||||
await expectTabTitle(page, 0, titles[0]);
|
||||
await expectTabTitle(page, 1, 'Untitled');
|
||||
await expectTabTitle(page, 2, titles[1]);
|
||||
});
|
||||
188
tests/affine-desktop/e2e/workspace.spec.ts
Normal file
188
tests/affine-desktop/e2e/workspace.spec.ts
Normal file
@@ -0,0 +1,188 @@
|
||||
import path from 'node:path';
|
||||
|
||||
import type { apis } from '@affine/electron-api';
|
||||
import { test } from '@affine-test/kit/electron';
|
||||
import {
|
||||
getBlockSuiteEditorTitle,
|
||||
getPageByTitle,
|
||||
waitForEditorLoad,
|
||||
} from '@affine-test/kit/utils/page-logic';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
clickSideBarCurrentWorkspaceBanner,
|
||||
} from '@affine-test/kit/utils/sidebar';
|
||||
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
|
||||
import { expect } from '@playwright/test';
|
||||
import fs from 'fs-extra';
|
||||
import type { ElectronApplication } from 'playwright';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__apis: typeof apis;
|
||||
}
|
||||
}
|
||||
|
||||
async function mockNextSaveDialog(
|
||||
electronApp: ElectronApplication,
|
||||
filePath: string
|
||||
) {
|
||||
await electronApp.evaluate(({ dialog }, mockedFilePath) => {
|
||||
const original = dialog.showSaveDialog.bind(dialog);
|
||||
dialog.showSaveDialog = async () => {
|
||||
dialog.showSaveDialog = original;
|
||||
return { canceled: false, filePath: mockedFilePath };
|
||||
};
|
||||
}, filePath);
|
||||
}
|
||||
|
||||
async function mockNextOpenDialog(
|
||||
electronApp: ElectronApplication,
|
||||
filePath: string
|
||||
) {
|
||||
await electronApp.evaluate(({ dialog }, mockedFilePath) => {
|
||||
const original = dialog.showOpenDialog.bind(dialog);
|
||||
dialog.showOpenDialog = async () => {
|
||||
dialog.showOpenDialog = original;
|
||||
return { canceled: false, filePaths: [mockedFilePath] };
|
||||
};
|
||||
}, filePath);
|
||||
}
|
||||
|
||||
test('check workspace has a DB file', async ({ appInfo, workspace }) => {
|
||||
const w = await workspace.current();
|
||||
const dbPath = path.join(
|
||||
appInfo.sessionData,
|
||||
'workspaces',
|
||||
'local',
|
||||
w.meta.id,
|
||||
'storage.db'
|
||||
);
|
||||
// check if db file exists
|
||||
expect(await fs.exists(dbPath)).toBe(true);
|
||||
});
|
||||
|
||||
test('export then add', async ({ electronApp, page, appInfo, workspace }) => {
|
||||
await clickNewPageButton(page);
|
||||
const w = await workspace.current();
|
||||
|
||||
await getBlockSuiteEditorTitle(page).fill('test1');
|
||||
|
||||
await page.getByTestId('slider-bar-workspace-setting-button').click();
|
||||
await expect(page.getByTestId('setting-modal')).toBeVisible();
|
||||
|
||||
const originalId = w.meta.id;
|
||||
|
||||
const newWorkspaceName = 'new-test-name';
|
||||
|
||||
// goto workspace setting
|
||||
await page.getByTestId('workspace-setting:preference').click();
|
||||
const input = page.getByTestId('workspace-name-input');
|
||||
await expect(input).toBeVisible();
|
||||
|
||||
// change workspace name
|
||||
await input.fill(newWorkspaceName);
|
||||
await page.getByTestId('save-workspace-name').click();
|
||||
await page.waitForSelector('text="Update workspace name success"');
|
||||
|
||||
const tmpPath = path.join(appInfo.sessionData, w.meta.id + '-tmp.db');
|
||||
|
||||
// export db file to tmp folder
|
||||
await mockNextSaveDialog(electronApp, tmpPath);
|
||||
|
||||
await page.getByTestId('workspace-setting:storage').click();
|
||||
await page.getByTestId('export-affine-backup').click();
|
||||
await page.waitForSelector('text="Export success"');
|
||||
expect(await fs.exists(tmpPath)).toBe(true);
|
||||
|
||||
await page.getByTestId('modal-close-button').click();
|
||||
|
||||
// add workspace
|
||||
// we are reusing the same db file so that we don't need to maintain one
|
||||
// in the codebase
|
||||
await clickSideBarCurrentWorkspaceBanner(page);
|
||||
|
||||
await mockNextOpenDialog(electronApp, tmpPath);
|
||||
|
||||
// load the db file
|
||||
await page.getByTestId('add-workspace').click();
|
||||
|
||||
// should show "Added Successfully" dialog
|
||||
// await page.waitForSelector('text="Added Successfully"');
|
||||
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const newWorkspace = await workspace.current();
|
||||
return newWorkspace.meta.id !== originalId;
|
||||
})
|
||||
.toBe(true);
|
||||
|
||||
// check its name is correct
|
||||
await expect(page.getByTestId('workspace-name')).toHaveText(newWorkspaceName);
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// find button which has the title "test1"
|
||||
await getPageByTitle(page, 'test1').click();
|
||||
await waitForEditorLoad(page);
|
||||
const title = page.locator('[data-block-is-title] >> text="test1"');
|
||||
await expect(title).toBeVisible();
|
||||
});
|
||||
|
||||
test('delete workspace and then restore it from backup', async ({ page }) => {
|
||||
//#region 1. create a new workspace
|
||||
const newWorkspaceName = 'new-test-name';
|
||||
await createLocalWorkspace({ name: newWorkspaceName }, page);
|
||||
//#endregion
|
||||
|
||||
//#region 2. create a page in the new workspace (will verify later if it is successfully recovered)
|
||||
await clickNewPageButton(page);
|
||||
|
||||
await getBlockSuiteEditorTitle(page).fill('test1');
|
||||
//#endregion
|
||||
|
||||
//#region 3. delete the workspace
|
||||
await page.getByTestId('slider-bar-workspace-setting-button').click();
|
||||
await expect(page.getByTestId('setting-modal')).toBeVisible();
|
||||
|
||||
await page.getByTestId('workspace-setting:preference').click();
|
||||
await page.getByTestId('delete-workspace-button').click();
|
||||
await page.getByTestId('delete-workspace-input').fill(newWorkspaceName);
|
||||
|
||||
await page.getByTestId('delete-workspace-confirm-button').click();
|
||||
|
||||
// we are back to the original workspace
|
||||
await expect(page.getByTestId('workspace-name')).toContainText(
|
||||
'Demo Workspace'
|
||||
);
|
||||
//#endregion
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
//#region 4. restore the workspace from backup
|
||||
await page.getByTestId('slider-bar-workspace-setting-button').click();
|
||||
await expect(page.getByTestId('setting-modal')).toBeVisible();
|
||||
|
||||
await page.getByTestId('backup-panel-trigger').click();
|
||||
await expect(page.getByTestId('backup-workspace-item')).toHaveCount(1);
|
||||
await page.getByTestId('backup-workspace-item').click();
|
||||
await page.getByRole('menuitem', { name: 'Enable local workspace' }).click();
|
||||
const toast = page.locator(
|
||||
'[data-sonner-toast]:has-text("Workspace enabled successfully")'
|
||||
);
|
||||
await expect(toast).toBeVisible();
|
||||
await toast.getByRole('button', { name: 'Open' }).click();
|
||||
//#endregion
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// verify the workspace name & page title
|
||||
await expect(page.getByTestId('workspace-name')).toContainText(
|
||||
newWorkspaceName
|
||||
);
|
||||
// find button which has the title "test1"
|
||||
const test1PageButton = await page.waitForSelector(`text="test1"`);
|
||||
await test1PageButton.click();
|
||||
|
||||
const title = page.locator('[data-block-is-title] >> text="test1"');
|
||||
await expect(title).toBeVisible();
|
||||
});
|
||||
17
tests/affine-desktop/package.json
Normal file
17
tests/affine-desktop/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "@affine-test/affine-desktop",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"e2e": "yarn playwright test --reporter=list"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@affine-test/kit": "workspace:*",
|
||||
"@affine/electron-api": "workspace:*",
|
||||
"@playwright/test": "=1.58.2",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"fs-extra": "^11.2.0",
|
||||
"playwright": "=1.58.2"
|
||||
},
|
||||
"version": "0.27.5"
|
||||
}
|
||||
54
tests/affine-desktop/playwright.config.ts
Normal file
54
tests/affine-desktop/playwright.config.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import assert from 'node:assert';
|
||||
|
||||
import { testResultDir } from '@affine-test/kit/playwright';
|
||||
import type { PlaywrightTestConfig } from '@playwright/test';
|
||||
// import { devices } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// require('dotenv').config();
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
const config: PlaywrightTestConfig = {
|
||||
testDir: './e2e',
|
||||
fullyParallel: true,
|
||||
timeout: process.env.CI ? 50_000 : 30_000,
|
||||
expect: {
|
||||
timeout: process.env.CI ? 15_000 : 5_000,
|
||||
},
|
||||
outputDir: testResultDir,
|
||||
use: {
|
||||
viewport: { width: 1440, height: 800 },
|
||||
trace: 'retain-on-failure',
|
||||
},
|
||||
};
|
||||
|
||||
if (process.env.CI) {
|
||||
config.retries = 5;
|
||||
config.workers = 1;
|
||||
}
|
||||
|
||||
if (process.env.DEV_SERVER_URL) {
|
||||
const devServerUrl = new URL(process.env.DEV_SERVER_URL);
|
||||
assert(
|
||||
devServerUrl.origin === 'http://localhost:8080',
|
||||
'DEV_SERVER_URL must be http://localhost:8080'
|
||||
);
|
||||
config.webServer = [
|
||||
{
|
||||
command: 'yarn run -T affine bundle -p @affine/electron-renderer --dev',
|
||||
timeout: 120 * 1000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
env: {
|
||||
COVERAGE: process.env.COVERAGE || 'false',
|
||||
},
|
||||
url: 'http://localhost:8080',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export default config;
|
||||
14
tests/affine-desktop/tsconfig.json
Normal file
14
tests/affine-desktop/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"extends": "../../tsconfig.web.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"rootDir": "./e2e",
|
||||
"outDir": "./dist",
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["e2e"],
|
||||
"references": [
|
||||
{ "path": "../kit" },
|
||||
{ "path": "../../packages/frontend/electron-api" }
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user