mirror of
https://github.com/heyman/heynote.git
synced 2024-12-22 23:00:38 +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
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
import { test, expect } from '@playwright/test';
|
|
|
|
export function pageErrorGetter(page) {
|
|
let messages = [];
|
|
page.on('pageerror', (error) => {
|
|
messages.push(`[${error.name}] ${error.message}`);
|
|
});
|
|
return () => messages;
|
|
}
|
|
|
|
|
|
export class HeynotePage {
|
|
constructor(page) {
|
|
this.page = page
|
|
this.getErrors = pageErrorGetter(page)
|
|
this.isMac = process.platform === "darwin"
|
|
}
|
|
|
|
async goto() {
|
|
await this.page.goto("/")
|
|
await expect(this.page).toHaveTitle(/Heynote/)
|
|
expect(this.getErrors()).toStrictEqual([])
|
|
}
|
|
|
|
async getBlocks() {
|
|
return await this.page.evaluate(() => window._heynote_editor.getBlocks())
|
|
}
|
|
|
|
async getContent() {
|
|
return await this.page.evaluate(() => window._heynote_editor.getContent())
|
|
}
|
|
|
|
async setContent(content) {
|
|
await this.page.evaluate((content) => window._heynote_editor.setContent(content), content)
|
|
}
|
|
|
|
async getBlockContent(blockIndex) {
|
|
const blocks = await this.getBlocks()
|
|
const content = await this.getContent()
|
|
expect(blocks.length).toBeGreaterThan(blockIndex)
|
|
const block = blocks[blockIndex]
|
|
return content.slice(block.content.from, block.content.to)
|
|
}
|
|
}
|