+
{results.map((result, i) => (
{
}, id)
}
+async function installGlobalSearchResultsHarness(page: Page): Promise {
+ await page.waitForFunction(() => Boolean(window.__mockHandlers?.search_vault))
+ await page.evaluate((results) => {
+ type Handler = (args?: Record) => unknown
+ const handlers = window.__mockHandlers as Record
+ Object.defineProperty(window, '__mockHandlers', {
+ configurable: true,
+ get: () => handlers,
+ set: (nextHandlers) => Object.assign(handlers, nextHandlers),
+ })
+ handlers.search_vault = () => ({ results, elapsed_ms: 1 })
+ }, GLOBAL_SEARCH_RESULTS)
+}
+
+function searchResultRow(page: Page, title: string) {
+ return page.locator('[role="option"]').filter({ hasText: title }).first()
+}
+
+async function expectSelectedSearchResult(page: Page, title: string): Promise {
+ await expect(searchResultRow(page, title)).toHaveClass(/bg-accent/)
+}
+
test.describe('keyboard command routing', () => {
test.beforeEach(() => {
tempVaultDir = createFixtureVaultCopy()
@@ -135,6 +164,35 @@ test.describe('keyboard command routing', () => {
await expect(page.locator('input[placeholder="Search notes..."]')).toBeFocused()
})
+ test('global search arrow keys move one result at a time @smoke', async ({ page }) => {
+ await openFixtureVaultDesktopHarness(page, tempVaultDir)
+ await installGlobalSearchResultsHarness(page)
+
+ await page.locator('body').click()
+ await dispatchShortcutEvent(page, {
+ key: 'f',
+ code: 'KeyF',
+ ctrlKey: false,
+ metaKey: true,
+ shiftKey: true,
+ altKey: false,
+ bubbles: true,
+ cancelable: true,
+ })
+ const input = page.locator(GLOBAL_SEARCH_INPUT)
+ await expect(input).toBeVisible({ timeout: 5_000 })
+ await input.fill('search')
+ await expect(searchResultRow(page, 'Third Search Result')).toBeVisible({ timeout: 5_000 })
+
+ await expectSelectedSearchResult(page, 'First Search Result')
+ await page.keyboard.press('ArrowDown')
+ await expectSelectedSearchResult(page, 'Second Search Result')
+ await page.keyboard.press('ArrowDown')
+ await expectSelectedSearchResult(page, 'Third Search Result')
+ await page.keyboard.press('ArrowUp')
+ await expectSelectedSearchResult(page, 'Second Search Result')
+ })
+
test('desktop menu-command bridge toggles organized state through the shared command path @smoke', async ({ page }) => {
await openAlphaProjectInEditor(page)