Fix test on linux/windows

Change Playwright reporter when running in Github action

Change default emacs meta key to Alt on non Linux and Windows

Always set emacsMetaKey to "alt" if not on Mac, since the option is only available on Mac
This commit is contained in:
Jonatan Heyman 2024-01-05 16:53:00 +01:00
parent 17091d323c
commit 554e04ea67
7 changed files with 16 additions and 10 deletions

View File

@ -1,4 +1,5 @@
import Store from "electron-store" import Store from "electron-store"
import { isMac } from "./detect-platform"
const isDev = !!process.env.VITE_DEV_SERVER_URL const isDev = !!process.env.VITE_DEV_SERVER_URL
@ -50,7 +51,7 @@ const schema = {
const defaults = { const defaults = {
settings: { settings: {
keymap: "default", keymap: "default",
emacsMetaKey: "meta", emacsMetaKey: isMac ? "meta" : "alt",
showLineNumberGutter: true, showLineNumberGutter: true,
showFoldGutter: true, showFoldGutter: true,
autoUpdate: true, autoUpdate: true,

View File

@ -20,7 +20,7 @@ export default defineConfig({
/* Opt out of parallel tests on CI. */ /* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined, workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html', reporter: process.env.CI ? [['github'], ['html']] : 'list',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: { use: {
/* Base URL to use in actions like `await page.goto('/')`. */ /* Base URL to use in actions like `await page.goto('/')`. */

View File

@ -13,7 +13,7 @@
}, },
emacsMetaKey: { emacsMetaKey: {
type: String, type: String,
default: "Meta", default: "alt",
}, },
showLineNumberGutter: { showLineNumberGutter: {
type: Boolean, type: Boolean,

View File

@ -60,7 +60,7 @@
showLineNumberGutter: this.showLineNumberGutter, showLineNumberGutter: this.showLineNumberGutter,
showFoldGutter: this.showFoldGutter, showFoldGutter: this.showFoldGutter,
keymap: this.keymap, keymap: this.keymap,
emacsMetaKey: this.metaKey, emacsMetaKey: window.heynote.platform.isMac ? this.metaKey : "alt",
allowBetaVersions: this.allowBetaVersions, allowBetaVersions: this.allowBetaVersions,
enableGlobalHotkey: this.enableGlobalHotkey, enableGlobalHotkey: this.enableGlobalHotkey,
globalHotkey: this.globalHotkey, globalHotkey: this.globalHotkey,

View File

@ -40,7 +40,7 @@ export class HeynoteEditor {
theme="light", theme="light",
saveFunction=null, saveFunction=null,
keymap="default", keymap="default",
emacsMetaKey="Meta", emacsMetaKey,
showLineNumberGutter=true, showLineNumberGutter=true,
showFoldGutter=true, showFoldGutter=true,
bracketClosing=false, bracketClosing=false,

View File

@ -17,17 +17,22 @@ test("test emacs copy/pase/cut key bindings", async ({ page, browserName }) => {
await page.locator("css=.status-block.settings").click() await page.locator("css=.status-block.settings").click()
//await page.locator("css=li.tab-editing").click() //await page.locator("css=li.tab-editing").click()
await page.locator("css=select.keymap").selectOption("emacs") await page.locator("css=select.keymap").selectOption("emacs")
await page.locator("css=select.metaKey").selectOption("alt") if (heynotePage.isMac) {
await page.locator("css=select.metaKey").selectOption("alt")
}
await page.locator("body").press("Escape") await page.locator("body").press("Escape")
await page.locator("body").pressSequentially("test") await page.locator("body").pressSequentially("test")
await page.locator("body").press(heynotePage.isMac ? "Meta+A" : "Control+A") await page.locator("body").press("Control+Space")
await page.locator("body").press("Control+A")
await page.locator("body").press("Alt+W") await page.locator("body").press("Alt+W")
expect(await heynotePage.getBlockContent(0)).toBe("test") expect(await heynotePage.getBlockContent(0)).toBe("test")
await page.locator("body").press("Control+Y") await page.locator("body").press("Control+Y")
expect(await heynotePage.getBlockContent(0)).toBe("testtest") expect(await heynotePage.getBlockContent(0)).toBe("testtest")
await page.locator("body").press(heynotePage.isMac ? "Meta+A" : "Control+A") await page.locator("body").press("Control+E")
await page.locator("body").press("Control+Space")
await page.locator("body").press("Control+A")
await page.locator("body").press("Control+W") await page.locator("body").press("Control+W")
expect(await heynotePage.getBlockContent(0)).toBe("") expect(await heynotePage.getBlockContent(0)).toBe("")
await page.locator("body").press("Control+Y") await page.locator("body").press("Control+Y")

View File

@ -61,7 +61,7 @@ const ipcRenderer = new IpcRenderer()
let settingsData = localStorage.getItem("settings") let settingsData = localStorage.getItem("settings")
let initialSettings = { let initialSettings = {
keymap: "default", keymap: "default",
emacsMetaKey: "meta", emacsMetaKey: "alt",
showLineNumberGutter: true, showLineNumberGutter: true,
showFoldGutter: true, showFoldGutter: true,
bracketClosing: false, bracketClosing: false,