snapshot of https://github.com/toeverything/AFFiNE.git (canary, 2026-09-16; blobs > 131072B omitted)
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
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
Copilot Test Automatically / Setup Test (push) Failing after 1s
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
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
Copilot Test Automatically / Setup Test (push) Failing after 1s
This commit is contained in:
460
tests/affine-local/e2e/blocksuite/paragraph.spec.ts
Normal file
460
tests/affine-local/e2e/blocksuite/paragraph.spec.ts
Normal file
@@ -0,0 +1,460 @@
|
||||
import { test } from '@affine-test/kit/playwright';
|
||||
import { locateToolbar } from '@affine-test/kit/utils/editor';
|
||||
import {
|
||||
pressEnter,
|
||||
pressShiftTab,
|
||||
pressTab,
|
||||
selectAllByKeyboard,
|
||||
undoByKeyboard,
|
||||
} 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 type { ParagraphBlockComponent } from '@blocksuite/affine-block-paragraph';
|
||||
import { expect, type Locator } from '@playwright/test';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await clickNewPageButton(page, 'Paragraph Test');
|
||||
await waitForEditorLoad(page);
|
||||
});
|
||||
|
||||
async function expectParagraphState(
|
||||
paragraphs: Locator,
|
||||
index: number,
|
||||
expectedType: string,
|
||||
expectedText: string
|
||||
) {
|
||||
await expect
|
||||
.poll(async () => {
|
||||
return await paragraphs
|
||||
.nth(index)
|
||||
.evaluate(
|
||||
(
|
||||
block: ParagraphBlockComponent,
|
||||
expected: { type: string; text: string }
|
||||
) =>
|
||||
block.model.props.type === expected.type &&
|
||||
block.model.props.text.toString() === expected.text,
|
||||
{
|
||||
type: expectedType,
|
||||
text: expectedText,
|
||||
}
|
||||
);
|
||||
})
|
||||
.toBeTruthy();
|
||||
}
|
||||
|
||||
async function expectParagraphVisibility(
|
||||
paragraphs: Locator,
|
||||
index: number,
|
||||
visible: boolean
|
||||
) {
|
||||
await expect
|
||||
.poll(async () => {
|
||||
return await paragraphs.nth(index).isVisible();
|
||||
})
|
||||
.toBe(visible);
|
||||
}
|
||||
|
||||
test('heading icon should be updated after change heading level', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.keyboard.press('Enter');
|
||||
await page.keyboard.type('Hello');
|
||||
// Hello|
|
||||
// empty paragraph
|
||||
|
||||
const paragraph = page.locator('affine-note affine-paragraph').nth(0);
|
||||
|
||||
await selectAllByKeyboard(page);
|
||||
const toolbar = locateToolbar(page);
|
||||
await toolbar.getByLabel('Conversions').click();
|
||||
await toolbar.getByLabel('Heading 1').click();
|
||||
|
||||
await paragraph.hover();
|
||||
await expect(page.getByTestId('heading-icon-1')).toBeVisible();
|
||||
|
||||
await selectAllByKeyboard(page);
|
||||
await toolbar.getByLabel('Conversions').click();
|
||||
await toolbar.getByLabel('Heading 2').click();
|
||||
|
||||
await paragraph.hover();
|
||||
await expect(page.getByTestId('heading-icon-1')).toBeHidden();
|
||||
await expect(page.getByTestId('heading-icon-2')).toBeVisible();
|
||||
});
|
||||
|
||||
test('basic heading collapsed', async ({ page }) => {
|
||||
await pressEnter(page);
|
||||
|
||||
/**
|
||||
* # aaa
|
||||
* bbb
|
||||
* ## ccc
|
||||
* ddd
|
||||
* ### eee
|
||||
* fff
|
||||
* ## ggg
|
||||
* hhh
|
||||
* # iii
|
||||
* jjj
|
||||
*/
|
||||
await type(
|
||||
page,
|
||||
'# aaa\nbbb\n## ccc\nddd\n### eee\nfff\n## ggg\nhhh\n# iii\njjj'
|
||||
);
|
||||
const a = page.locator('affine-note affine-paragraph').nth(0);
|
||||
const b = page.locator('affine-note affine-paragraph').nth(1);
|
||||
const c = page.locator('affine-note affine-paragraph').nth(2);
|
||||
const d = page.locator('affine-note affine-paragraph').nth(3);
|
||||
const e = page.locator('affine-note affine-paragraph').nth(4);
|
||||
const f = page.locator('affine-note affine-paragraph').nth(5);
|
||||
const g = page.locator('affine-note affine-paragraph').nth(6);
|
||||
const h = page.locator('affine-note affine-paragraph').nth(7);
|
||||
const i = page.locator('affine-note affine-paragraph').nth(8);
|
||||
const j = page.locator('affine-note affine-paragraph').nth(9);
|
||||
|
||||
const assertInitState = async () => {
|
||||
expect(await a.isVisible()).toBeTruthy();
|
||||
expect(await b.isVisible()).toBeTruthy();
|
||||
expect(await c.isVisible()).toBeTruthy();
|
||||
expect(await d.isVisible()).toBeTruthy();
|
||||
expect(await e.isVisible()).toBeTruthy();
|
||||
expect(await f.isVisible()).toBeTruthy();
|
||||
expect(await g.isVisible()).toBeTruthy();
|
||||
expect(await h.isVisible()).toBeTruthy();
|
||||
expect(await i.isVisible()).toBeTruthy();
|
||||
expect(await j.isVisible()).toBeTruthy();
|
||||
};
|
||||
await assertInitState();
|
||||
|
||||
// fold h1 aaa
|
||||
await a.hover();
|
||||
await page.waitForTimeout(100);
|
||||
await a.locator('blocksuite-toggle-button .toggle-icon').click();
|
||||
expect(await a.isVisible()).toBeTruthy();
|
||||
expect(await b.isVisible()).toBeFalsy();
|
||||
expect(await c.isVisible()).toBeFalsy();
|
||||
expect(await d.isVisible()).toBeFalsy();
|
||||
expect(await e.isVisible()).toBeFalsy();
|
||||
expect(await f.isVisible()).toBeFalsy();
|
||||
expect(await g.isVisible()).toBeFalsy();
|
||||
expect(await h.isVisible()).toBeFalsy();
|
||||
expect(await i.isVisible()).toBeTruthy();
|
||||
expect(await j.isVisible()).toBeTruthy();
|
||||
await undoByKeyboard(page);
|
||||
await assertInitState();
|
||||
|
||||
// fold h2 ccc
|
||||
await c.hover();
|
||||
await page.waitForTimeout(100);
|
||||
await c.locator('blocksuite-toggle-button .toggle-icon').click();
|
||||
expect(await a.isVisible()).toBeTruthy();
|
||||
expect(await b.isVisible()).toBeTruthy();
|
||||
expect(await c.isVisible()).toBeTruthy();
|
||||
expect(await d.isVisible()).toBeFalsy();
|
||||
expect(await e.isVisible()).toBeFalsy();
|
||||
expect(await f.isVisible()).toBeFalsy();
|
||||
expect(await g.isVisible()).toBeTruthy();
|
||||
expect(await h.isVisible()).toBeTruthy();
|
||||
expect(await i.isVisible()).toBeTruthy();
|
||||
expect(await j.isVisible()).toBeTruthy();
|
||||
await undoByKeyboard(page);
|
||||
await assertInitState();
|
||||
|
||||
// fold h3 eee
|
||||
await e.hover();
|
||||
await page.waitForTimeout(100);
|
||||
await e.locator('blocksuite-toggle-button .toggle-icon').click();
|
||||
expect(await a.isVisible()).toBeTruthy();
|
||||
expect(await b.isVisible()).toBeTruthy();
|
||||
expect(await c.isVisible()).toBeTruthy();
|
||||
expect(await d.isVisible()).toBeTruthy();
|
||||
expect(await e.isVisible()).toBeTruthy();
|
||||
expect(await f.isVisible()).toBeFalsy();
|
||||
expect(await g.isVisible()).toBeTruthy();
|
||||
expect(await h.isVisible()).toBeTruthy();
|
||||
expect(await i.isVisible()).toBeTruthy();
|
||||
expect(await j.isVisible()).toBeTruthy();
|
||||
await undoByKeyboard(page);
|
||||
await assertInitState();
|
||||
|
||||
// fold h2 ggg
|
||||
await g.hover();
|
||||
await page.waitForTimeout(100);
|
||||
await g.locator('blocksuite-toggle-button .toggle-icon').click();
|
||||
expect(await a.isVisible()).toBeTruthy();
|
||||
expect(await b.isVisible()).toBeTruthy();
|
||||
expect(await c.isVisible()).toBeTruthy();
|
||||
expect(await d.isVisible()).toBeTruthy();
|
||||
expect(await e.isVisible()).toBeTruthy();
|
||||
expect(await f.isVisible()).toBeTruthy();
|
||||
expect(await g.isVisible()).toBeTruthy();
|
||||
expect(await j.isVisible()).toBeTruthy();
|
||||
});
|
||||
|
||||
test('add new heading when press enter at the end of collapsed heading', async ({
|
||||
page,
|
||||
}) => {
|
||||
await pressEnter(page);
|
||||
await type(page, '# aaa');
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await type(page, 'bbb');
|
||||
await page.keyboard.press('ArrowUp');
|
||||
await page.keyboard.press('ArrowRight');
|
||||
|
||||
const paragraph = page.locator('affine-note affine-paragraph');
|
||||
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(1)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.text.toString() === 'bbb'
|
||||
)
|
||||
).toBeTruthy();
|
||||
await pressEnter(page);
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(1)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.type === 'text' &&
|
||||
block.model.props.text.toString() === ''
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(2)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.text.toString() === 'bbb'
|
||||
)
|
||||
).toBeTruthy();
|
||||
|
||||
await undoByKeyboard(page);
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(1)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.text.toString() === 'bbb'
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(await paragraph.nth(1).isVisible()).toBeTruthy();
|
||||
await paragraph
|
||||
.nth(0)
|
||||
.locator('blocksuite-toggle-button .toggle-icon')
|
||||
.click();
|
||||
expect(await paragraph.nth(1).isVisible()).toBeFalsy();
|
||||
|
||||
await paragraph.nth(0).click();
|
||||
expect(await paragraph.count()).toBe(2);
|
||||
await pressEnter(page);
|
||||
expect(await paragraph.count()).toBe(3);
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(2)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.type === 'h1' &&
|
||||
block.model.props.text.toString() === ''
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
test('unfold collapsed heading when some block indented to be its child', async ({
|
||||
page,
|
||||
}) => {
|
||||
await pressEnter(page);
|
||||
await type(page, '# aaa\nbbb\n# ccc');
|
||||
const paragraph = page.locator('affine-note affine-paragraph');
|
||||
await paragraph
|
||||
.nth(0)
|
||||
.locator('blocksuite-toggle-button .toggle-icon')
|
||||
.click();
|
||||
expect(await paragraph.nth(1).isVisible()).toBeFalsy();
|
||||
await paragraph.nth(2).click();
|
||||
await pressTab(page);
|
||||
expect(await paragraph.nth(1).isVisible()).toBeTruthy();
|
||||
});
|
||||
|
||||
test('unfold collapsed heading when its siblings changed to text type from heading type', async ({
|
||||
page,
|
||||
}) => {
|
||||
await pressEnter(page);
|
||||
await type(page, '# aaa\nbbb\n# ccc');
|
||||
const paragraph = page.locator('affine-note affine-paragraph');
|
||||
await paragraph
|
||||
.nth(0)
|
||||
.locator('blocksuite-toggle-button .toggle-icon')
|
||||
.click();
|
||||
expect(await paragraph.nth(1).isVisible()).toBeFalsy();
|
||||
await paragraph.nth(2).click();
|
||||
await page.keyboard.press('ArrowLeft');
|
||||
await page.keyboard.press('ArrowLeft');
|
||||
await page.keyboard.press('ArrowLeft');
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(2)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.type === 'h1' &&
|
||||
block.model.props.text.toString() === 'ccc'
|
||||
)
|
||||
).toBeTruthy();
|
||||
await page.keyboard.press('Backspace');
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(2)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.type === 'text' &&
|
||||
block.model.props.text.toString() === 'ccc'
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(await paragraph.nth(1).isVisible()).toBeTruthy();
|
||||
});
|
||||
|
||||
test('also move children when dedent collapsed heading', async ({ page }) => {
|
||||
await pressEnter(page);
|
||||
await type(page, 'aaa');
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await pressTab(page);
|
||||
await type(page, '# bbb\nccc');
|
||||
|
||||
const paragraph = page.locator('affine-note affine-paragraph');
|
||||
const subParagraph = paragraph.nth(0).locator('affine-paragraph');
|
||||
await expect.poll(() => subParagraph.count()).toBe(2);
|
||||
await expectParagraphState(subParagraph, 0, 'h1', 'bbb');
|
||||
await expectParagraphState(subParagraph, 1, 'text', 'ccc');
|
||||
|
||||
expect(await subParagraph.nth(1).isVisible()).toBeTruthy();
|
||||
await subParagraph
|
||||
.nth(0)
|
||||
.locator('blocksuite-toggle-button .toggle-icon')
|
||||
.click();
|
||||
expect(await subParagraph.nth(1).isVisible()).toBeFalsy();
|
||||
|
||||
await subParagraph.nth(0).click();
|
||||
await pressShiftTab(page);
|
||||
expect(await subParagraph.count()).toBe(0);
|
||||
await expectParagraphState(paragraph, 1, 'h1', 'bbb');
|
||||
await expectParagraphState(paragraph, 2, 'text', 'ccc');
|
||||
await expectParagraphVisibility(paragraph, 2, false);
|
||||
await paragraph
|
||||
.nth(1)
|
||||
.locator('blocksuite-toggle-button .toggle-icon')
|
||||
.click({
|
||||
position: {
|
||||
x: 5,
|
||||
y: 5,
|
||||
},
|
||||
});
|
||||
await expectParagraphVisibility(paragraph, 2, true);
|
||||
});
|
||||
|
||||
test('also move collapsed siblings when indent collapsed heading', async ({
|
||||
page,
|
||||
}) => {
|
||||
await pressEnter(page);
|
||||
await type(page, 'aaa');
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await type(page, '# bbb\nccc');
|
||||
await page.keyboard.press('ArrowUp');
|
||||
|
||||
const paragraph = page.locator('affine-note affine-paragraph');
|
||||
expect(await paragraph.nth(0).locator('affine-paragraph').count()).toBe(0);
|
||||
await pressTab(page);
|
||||
expect(await paragraph.nth(0).locator('affine-paragraph').count()).toBe(1);
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(0)
|
||||
.locator('affine-paragraph')
|
||||
.nth(0)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.type === 'h1' &&
|
||||
block.model.props.text.toString() === 'bbb'
|
||||
)
|
||||
).toBeTruthy();
|
||||
await undoByKeyboard(page);
|
||||
|
||||
expect(await paragraph.nth(2).isVisible()).toBeTruthy();
|
||||
await paragraph
|
||||
.nth(1)
|
||||
.locator('blocksuite-toggle-button .toggle-icon')
|
||||
.click();
|
||||
expect(await paragraph.nth(2).isVisible()).toBeFalsy();
|
||||
await paragraph.nth(1).click();
|
||||
await pressTab(page);
|
||||
expect(await paragraph.nth(2).isVisible()).toBeFalsy();
|
||||
expect(await paragraph.nth(0).locator('affine-paragraph').count()).toBe(2);
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(0)
|
||||
.locator('affine-paragraph')
|
||||
.nth(0)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.type === 'h1' &&
|
||||
block.model.props.text.toString() === 'bbb'
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
await paragraph
|
||||
.nth(0)
|
||||
.locator('affine-paragraph')
|
||||
.nth(1)
|
||||
.evaluate(
|
||||
(block: ParagraphBlockComponent) =>
|
||||
block.model.props.type === 'text' &&
|
||||
block.model.props.text.toString() === 'ccc'
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
test('unfold collapsed heading when its other blocks indented to be its sibling', async ({
|
||||
page,
|
||||
}) => {
|
||||
await pressEnter(page);
|
||||
await type(page, 'aaa');
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await type(page, '# bbb\nddd');
|
||||
await page.keyboard.press('ArrowUp');
|
||||
await pressTab(page);
|
||||
const paragraph = page.locator('affine-note affine-paragraph');
|
||||
const subParagraph = paragraph.nth(0).locator('affine-paragraph');
|
||||
await expect.poll(() => subParagraph.count()).toBe(1);
|
||||
await expectParagraphState(subParagraph, 0, 'h1', 'bbb');
|
||||
await subParagraph.nth(0).click();
|
||||
await page.keyboard.press('End');
|
||||
await pressEnter(page);
|
||||
await type(page, 'ccc');
|
||||
|
||||
/**
|
||||
* aaa
|
||||
* # bbb
|
||||
* ccc
|
||||
* ddd
|
||||
*/
|
||||
|
||||
await expectParagraphVisibility(paragraph, 2, true);
|
||||
await expectParagraphState(paragraph, 2, 'text', 'ccc');
|
||||
await paragraph.locator('blocksuite-toggle-button .toggle-icon').click();
|
||||
await expectParagraphVisibility(paragraph, 2, false);
|
||||
|
||||
await paragraph.nth(3).click(); // ddd
|
||||
await expectParagraphVisibility(paragraph, 2, false);
|
||||
await expect
|
||||
.poll(() => paragraph.nth(0).locator('affine-paragraph').count())
|
||||
.toBe(2);
|
||||
await pressTab(page);
|
||||
await expect
|
||||
.poll(() => paragraph.nth(0).locator('affine-paragraph').count())
|
||||
.toBe(3);
|
||||
await expectParagraphVisibility(paragraph, 2, true);
|
||||
});
|
||||
Reference in New Issue
Block a user