Position the cursor at the beginning of the next block when a block is deleted

This also changes the behavior when blocks are moved.
Add tests for the deleteBlock command.
This commit is contained in:
Jonatan Heyman
2025-01-09 14:04:02 +01:00
parent 03ec7a4867
commit 52a6c444eb
5 changed files with 127 additions and 8 deletions

View File

@ -25,15 +25,17 @@ Block C`)
// check that visual block layers are created
await expect(page.locator("css=.heynote-blocks-layer > div")).toHaveCount(3)
});
test("move block to other buffer", async ({page}) => {
// create secondary buffer
await heynotePage.saveBuffer("other.txt", `
∞∞∞text-a
First block
∞∞∞math
Second block`)
});
test("move block to other buffer", async ({page}) => {
await page.locator("body").press(heynotePage.agnosticKey("Mod+S"))
await page.waitForTimeout(50)
await page.locator("body").press("Enter")
@ -62,11 +64,6 @@ Block C`)
test("move block to other open/cached buffer", async ({page}) => {
await heynotePage.saveBuffer("other.txt", `
∞∞∞text-a
First block
∞∞∞math
Second block`)
await page.locator("body").press(heynotePage.agnosticKey("Mod+P"))
await page.locator("body").press("Enter")
await page.waitForTimeout(50)
@ -99,3 +96,30 @@ Block C`)
})
test("cursor position after moving first block", async ({page}) => {
await heynotePage.setCursorPosition(10)
expect(await heynotePage.getCursorPosition()).toBe(10)
await page.locator("body").press(heynotePage.agnosticKey("Mod+S"))
await page.waitForTimeout(50)
await page.locator("body").press("Enter")
await page.waitForTimeout(50)
expect(await heynotePage.getCursorPosition()).toBe(9)
})
test("cursor position after moving middle block", async ({page}) => {
await heynotePage.setCursorPosition(28)
await page.locator("body").press(heynotePage.agnosticKey("Mod+S"))
await page.waitForTimeout(50)
await page.locator("body").press("Enter")
await page.waitForTimeout(50)
expect(await heynotePage.getCursorPosition()).toBe(25)
})
test("cursor position after moving last block", async ({page}) => {
await heynotePage.setCursorPosition(48)
await page.locator("body").press(heynotePage.agnosticKey("Mod+S"))
await page.waitForTimeout(50)
await page.locator("body").press("Enter")
await page.waitForTimeout(50)
expect(await heynotePage.getCursorPosition()).toBe(32)
})