mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
feat(core): drop doc onto split view (#9487)
fix AF-2068, AF-2069, AF-1175, AF-2061, AF-2079, AF-2034, AF-2080, AF-1960, AF-2081 1. replace `dnd-kit` with `@atlaskit/pragmatic-drag-and-drop` 2. allow creating split views by drag & drop the following a. WorkbenchLinks (route links), like journals, trash, all docs b. doc refs c. tags/collection 3. style adjustments to split view 4. remove split view's feature flag and make it GA for electron https://github.com/user-attachments/assets/6a3e4a25-faa2-4215-8eb0-983f44db6e8c
This commit is contained in:
52
tests/kit/src/utils/app-tabs.ts
Normal file
52
tests/kit/src/utils/app-tabs.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
export async function expectActiveTab(
|
||||
page: Page,
|
||||
index: number,
|
||||
activeViewIndex = 0
|
||||
) {
|
||||
await expect(
|
||||
page
|
||||
.getByTestId('workbench-tab')
|
||||
.nth(index)
|
||||
.getByTestId('split-view-label')
|
||||
.nth(activeViewIndex)
|
||||
).toHaveAttribute('data-active', 'true');
|
||||
}
|
||||
|
||||
export async function expectTabTitle(
|
||||
page: Page,
|
||||
index: number,
|
||||
title: string | string[]
|
||||
) {
|
||||
if (typeof title === 'string') {
|
||||
await expect(page.getByTestId('workbench-tab').nth(index)).toContainText(
|
||||
title
|
||||
);
|
||||
} else {
|
||||
for (let i = 0; i < title.length; i++) {
|
||||
await expect(
|
||||
page
|
||||
.getByTestId('workbench-tab')
|
||||
.nth(index)
|
||||
.getByTestId('split-view-label')
|
||||
.nth(i)
|
||||
).toContainText(title[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function expectTabCount(page: Page, count: number) {
|
||||
await expect(page.getByTestId('workbench-tab')).toHaveCount(count);
|
||||
}
|
||||
|
||||
export async function closeTab(page: Page, index: number) {
|
||||
await page.getByTestId('workbench-tab').nth(index).hover();
|
||||
|
||||
await page
|
||||
.getByTestId('workbench-tab')
|
||||
.nth(index)
|
||||
.getByTestId('close-tab-button')
|
||||
.click();
|
||||
}
|
||||
@@ -139,7 +139,8 @@ export const dragTo = async (
|
||||
page: Page,
|
||||
locator: Locator,
|
||||
target: Locator,
|
||||
location: DragLocation = 'center'
|
||||
location: DragLocation = 'center',
|
||||
willMoveOnDrag = false
|
||||
) => {
|
||||
await locator.hover();
|
||||
const locatorElement = await locator.boundingBox();
|
||||
@@ -164,18 +165,20 @@ export const dragTo = async (
|
||||
|
||||
await target.hover();
|
||||
|
||||
const targetElement = await target.boundingBox();
|
||||
if (!targetElement) {
|
||||
throw new Error('target element not found');
|
||||
}
|
||||
const targetPosition = toPosition(targetElement, location);
|
||||
await page.mouse.move(
|
||||
targetElement.x + targetPosition.x,
|
||||
targetElement.y + targetPosition.y,
|
||||
{
|
||||
steps: 10,
|
||||
if (!willMoveOnDrag) {
|
||||
const targetElement = await target.boundingBox();
|
||||
if (!targetElement) {
|
||||
throw new Error('target element not found');
|
||||
}
|
||||
);
|
||||
const targetPosition = toPosition(targetElement, location);
|
||||
await page.mouse.move(
|
||||
targetElement.x + targetPosition.x,
|
||||
targetElement.y + targetPosition.y,
|
||||
{
|
||||
steps: 10,
|
||||
}
|
||||
);
|
||||
}
|
||||
await page.waitForTimeout(100);
|
||||
await page.mouse.up();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user