chore(editor): fix imports in legacy tests (#10300)

This commit is contained in:
Saul-Mirone
2025-02-20 03:30:05 +00:00
parent e0b2b2b33c
commit c3fc0a0d88
119 changed files with 96 additions and 90 deletions

View File

@@ -3,9 +3,9 @@ import { fileURLToPath } from 'node:url';
import { sleep } from '@blocksuite/global/utils';
import { expect, type Page } from '@playwright/test';
import { switchEditorMode } from 'utils/actions/edgeless.js';
import { dragBlockToPoint, popImageMoreMenu } from './utils/actions/drag.js';
import { switchEditorMode } from './utils/actions/edgeless.js';
import {
pressArrowDown,
pressArrowUp,
@@ -43,7 +43,10 @@ import { test } from './utils/playwright.js';
const FILE_NAME = 'test-card-1.png';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const FILE_PATH = path.resolve(__dirname, `../playground/public/${FILE_NAME}`);
const FILE_PATH = path.resolve(
__dirname,
`../../playground/public/${FILE_NAME}`
);
function getAttachment(page: Page) {
const attachment = page.locator('affine-attachment');

View File

@@ -3,8 +3,6 @@ import './utils/declare-test-window.js';
import type { BlockSnapshot } from '@blocksuite/store';
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
import { ignoreSnapshotId } from 'utils/ignore.js';
import { getEmbedCardToolbar } from 'utils/query.js';
import {
activeNoteInEdgeless,
@@ -42,7 +40,9 @@ import {
assertParentBlockFlavour,
assertRichTextInlineRange,
} from './utils/asserts.js';
import { ignoreSnapshotId } from './utils/ignore.js';
import { scoped, test } from './utils/playwright.js';
import { getEmbedCardToolbar } from './utils/query.js';
const LOCAL_HOST_URL = 'http://localhost';

View File

@@ -1,8 +1,7 @@
import { expect } from '@playwright/test';
import { dragBetweenIndices } from 'utils/actions/drag.js';
import { getFormatBar } from 'utils/query.js';
import { updateBlockType } from '../utils/actions/block.js';
import { dragBetweenIndices } from '../utils/actions/drag.js';
import {
createCodeBlock,
pressArrowLeft,
@@ -32,6 +31,7 @@ import {
assertTitle,
} from '../utils/asserts.js';
import { test } from '../utils/playwright.js';
import { getFormatBar } from '../utils/query.js';
import { getCodeBlock } from './utils.js';
test('use debug menu can create code block', async ({ page }) => {

View File

@@ -1,16 +1,16 @@
import { expect, type Locator, type Page } from '@playwright/test';
import { dragBetweenCoords } from 'utils/actions/drag.js';
import { dragBetweenCoords } from '../utils/actions/drag.js';
import {
addBasicShapeElement,
Shape,
switchEditorMode,
triggerComponentToolbarAction,
} from 'utils/actions/edgeless.js';
} from '../utils/actions/edgeless.js';
import {
enterPlaygroundRoom,
initEmptyEdgelessState,
} from 'utils/actions/misc.js';
} from '../utils/actions/misc.js';
import { parseStringToRgba } from '../utils/bs-alternative.js';
import { test } from '../utils/playwright.js';

View File

@@ -1,5 +1,6 @@
import type { Page } from '@playwright/test';
import { clickView, moveView } from 'utils/actions/click.js';
import { clickView, moveView } from '../../utils/actions/click.js';
import {
autoFit,
createFrame as _createFrame,
@@ -14,15 +15,14 @@ import {
shiftClickView,
triggerComponentToolbarAction,
zoomResetByKeyboard,
} from 'utils/actions/edgeless.js';
} from '../../utils/actions/edgeless.js';
import {
copyByKeyboard,
pasteByKeyboard,
pressBackspace,
pressEscape,
} from 'utils/actions/keyboard.js';
import { assertContainerOfElements } from 'utils/asserts.js';
} from '../../utils/actions/keyboard.js';
import { assertContainerOfElements } from '../../utils/asserts.js';
import { test } from '../../utils/playwright.js';
const createFrame = async (

View File

@@ -1,5 +1,6 @@
import type { Page } from '@playwright/test';
import { clickView } from 'utils/actions/click.js';
import { clickView } from '../../utils/actions/click.js';
import {
createFrame,
dragBetweenViewCoords as _dragBetweenViewCoords,
@@ -9,11 +10,10 @@ import {
toViewCoord,
triggerComponentToolbarAction,
zoomResetByKeyboard,
} from 'utils/actions/edgeless.js';
import { pressEscape } from 'utils/actions/keyboard.js';
import { waitNextFrame } from 'utils/actions/misc.js';
import { assertContainerOfElements } from 'utils/asserts.js';
} from '../../utils/actions/edgeless.js';
import { pressEscape } from '../../utils/actions/keyboard.js';
import { waitNextFrame } from '../../utils/actions/misc.js';
import { assertContainerOfElements } from '../../utils/asserts.js';
import { test } from '../../utils/playwright.js';
const dragBetweenViewCoords = async (

View File

@@ -1,4 +1,5 @@
import { expect, type Page } from '@playwright/test';
import {
addNote,
autoFit,
@@ -8,15 +9,14 @@ import {
getFrameTitle,
zoomOutByKeyboard,
zoomResetByKeyboard,
} from 'utils/actions/edgeless.js';
} from '../../utils/actions/edgeless.js';
import {
pressBackspace,
pressEnter,
pressEscape,
type,
} from 'utils/actions/keyboard.js';
import { waitNextFrame } from 'utils/actions/misc.js';
} from '../../utils/actions/keyboard.js';
import { waitNextFrame } from '../../utils/actions/misc.js';
import { test } from '../../utils/playwright.js';
const createFrame = async (

View File

@@ -1,4 +1,5 @@
import { expect } from '@playwright/test';
import {
createFrame,
createNote,
@@ -8,9 +9,11 @@ import {
getEdgelessSelectedRectModel,
Shape,
zoomResetByKeyboard,
} from 'utils/actions/edgeless.js';
import { pressEscape, selectAllByKeyboard } from 'utils/actions/keyboard.js';
} from '../../utils/actions/edgeless.js';
import {
pressEscape,
selectAllByKeyboard,
} from '../../utils/actions/keyboard.js';
import { test } from '../../utils/playwright.js';
test.beforeEach(async ({ page }) => {

View File

@@ -1,5 +1,6 @@
import { expect, type Page } from '@playwright/test';
import { click, clickView, dblclickView } from 'utils/actions/click.js';
import { click, clickView, dblclickView } from '../../utils/actions/click.js';
import {
addNote,
autoFit,
@@ -13,21 +14,20 @@ import {
Shape,
toViewCoord,
zoomResetByKeyboard,
} from 'utils/actions/edgeless.js';
} from '../../utils/actions/edgeless.js';
import {
pressBackspace,
pressEnter,
pressEscape,
selectAllByKeyboard,
type,
} from 'utils/actions/keyboard.js';
import { waitNextFrame } from 'utils/actions/misc.js';
} from '../../utils/actions/keyboard.js';
import { waitNextFrame } from '../../utils/actions/misc.js';
import {
assertEdgelessCanvasText,
assertRichTexts,
assertSelectedBound,
} from 'utils/asserts.js';
} from '../../utils/asserts.js';
import { test } from '../../utils/playwright.js';
const createFrame = async (

View File

@@ -254,7 +254,7 @@ test.skip('polygonal lasso should complete selection when clicking the last poin
const curController = edgeless.gfx.tool.currentTool$.peek();
if (curController?.toolName !== 'lasso')
throw new Error('expected lasso tool controller');
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (curController as any)['_isSelecting'];
});

View File

@@ -1,5 +1,6 @@
import { expect, type Page } from '@playwright/test';
import { clickView, dblclickView, moveView } from 'utils/actions/click.js';
import { clickView, dblclickView, moveView } from '../utils/actions/click.js';
import {
createBrushElement,
createConnectorElement,
@@ -16,7 +17,7 @@ import {
getSelectedIds,
getTypeById,
setEdgelessTool,
} from 'utils/actions/edgeless.js';
} from '../utils/actions/edgeless.js';
import {
copyByKeyboard,
pasteByKeyboard,
@@ -29,15 +30,14 @@ import {
SHORT_KEY,
type,
undoByKeyboard,
} from 'utils/actions/keyboard.js';
import { waitNextFrame } from 'utils/actions/misc.js';
} from '../utils/actions/keyboard.js';
import { waitNextFrame } from '../utils/actions/misc.js';
import {
assertCanvasElementsCount,
assertEdgelessElementBound,
assertEdgelessSelectedModelRect,
assertRichTexts,
} from 'utils/asserts.js';
} from '../utils/asserts.js';
import { test } from '../utils/playwright.js';
test.describe('lock', () => {

View File

@@ -1,6 +1,7 @@
import { expect } from '@playwright/test';
import { clickView } from 'utils/actions/click.js';
import { dragBetweenCoords } from 'utils/actions/drag.js';
import { clickView } from '../utils/actions/click.js';
import { dragBetweenCoords } from '../utils/actions/drag.js';
import {
addBasicRectShapeElement,
autoFit,
@@ -10,7 +11,7 @@ import {
selectElementInEdgeless,
waitFontsLoaded,
zoomResetByKeyboard,
} from 'utils/actions/edgeless.js';
} from '../utils/actions/edgeless.js';
import {
pressBackspace,
pressEnter,
@@ -18,18 +19,17 @@ import {
selectAllByKeyboard,
type,
undoByKeyboard,
} from 'utils/actions/keyboard.js';
import { waitNextFrame } from 'utils/actions/misc.js';
} from '../utils/actions/keyboard.js';
import { waitNextFrame } from '../utils/actions/misc.js';
import {
assertEdgelessSelectedRect,
assertSelectedBound,
} from 'utils/asserts.js';
} from '../utils/asserts.js';
import {
addMindmapNodes,
createMindMap,
getMindMapNode,
} from 'utils/mindmap.js';
} from '../utils/mindmap.js';
import { test } from '../utils/playwright.js';
test('elements should be selectable after open mindmap menu', async ({
@@ -224,17 +224,17 @@ test('drag root node should layout in real time', async ({ page }) => {
const { rect: thirdRect } = await getMindMapNode(page, mindmapId, [0, 2]);
const assertMindMapNodesPosition = async (deltaX: number, deltaY: number) => {
await expect((await getMindMapNode(page, mindmapId, [0, 0])).rect).toEqual({
expect((await getMindMapNode(page, mindmapId, [0, 0])).rect).toEqual({
...firstRect,
x: firstRect.x + deltaX,
y: firstRect.y + deltaY,
});
await expect((await getMindMapNode(page, mindmapId, [0, 1])).rect).toEqual({
expect((await getMindMapNode(page, mindmapId, [0, 1])).rect).toEqual({
...secondRect,
x: secondRect.x + deltaX,
y: secondRect.y + deltaY,
});
await expect((await getMindMapNode(page, mindmapId, [0, 2])).rect).toEqual({
expect((await getMindMapNode(page, mindmapId, [0, 2])).rect).toEqual({
...thirdRect,
x: thirdRect.x + deltaX,
y: thirdRect.y + deltaY,
@@ -359,13 +359,13 @@ test('allow to type content directly when node has been selected', async ({
await type(page, 'child node 2');
await pressEnter(page);
await expect((await getMindMapNode(page, mindmapId, [0, 1])).text).toBe(
expect((await getMindMapNode(page, mindmapId, [0, 1])).text).toBe(
'parent node'
);
await expect((await getMindMapNode(page, mindmapId, [0, 1, 0])).text).toBe(
expect((await getMindMapNode(page, mindmapId, [0, 1, 0])).text).toBe(
'child node 1'
);
await expect((await getMindMapNode(page, mindmapId, [0, 1, 1])).text).toBe(
expect((await getMindMapNode(page, mindmapId, [0, 1, 1])).text).toBe(
'child node 2'
);
});

View File

@@ -1,4 +1,5 @@
import { expect, type Page } from '@playwright/test';
import {
addNote,
locatorScalePanelButton,
@@ -6,19 +7,19 @@ import {
switchEditorMode,
triggerComponentToolbarAction,
zoomResetByKeyboard,
} from 'utils/actions/edgeless.js';
} from '../../utils/actions/edgeless.js';
import {
copyByKeyboard,
pasteByKeyboard,
selectAllByKeyboard,
} from 'utils/actions/keyboard.js';
} from '../../utils/actions/keyboard.js';
import {
enterPlaygroundRoom,
initEmptyEdgelessState,
waitNextFrame,
} from 'utils/actions/misc.js';
import { assertRectExist } from 'utils/asserts.js';
import { test } from 'utils/playwright.js';
} from '../../utils/actions/misc.js';
import { assertRectExist } from '../../utils/asserts.js';
import { test } from '../../utils/playwright.js';
async function setupAndAddNote(page: Page) {
await enterPlaygroundRoom(page);

View File

@@ -1,4 +1,5 @@
import { expect, type Page } from '@playwright/test';
import {
click,
copyByKeyboard,
@@ -17,8 +18,7 @@ import {
setEdgelessTool,
switchEditorMode,
type,
} from 'utils/actions/index.js';
} from '../utils/actions/index.js';
import { test } from '../utils/playwright.js';
test.describe('pasting blocks', () => {

View File

@@ -1,4 +1,5 @@
import { expect } from '@playwright/test';
import {
assertEdgelessTool,
createFrame,
@@ -11,15 +12,14 @@ import {
setEdgelessTool,
Shape,
toggleFramePanel,
} from 'utils/actions/edgeless.js';
} from '../utils/actions/edgeless.js';
import {
copyByKeyboard,
pasteByKeyboard,
pressEscape,
selectAllBlocksByKeyboard,
} from 'utils/actions/keyboard.js';
import { waitNextFrame } from 'utils/actions/misc.js';
} from '../utils/actions/keyboard.js';
import { waitNextFrame } from '../utils/actions/misc.js';
import { test } from '../utils/playwright.js';
test.describe('presentation', () => {

View File

@@ -1,5 +1,4 @@
import { expect, type Page } from '@playwright/test';
import { getLinkedDocPopover } from 'utils/actions/linked-doc.js';
import {
assertEdgelessTool,
@@ -16,6 +15,7 @@ import {
waitNextFrame,
zoomResetByKeyboard,
} from '../utils/actions/index.js';
import { getLinkedDocPopover } from '../utils/actions/linked-doc.js';
import { assertEdgelessCanvasText } from '../utils/asserts.js';
import { test } from '../utils/playwright.js';

View File

@@ -1,16 +1,16 @@
import type { DatabaseBlockModel } from '@blocksuite/affine-model';
import { assertExists } from '@blocksuite/global/utils';
import { expect, type Page } from '@playwright/test';
import { switchEditorMode } from 'utils/actions/edgeless.js';
import { getLinkedDocPopover } from 'utils/actions/linked-doc.js';
import { switchEditorMode } from './utils/actions/edgeless.js';
import { getLinkedDocPopover } from './utils/actions/linked-doc.js';
import {
enterPlaygroundRoom,
focusRichText,
initEmptyEdgelessState,
initEmptyParagraphState,
waitNextFrame,
} from 'utils/actions/misc.js';
} from './utils/actions/misc.js';
import { test } from './utils/playwright.js';
test.describe('Embed synced doc', () => {

View File

Before

Width:  |  Height:  |  Size: 96 B

After

Width:  |  Height:  |  Size: 96 B

View File

@@ -1,11 +1,6 @@
import { expect, type Locator, type Page } from '@playwright/test';
import { dragBetweenCoords } from 'utils/actions/drag.js';
import {
assertEdgelessNonSelectedRect,
assertEdgelessSelectedRect,
assertZoomLevel,
} from 'utils/asserts.js';
import { dragBetweenCoords } from '../utils/actions/drag.js';
import {
addBasicShapeElement,
addNote,
@@ -21,6 +16,11 @@ import {
toggleFramePanel,
} from '../utils/actions/edgeless.js';
import { waitNextFrame } from '../utils/actions/index.js';
import {
assertEdgelessNonSelectedRect,
assertEdgelessSelectedRect,
assertZoomLevel,
} from '../utils/asserts.js';
import { test } from '../utils/playwright.js';
async function dragFrameCard(

View File

@@ -1,9 +1,5 @@
import { ZERO_WIDTH_SPACE } from '@blocksuite/inline';
import { expect } from '@playwright/test';
import {
assertRichTextInlineDeltas,
assertRichTextInlineRange,
} from 'utils/asserts.js';
import {
cutByKeyboard,
@@ -25,6 +21,10 @@ import {
focusRichText,
initEmptyParagraphState,
} from '../utils/actions/misc.js';
import {
assertRichTextInlineDeltas,
assertRichTextInlineRange,
} from '../utils/asserts.js';
import { test } from '../utils/playwright.js';
test('add inline latex at the start of line', async ({ page }) => {

View File

@@ -1,6 +1,4 @@
import { expect, type Page } from '@playwright/test';
import { switchEditorMode } from 'utils/actions/edgeless.js';
import { getLinkedDocPopover } from 'utils/actions/linked-doc.js';
import {
addNewPage,
@@ -8,6 +6,7 @@ import {
switchToPage,
} from './utils/actions/click.js';
import { dragBetweenIndices, dragBlockToPoint } from './utils/actions/drag.js';
import { switchEditorMode } from './utils/actions/edgeless.js';
import {
copyByKeyboard,
cutByKeyboard,
@@ -20,6 +19,7 @@ import {
SHORT_KEY,
type,
} from './utils/actions/keyboard.js';
import { getLinkedDocPopover } from './utils/actions/linked-doc.js';
import {
captureHistory,
enterPlaygroundRoom,

View File

@@ -1,5 +1,4 @@
import { expect, type Locator } from '@playwright/test';
import { getFormatBar } from 'utils/query.js';
import {
dragBetweenIndices,
@@ -39,6 +38,7 @@ import {
assertTextContent,
} from './utils/asserts.js';
import { test } from './utils/playwright.js';
import { getFormatBar } from './utils/query.js';
async function isToggleIconVisible(toggleIcon: Locator) {
const connected = await toggleIcon.isVisible();

Some files were not shown because too many files have changed in this diff Show More