Files
upstream-affine/tests/blocksuite/e2e/hotkey/multiline.spec.ts
upstream-mirror 702cc698a7
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
snapshot of https://github.com/toeverything/AFFiNE.git (canary, 2026-09-16; blobs > 131072B omitted)
2026-09-16 04:01:20 +05:00

180 lines
4.8 KiB
TypeScript

import { expect } from '@playwright/test';
import {
dragBetweenIndices,
enterPlaygroundRoom,
focusRichText,
getPageSnapshot,
initEmptyParagraphState,
initThreeParagraphs,
inlineCode,
pressArrowLeft,
pressArrowUp,
pressEnter,
pressForwardDelete,
pressShiftEnter,
readClipboardText,
redoByClick,
resetHistory,
setInlineRangeInSelectedRichText,
SHORT_KEY,
type,
undoByClick,
undoByKeyboard,
waitNextFrame,
} from '../utils/actions/index.js';
import {
assertBlockSelections,
assertRichTextInlineRange,
assertRichTexts,
} from '../utils/asserts.js';
import { test } from '../utils/playwright.js';
test('should multiple line format hotkey work', async ({ page }, testInfo) => {
await enterPlaygroundRoom(page);
await initEmptyParagraphState(page);
await initThreeParagraphs(page);
// 0 1 2
// 1|23 456 78|9
await dragBetweenIndices(page, [0, 1], [2, 2]);
// bold
await page.keyboard.press(`${SHORT_KEY}+b`);
// italic
await page.keyboard.press(`${SHORT_KEY}+i`);
// underline
await page.keyboard.press(`${SHORT_KEY}+u`);
// strikethrough
await page.keyboard.press(`${SHORT_KEY}+Shift+S`);
await waitNextFrame(page);
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
`${testInfo.title}_init.json`
);
// bold
await page.keyboard.press(`${SHORT_KEY}+b`, { delay: 50 });
// italic
await page.keyboard.press(`${SHORT_KEY}+i`, { delay: 50 });
// underline
await page.keyboard.press(`${SHORT_KEY}+u`, { delay: 50 });
// strikethrough
await page.keyboard.press(`${SHORT_KEY}+Shift+s`, { delay: 50 });
await waitNextFrame(page);
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
`${testInfo.title}_finial.json`
);
});
test('multi line rich-text inline code hotkey', async ({ page }, testInfo) => {
await enterPlaygroundRoom(page);
await initEmptyParagraphState(page);
await initThreeParagraphs(page);
await assertRichTexts(page, ['123', '456', '789']);
// 0 1 2
// 1|23 456 78|9
await dragBetweenIndices(page, [0, 1], [2, 2]);
await inlineCode(page);
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
`${testInfo.title}_init.json`
);
await undoByClick(page);
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
`${testInfo.title}_undo.json`
);
await redoByClick(page);
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
`${testInfo.title}_redo.json`
);
});
test('should cut work multiple line', async ({ page }, testInfo) => {
await enterPlaygroundRoom(page);
await initEmptyParagraphState(page);
await initThreeParagraphs(page);
await resetHistory(page);
// 0 1 2
// 1|23 456 78|9
await dragBetweenIndices(page, [0, 1], [2, 2]);
// cut
await page.keyboard.press(`${SHORT_KEY}+x`);
await waitNextFrame(page, 200);
await assertRichTexts(page, ['19']);
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
`${testInfo.title}_init.json`
);
await undoByKeyboard(page);
const text = await readClipboardText(page);
expect(text).toBe(`23 456 78`);
await assertRichTexts(page, ['123', '456', '789']);
expect(await getPageSnapshot(page, true)).toMatchSnapshot(
`${testInfo.title}_undo.json`
);
});
test('arrow up and down behavior on multiline text blocks when previous is non-text', async ({
page,
}) => {
await enterPlaygroundRoom(page);
await initEmptyParagraphState(page);
await focusRichText(page);
await pressEnter(page);
await pressArrowUp(page);
await type(page, '--- ');
await pressEnter(page);
await focusRichText(page);
await type(page, '124');
await pressShiftEnter(page);
await type(page, '1234');
await pressArrowUp(page);
await waitNextFrame(page, 100);
await assertRichTextInlineRange(page, 0, 3);
await pressArrowUp(page);
await assertBlockSelections(page, ['4']);
});
test('should forwardDelete works when delete multi characters', async ({
page,
}) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/toeverything/blocksuite/issues/3122',
});
await enterPlaygroundRoom(page);
await initEmptyParagraphState(page);
await focusRichText(page, 0);
await type(page, 'hello');
await pressArrowLeft(page, 5);
await setInlineRangeInSelectedRichText(page, 1, 3);
await pressForwardDelete(page);
await assertRichTexts(page, ['ho']);
});
test('should drag multiple block and input text works', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/toeverything/blocksuite/issues/2982',
});
await enterPlaygroundRoom(page);
await initEmptyParagraphState(page);
await initThreeParagraphs(page);
await dragBetweenIndices(page, [0, 1], [2, 1]);
await type(page, 'ab');
await assertRichTexts(page, ['1ab89']);
await undoByKeyboard(page);
await assertRichTexts(page, ['123', '456', '789']);
});