mirror of
https://github.com/heyman/heynote.git
synced 2024-11-22 07:54:11 +01:00
bb511b868b
* Contain language selection dialog in an element that can be scrolled, and automatically scroll it if needed when navigating the list with arrow keys * Add support for more languages: Clojure, Erlang, Golang, Lezer, Ruby, Shell, YAML * Move prettier auto format settings for languages into Language() class * Remove invalid import * Fix bug that could cause auto formatting to fail for the last block. Add tests for language auto detection and formatting. * Fix broken tests * Fix language auto detection on Safari Webkit which was broken * Remove unnecessary wait time
46 lines
1.3 KiB
JavaScript
46 lines
1.3 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("JSON formatting", async ({ page }) => {
|
|
heynotePage.setContent(`
|
|
∞∞∞json
|
|
{"test": 1, "key2": "hey!"}
|
|
`)
|
|
expect(await page.locator("css=.status .status-block.lang")).toHaveText("JSON")
|
|
await page.locator("css=.status-block.format").click()
|
|
await page.waitForTimeout(100)
|
|
expect(await heynotePage.getBlockContent(0)).toBe(`{
|
|
"test": 1,
|
|
"key2": "hey!"
|
|
}
|
|
`)
|
|
})
|
|
|
|
test("JSON formatting (cursor at start)", async ({ page }) => {
|
|
heynotePage.setContent(`
|
|
∞∞∞json
|
|
{"test": 1, "key2": "hey!"}
|
|
`)
|
|
expect(await page.locator("css=.status .status-block.lang")).toHaveText("JSON")
|
|
for (let i=0; i<5; i++) {
|
|
await page.locator("body").press("ArrowUp")
|
|
}
|
|
await page.locator("css=.status-block.format").click()
|
|
await page.waitForTimeout(100)
|
|
expect(await heynotePage.getBlockContent(0)).toBe(`{
|
|
"test": 1,
|
|
"key2": "hey!"
|
|
}
|
|
`)
|
|
const block = (await heynotePage.getBlocks())[0]
|
|
expect(await page.evaluate(() => window._heynote_editor.view.state.selection.main.from)).toBe(block.content.from)
|
|
}) |