mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-04-26 15:17:52 +00:00
feat: improve keyboard shortcuts handling and add E2E helper functions for command palette interaction
This commit is contained in:
@@ -50,6 +50,9 @@ class KeyboardShortcuts {
|
||||
// Check for matches
|
||||
for (const shortcut of this.shortcuts) {
|
||||
if (this.matches(shortcut.keys, e)) {
|
||||
if (shortcut.action === "command_palette") {
|
||||
continue;
|
||||
}
|
||||
// Check if we should ignore because we're in an input
|
||||
const isInput =
|
||||
["INPUT", "TEXTAREA"].includes(document.activeElement.tagName) ||
|
||||
|
||||
41
tests/e2e/helpers.js
Normal file
41
tests/e2e/helpers.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const { expect } = require("@playwright/test");
|
||||
|
||||
const E2E_BACKEND_PORT = process.env.E2E_BACKEND_PORT || "8000";
|
||||
const E2E_BACKEND_ORIGIN = `http://127.0.0.1:${E2E_BACKEND_PORT}`;
|
||||
|
||||
const PALETTE_PLACEHOLDER = "Search commands, navigate, or find peers...";
|
||||
|
||||
/**
|
||||
* Marks tutorial and changelog as seen on the E2E backend so first-load modals
|
||||
* (v-overlay scrim) do not block pointer clicks on the shell.
|
||||
*/
|
||||
async function prepareE2eSession(request) {
|
||||
const tutorial = await request.post(`${E2E_BACKEND_ORIGIN}/api/v1/app/tutorial/seen`);
|
||||
expect(tutorial.ok()).toBeTruthy();
|
||||
const changelog = await request.post(`${E2E_BACKEND_ORIGIN}/api/v1/app/changelog/seen`, {
|
||||
data: { version: "999.999.999" },
|
||||
});
|
||||
expect(changelog.ok()).toBeTruthy();
|
||||
}
|
||||
|
||||
async function openCommandPalette(page) {
|
||||
await page.keyboard.press("Control+K");
|
||||
let input = page.getByPlaceholder(PALETTE_PLACEHOLDER);
|
||||
if ((await input.count()) === 0) {
|
||||
await page.evaluate(() => {
|
||||
window.dispatchEvent(
|
||||
new KeyboardEvent("keydown", {
|
||||
key: "k",
|
||||
code: "KeyK",
|
||||
ctrlKey: true,
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
input = page.getByPlaceholder(PALETTE_PLACEHOLDER);
|
||||
}
|
||||
await expect(input).toBeVisible({ timeout: 15000 });
|
||||
}
|
||||
|
||||
module.exports = { E2E_BACKEND_ORIGIN, PALETTE_PLACEHOLDER, openCommandPalette, prepareE2eSession };
|
||||
Reference in New Issue
Block a user