mirror of
https://github.com/heyman/heynote.git
synced 2024-11-28 19:03:45 +01:00
c010df083c
Add support for migrating old buffer file to new library. Add support for changing location for the notes library. Replace theme toggle in status bar with a dropdown in Appearance settings. Improve New Note and Update Note dialogs. Implement UI for confirming note delete (the actualal deltion is still to be implemented).
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
import { test, expect } from '@playwright/test';
|
|
import { NoteFormat } from '../src/common/note-format.js';
|
|
|
|
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 getBufferData() {
|
|
return await this.page.evaluate(() => window._heynote_editor.getContent())
|
|
}
|
|
|
|
async getContent() {
|
|
const note = NoteFormat.load(await this.getBufferData())
|
|
return note.content
|
|
}
|
|
|
|
async setContent(content) {
|
|
await expect(this.page.locator("css=.cm-editor")).toBeVisible()
|
|
await this.page.evaluate((content) => window._heynote_editor.setContent(content), content)
|
|
}
|
|
|
|
async getCursorPosition() {
|
|
return await this.page.evaluate(() => window._heynote_editor.getCursorPosition())
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
async getStoredSettings() {
|
|
return await this.page.evaluate(() => JSON.parse(window.localStorage.getItem("settings")))
|
|
}
|
|
}
|