mirror of
https://github.com/heyman/heynote.git
synced 2024-11-25 09:23:17 +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
40 lines
1.1 KiB
JavaScript
40 lines
1.1 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("test valid JSON detection", async ({ page }) => {
|
|
await page.locator("body").pressSequentially(`
|
|
{"test": 1, "key2": "hey!"}
|
|
`)
|
|
await expect(page.locator("css=.status .status-block.lang")).toHaveText("JSON (auto)")
|
|
const block = (await heynotePage.getBlocks())[0]
|
|
expect(block.language.name).toBe("json")
|
|
expect(block.language.auto).toBeTruthy()
|
|
})
|
|
|
|
|
|
test("python detection", async ({ page }) => {
|
|
await page.locator("body").pressSequentially(`
|
|
# import complex math module
|
|
import cmath
|
|
|
|
# calculate the discriminant
|
|
d = (b**2) - (4*a*c)
|
|
|
|
# find two solutions
|
|
sol1 = (-b-cmath.sqrt(d))/(2*a)
|
|
sol2 = (-b+cmath.sqrt(d))/(2*a)
|
|
|
|
print('The solution are {0} and {1}'.format(sol1,sol2))
|
|
`)
|
|
await expect(page.locator("css=.status .status-block.lang")).toHaveText("Python (auto)")
|
|
})
|