mirror of
https://github.com/heyman/heynote.git
synced 2024-11-25 09:23:17 +01:00
1006fd4580
* Set up Playwright and add first test * Add npm run commands for running tests Run tests in github actions * Fix tests on non Mac environments * Add method to HeynoteEditor class to set the buffer content * Add more tests * Set Github action job name
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
import { test, expect } from "@playwright/test";
|
|
import { HeynotePage } from "./test-utils.js";
|
|
|
|
let heynotePage
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
console.log("beforeEach")
|
|
heynotePage = new HeynotePage(page)
|
|
await heynotePage.goto()
|
|
});
|
|
|
|
test("enter text and create new block", async ({ page }) => {
|
|
expect((await heynotePage.getBlocks()).length).toBe(1)
|
|
await page.locator("body").pressSequentially("Hello World!")
|
|
await page.locator("body").press("Enter")
|
|
await page.locator("body").press(heynotePage.isMac ? "Meta+Enter" : "Control+Enter")
|
|
await page.waitForTimeout(100);
|
|
expect((await heynotePage.getBlocks()).length).toBe(2)
|
|
expect(await heynotePage.getBlockContent(0)).toBe("Hello World!\n")
|
|
expect(await heynotePage.getBlockContent(1)).toBe("")
|
|
|
|
// check that visual block layers are created
|
|
expect(await page.locator("css=.heynote-blocks-layer > div").count()).toBe(2)
|
|
})
|
|
|
|
test("backspace", async ({ page }) => {
|
|
|
|
await page.locator("body").pressSequentially("Hello World!")
|
|
for (let i=0; i<5; i++) {
|
|
await page.locator("body").press("Backspace")
|
|
}
|
|
expect(await heynotePage.getBlockContent(0)).toBe("Hello W")
|
|
})
|
|
|
|
test("first block is protected", async ({ page }) => {
|
|
const initialContent = await heynotePage.getContent()
|
|
await page.locator("body").press("Backspace")
|
|
expect(await heynotePage.getBlockContent(0)).toBe("")
|
|
expect(await heynotePage.getContent()).toBe(initialContent)
|
|
})
|