mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-16 05:47:09 +08:00
feat(electron): multi tabs support (#7440)
use https://www.electronjs.org/docs/latest/api/web-contents-view to serve different tab views added tabs view manager in electron to handle multi-view actions and events. fix AF-1111 fix AF-999 fix PD-1459 fix AF-964 PD-1458
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import { test } from '@affine-test/kit/electron';
|
||||
import { withCtrlOrMeta } from '@affine-test/kit/utils/keyboard';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
createLinkedPage,
|
||||
getBlockSuiteEditorTitle,
|
||||
waitForEmptyEditor,
|
||||
} from '@affine-test/kit/utils/page-logic';
|
||||
import {
|
||||
clickSideBarCurrentWorkspaceBanner,
|
||||
@@ -14,73 +12,53 @@ import type { Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
const historyShortcut = async (page: Page, command: 'goBack' | 'goForward') => {
|
||||
await withCtrlOrMeta(page, () =>
|
||||
page.keyboard.press(command === 'goBack' ? '[' : ']', { delay: 50 })
|
||||
await page.keyboard.press(
|
||||
command === 'goBack' ? 'ControlOrMeta+[' : 'ControlOrMeta+]'
|
||||
);
|
||||
};
|
||||
|
||||
test('new page', async ({ page, workspace }) => {
|
||||
await page.getByTestId('sidebar-new-page-button').click();
|
||||
await page.waitForSelector('v-line');
|
||||
await clickNewPageButton(page);
|
||||
const flavour = (await workspace.current()).meta.flavour;
|
||||
expect(flavour).toBe('local');
|
||||
});
|
||||
|
||||
test('app sidebar router forward/back', async ({ page }) => {
|
||||
{
|
||||
// create pages
|
||||
await page.waitForTimeout(500);
|
||||
await clickNewPageButton(page);
|
||||
await page.waitForSelector('v-line');
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.focus();
|
||||
await title.pressSequentially('test1', {
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForTimeout(500);
|
||||
await page.getByTestId('sidebar-new-page-button').click({
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForSelector('v-line');
|
||||
// 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 page.getByTestId('sidebar-new-page-button').click({
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForSelector('v-line');
|
||||
await title.focus();
|
||||
await title.pressSequentially('test3', {
|
||||
delay: 100,
|
||||
});
|
||||
}
|
||||
{
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test3');
|
||||
}
|
||||
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 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 expect(getBlockSuiteEditorTitle(page)).toHaveText('test3');
|
||||
await historyShortcut(page, 'goBack');
|
||||
await historyShortcut(page, 'goBack');
|
||||
{
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test1');
|
||||
}
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test1');
|
||||
await historyShortcut(page, 'goForward');
|
||||
await historyShortcut(page, 'goForward');
|
||||
{
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test3');
|
||||
}
|
||||
await expect(getBlockSuiteEditorTitle(page)).toHaveText('test3');
|
||||
});
|
||||
|
||||
test('clientBorder value should disable by default on window', async ({
|
||||
@@ -133,6 +111,8 @@ test('windows only check', async ({ page }) => {
|
||||
});
|
||||
|
||||
test('delete workspace', async ({ page }) => {
|
||||
await clickNewPageButton(page);
|
||||
|
||||
await clickSideBarCurrentWorkspaceBanner(page);
|
||||
await page.getByTestId('new-workspace').click();
|
||||
await page.getByTestId('create-workspace-input').fill('Delete Me');
|
||||
@@ -159,8 +139,7 @@ test('delete workspace', async ({ page }) => {
|
||||
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 page.waitForTimeout(1000);
|
||||
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
||||
await expect(page.getByTestId('workspace-name')).toContainText(
|
||||
'Demo Workspace'
|
||||
);
|
||||
});
|
||||
@@ -192,17 +171,14 @@ async function enableSplitView(page: Page) {
|
||||
|
||||
test('open split view', async ({ page }) => {
|
||||
await enableSplitView(page);
|
||||
await page.getByTestId('sidebar-new-page-button').click({
|
||||
delay: 100,
|
||||
});
|
||||
await waitForEmptyEditor(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: [process.platform === 'darwin' ? 'Meta' : 'Control'],
|
||||
modifiers: ['ControlOrMeta', 'Alt'],
|
||||
});
|
||||
await expect(page.locator('.doc-title-container')).toHaveCount(2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user