| 429 | } |
| 430 | |
| 431 | export async function runCommand(page: Page, command: string): Promise<void> { |
| 432 | await openCommandPalette(page); |
| 433 | // Type the command |
| 434 | await page.keyboard.type(command, { delay: 30 }); |
| 435 | await page.waitForTimeout(500); // Wait for search to filter |
| 436 | |
| 437 | // Wait for suggestions to appear |
| 438 | const suggestion = page.locator('.suggestion-item').first(); |
| 439 | try { |
| 440 | await suggestion.waitFor({ timeout: 3000, state: 'visible' }); |
| 441 | await page.keyboard.press('Enter'); |
| 442 | } catch { |
| 443 | // If no suggestions found, still try to press Enter and close palette |
| 444 | await page.keyboard.press('Escape'); |
| 445 | throw new Error(`Command not found: "${command}". Make sure TaskNotes plugin is loaded.`); |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | export async function waitForNotice(page: Page, text?: string): Promise<void> { |
| 450 | const notice = page.locator('.notice'); |