heynote/tests/auto-closing-brackets.spec.js
Florian Labarre 0f3c714d56
CloseBrackets setting toggle (#102)
* Add a setting to toggle the auto bracket-closing of CodeMirror

* Move Auto-close brackets setting into new settings tab Editing

* Add tests for Auto-close bracket setting

---------

Co-authored-by: Jonatan Heyman <jonatan@heyman.info>
2024-01-04 14:52:41 +01:00

28 lines
1.0 KiB
JavaScript

import { test, expect } from "@playwright/test";
import { HeynotePage } from "./test-utils.js";
let heynotePage
test.beforeEach(async ({ page }) => {
heynotePage = new HeynotePage(page)
await heynotePage.goto()
});
test("test bracket closing default off", async ({ page }) => {
await page.locator("body").pressSequentially("{")
expect(await heynotePage.getBlockContent(0)).toBe("{")
})
test("test bracket closing", async ({ page }) => {
await page.locator("css=.status-block.settings").click()
await page.locator("css=li.tab-editing").click()
await page.getByLabel("Auto-close brackets and quotation marks").click()
await page.locator("body").press("Escape")
await page.locator("body").pressSequentially("{")
expect(await heynotePage.getBlockContent(0)).toBe("{}")
await page.locator("body").press("Backspace")
expect(await heynotePage.getBlockContent(0)).toBe("")
await page.locator("body").pressSequentially("(hej")
await page.locator("body").pressSequentially("(hej)")
})