mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix(editor): split at the start of list with children (#10244)
This commit is contained in:
80
tests/affine-local/e2e/blocksuite/list.spec.ts
Normal file
80
tests/affine-local/e2e/blocksuite/list.spec.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import { test } from '@affine-test/kit/playwright';
|
||||
import {
|
||||
pressArrowUp,
|
||||
pressEnter,
|
||||
pressTab,
|
||||
} from '@affine-test/kit/utils/keyboard';
|
||||
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
type,
|
||||
waitForEditorLoad,
|
||||
} from '@affine-test/kit/utils/page-logic';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await clickNewPageButton(page, 'List Test');
|
||||
await waitForEditorLoad(page);
|
||||
});
|
||||
|
||||
test.describe('split list', () => {
|
||||
test('split at the start of the list', async ({ page }) => {
|
||||
await pressEnter(page);
|
||||
await type(page, '1. aaa\nbbb\nccc\nddd');
|
||||
await pressArrowUp(page, 2);
|
||||
await pressTab(page);
|
||||
await pressArrowUp(page, 2);
|
||||
|
||||
const listLocator = page.locator('affine-list');
|
||||
|
||||
/**
|
||||
* 1. |aaa
|
||||
* a. bbb
|
||||
* 2. ccc
|
||||
* 3. ddd
|
||||
*/
|
||||
await expect(listLocator.nth(0).locator('rich-text')).toHaveText([
|
||||
'aaa',
|
||||
'bbb',
|
||||
]);
|
||||
await expect(
|
||||
listLocator.nth(0).locator('.affine-list-block__numbered')
|
||||
).toHaveText(['1.', 'a.']);
|
||||
await expect(listLocator.nth(2).locator('rich-text')).toHaveText('ccc');
|
||||
await expect(
|
||||
listLocator.nth(2).locator('.affine-list-block__numbered')
|
||||
).toHaveText('2.');
|
||||
await expect(listLocator.nth(3).locator('rich-text')).toHaveText('ddd');
|
||||
expect(
|
||||
listLocator.nth(3).locator('.affine-list-block__numbered')
|
||||
).toHaveText('3.');
|
||||
|
||||
await pressEnter(page);
|
||||
/**
|
||||
* 1.
|
||||
* 2. aaa
|
||||
* a. bbb
|
||||
* 3. ccc
|
||||
* 4. ddd
|
||||
*/
|
||||
await expect(
|
||||
listLocator.nth(0).locator('.affine-list-block__numbered')
|
||||
).toHaveText('1.');
|
||||
await expect(listLocator.nth(1).locator('rich-text')).toHaveText([
|
||||
'aaa',
|
||||
'bbb',
|
||||
]);
|
||||
await expect(
|
||||
listLocator.nth(1).locator('.affine-list-block__numbered')
|
||||
).toHaveText(['2.', 'a.']);
|
||||
await expect(listLocator.nth(3).locator('rich-text')).toHaveText('ccc');
|
||||
await expect(
|
||||
listLocator.nth(3).locator('.affine-list-block__numbered')
|
||||
).toHaveText('3.');
|
||||
await expect(listLocator.nth(4).locator('rich-text')).toHaveText('ddd');
|
||||
await expect(
|
||||
listLocator.nth(4).locator('.affine-list-block__numbered')
|
||||
).toHaveText('4.');
|
||||
});
|
||||
});
|
||||
@@ -32,6 +32,12 @@ export async function pressEnter(page: Page, count = 1) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function pressArrowUp(page: Page, count = 1) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
await page.keyboard.press('ArrowUp', { delay: 50 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function pressTab(page: Page) {
|
||||
await page.keyboard.press('Tab', { delay: 50 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user