heynote/tests/delete-line.spec.js
Abhishek Maran 5eed314e32
fix: Block corruption when deleting block content using deleteLine command (#134)
* fix: cell corruption when deleting block contents

* customize deleteLine to fix cell corruption

* implemented tests for delete line

* moved deleteLine and selectedLineBlocks to delete-line.js
2024-02-07 13:03:59 +01:00

51 lines
1.4 KiB
JavaScript

import { expect, test } from "@playwright/test";
import { HeynotePage } from "./test-utils.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
text content 1
text content 2
text content 3
text content 4
∞∞∞text
Block B
∞∞∞text
Block C`)
// check that blocks are created
expect((await heynotePage.getBlocks()).length).toBe(3)
// check that visual block layers are created
await expect(page.locator("css=.heynote-blocks-layer > div")).toHaveCount(3)
});
test("delete line on single line in Block A", async ({ page }) => {
for (let i = 0; i < 7; i++) {
await page.locator("body").press("ArrowUp")
}
for (let i = 0; i < 4; i++) {
await page.locator("body").press(`${heynotePage.isMac ? "Meta" : "Control"}+Shift+k`)
}
expect(await heynotePage.getBlockContent(0)).toBe("\ntext content 4");
});
test("delete line on selection in Block B", async ({ page }) => {
for (let i = 0; i < 1; i++) {
await page.locator("body").press("ArrowUp")
}
await page.locator("body").press(`${heynotePage.isMac ? "Meta" : "Control"}+A`)
await page.locator("body").press(`${heynotePage.isMac ? "Meta" : "Control"}+Shift+k`)
expect(await heynotePage.getBlockContent(1)).toBe('');
});