mirror of
https://github.com/heyman/heynote.git
synced 2025-06-27 04:51:50 +02:00
Add test for overriding one of the default key bindings
This commit is contained in:
parent
29ac62db01
commit
a7a933c3ef
@ -25,6 +25,7 @@ test("add custom key binding", async ({page}) => {
|
||||
await page.locator(".p-autocomplete-list li.p-autocomplete-option.p-focus").click()
|
||||
await page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog .save").click()
|
||||
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings table tr.keybind-user")).toHaveCount(1)
|
||||
expect((await heynotePage.getSettings()).keyBindings).toEqual([{key:"Control-Shift-h", command:"openLanguageSelector"}])
|
||||
await page.locator("css=.overlay .settings .dialog .bottom-bar .close").click()
|
||||
await page.locator("body").press("Control+Shift+H")
|
||||
await expect(page.locator("css=.language-selector .items > li.selected")).toBeVisible()
|
||||
@ -43,6 +44,7 @@ test("delete custom key binding", async ({page}) => {
|
||||
await page.locator(".p-autocomplete-list li.p-autocomplete-option.p-focus").click()
|
||||
await page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog .save").click()
|
||||
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings table tr.keybind-user")).toHaveCount(1)
|
||||
expect((await heynotePage.getSettings()).keyBindings).toEqual([{key:"Control-Shift-h", command:"openLanguageSelector"}])
|
||||
await page.locator("css=.overlay .settings .dialog .bottom-bar .close").click()
|
||||
await page.locator("body").press("Control+Shift+H")
|
||||
await expect(page.locator("css=.language-selector .items > li.selected")).toBeVisible()
|
||||
@ -56,3 +58,15 @@ test("delete custom key binding", async ({page}) => {
|
||||
await page.locator("body").press("Control+Shift+H")
|
||||
await expect(page.locator("css=.language-selector .items > li.selected")).toHaveCount(0)
|
||||
})
|
||||
|
||||
test("disable default key binding", async ({page}) => {
|
||||
await page.locator("body").press("Meta+L")
|
||||
await expect(page.locator("css=.language-selector .items > li.selected")).toBeVisible()
|
||||
await page.locator("body").press("Escape")
|
||||
await expect(page.locator("css=.language-selector .items > li.selected")).toHaveCount(0)
|
||||
const settings = await heynotePage.getSettings()
|
||||
settings.keyBindings = [{key:"Meta-L", command:"nothing"}]
|
||||
await heynotePage.setSettings(settings)
|
||||
await page.locator("body").press("Meta+L")
|
||||
await expect(page.locator("css=.language-selector .items > li.selected")).toHaveCount(0)
|
||||
})
|
@ -79,6 +79,16 @@ export class HeynotePage {
|
||||
await this.page.evaluate(({path, content}) => window.heynote.buffer.save(path, content), {path, content:format.serialize()})
|
||||
}
|
||||
|
||||
async getSettings() {
|
||||
return await this.page.evaluate(() => {
|
||||
return JSON.parse(window.localStorage.getItem("settings") || "{}")
|
||||
})
|
||||
}
|
||||
|
||||
async setSettings(settings) {
|
||||
await this.page.evaluate((settings) => window.heynote.setSettings(settings), settings)
|
||||
}
|
||||
|
||||
agnosticKey(key) {
|
||||
return key.replace("Mod", this.isMac ? "Meta" : "Control")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user