mirror of
https://github.com/heyman/heynote.git
synced 2025-08-10 07:07:46 +02:00
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:
44
tests/delete-block.spec.js
Normal file
44
tests/delete-block.spec.js
Normal file
@ -0,0 +1,44 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {HeynotePage} from "./test-utils.js";
|
||||
|
||||
import { AUTO_SAVE_INTERVAL } from "../src/common/constants.js"
|
||||
import { NoteFormat } from "../src/common/note-format.js"
|
||||
|
||||
|
||||
let heynotePage
|
||||
|
||||
test.beforeEach(async ({page}) => {
|
||||
heynotePage = new HeynotePage(page)
|
||||
await heynotePage.goto()
|
||||
|
||||
expect((await heynotePage.getBlocks()).length).toBe(1)
|
||||
await heynotePage.setContent(`
|
||||
∞∞∞text
|
||||
Block A
|
||||
∞∞∞markdown
|
||||
Block B
|
||||
∞∞∞text
|
||||
Block C`)
|
||||
await page.waitForTimeout(100)
|
||||
})
|
||||
|
||||
test("delete first block", async ({page}) => {
|
||||
await heynotePage.setCursorPosition(10)
|
||||
await page.locator("body").press(heynotePage.agnosticKey("Mod+Shift+D"))
|
||||
await page.waitForTimeout(50)
|
||||
expect(await heynotePage.getCursorPosition()).toBe(13)
|
||||
})
|
||||
|
||||
test("delete middle block", async ({page}) => {
|
||||
await heynotePage.setCursorPosition(32)
|
||||
await page.locator("body").press(heynotePage.agnosticKey("Mod+Shift+D"))
|
||||
await page.waitForTimeout(50)
|
||||
expect(await heynotePage.getCursorPosition()).toBe(25)
|
||||
})
|
||||
|
||||
test("delete last block", async ({page}) => {
|
||||
await heynotePage.setCursorPosition(52)
|
||||
await page.locator("body").press(heynotePage.agnosticKey("Mod+Shift+D"))
|
||||
await page.waitForTimeout(50)
|
||||
expect(await heynotePage.getCursorPosition()).toBe(36)
|
||||
})
|
Reference in New Issue
Block a user