mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 22:38:56 +08:00
chore: migrate blocksuite test (#9222)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import {
|
||||
switchMultipleEditorsMode,
|
||||
toggleMultipleEditors,
|
||||
} from '../utils/actions/edgeless.js';
|
||||
import {
|
||||
enterPlaygroundRoom,
|
||||
initEmptyEdgelessState,
|
||||
initThreeParagraphs,
|
||||
waitNextFrame,
|
||||
} from '../utils/actions/misc.js';
|
||||
import { test } from '../utils/playwright.js';
|
||||
|
||||
test('the shift pressing status should effect all editors', async ({
|
||||
page,
|
||||
}) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
await initEmptyEdgelessState(page);
|
||||
await initThreeParagraphs(page);
|
||||
await toggleMultipleEditors(page);
|
||||
await switchMultipleEditorsMode(page);
|
||||
|
||||
await waitNextFrame(page, 5000);
|
||||
|
||||
const getShiftPressedStatus = async () => {
|
||||
return page.evaluate(() => {
|
||||
const edgelessBlocks = document.querySelectorAll('affine-edgeless-root');
|
||||
|
||||
return Array.from(edgelessBlocks).map(edgelessRoot => {
|
||||
return edgelessRoot.gfx.keyboard.shiftKey$.peek();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
await page.keyboard.down('Shift');
|
||||
const pressed = await getShiftPressedStatus();
|
||||
expect(pressed).toEqual([true, true]);
|
||||
|
||||
await page.keyboard.up('Shift');
|
||||
const released = await getShiftPressedStatus();
|
||||
expect(released).toEqual([false, false]);
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
import { dragBetweenCoords } from '../utils/actions/drag.js';
|
||||
import { toggleMultipleEditors } from '../utils/actions/edgeless.js';
|
||||
import {
|
||||
enterPlaygroundRoom,
|
||||
initEmptyParagraphState,
|
||||
initThreeParagraphs,
|
||||
} from '../utils/actions/misc.js';
|
||||
import { getRichTextBoundingBox } from '../utils/actions/selection.js';
|
||||
import { test } from '../utils/playwright.js';
|
||||
|
||||
test('should only show one format bar when multiple editors are toggled', async ({
|
||||
page,
|
||||
}) => {
|
||||
await enterPlaygroundRoom(page);
|
||||
await initEmptyParagraphState(page);
|
||||
await initThreeParagraphs(page);
|
||||
await toggleMultipleEditors(page);
|
||||
|
||||
// Select some text
|
||||
const box123 = await getRichTextBoundingBox(page, '2');
|
||||
const above123 = { x: box123.left + 10, y: box123.top + 2 };
|
||||
|
||||
const box789 = await getRichTextBoundingBox(page, '4');
|
||||
const bottomRight789 = { x: box789.right - 10, y: box789.bottom - 2 };
|
||||
|
||||
await dragBetweenCoords(page, above123, bottomRight789, { steps: 10 });
|
||||
|
||||
// should only show one format bar
|
||||
const formatBar = page.locator('.affine-format-bar-widget');
|
||||
await expect(formatBar).toHaveCount(1);
|
||||
});
|
||||
Reference in New Issue
Block a user