Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: command palette e2e tests #3588

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions frontend/console/e2e/command-palette.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { expect, test } from '@playwright/test'
import { pressShortcut } from './helpers'

test('shows command palette results', async ({ page }) => {
await page.goto('http://localhost:8892')

await page.click('#command-palette-search')
await page.fill('#command-palette-search-input', 'echo')

// Command palette should be showing the echo parts
await expect(page.locator('[role="listbox"]').getByText('echo.EchoRequest', { exact: true })).toBeVisible()
await expect(page.locator('[role="listbox"]').getByText('echo.EchoResponse', { exact: true })).toBeVisible()
await expect(page.locator('[role="listbox"]').getByText('echo.echo', { exact: true })).toBeVisible()
})

test('opens command palette with keyboard shortcut', async ({ page }) => {
await page.goto('http://localhost:8892')

await pressShortcut(page, 'k')

await expect(page.locator('#command-palette-search-input')).toBeVisible()
await page.fill('#command-palette-search-input', 'echo')

// Command palette should be showing the echo parts
await expect(page.locator('[role="listbox"]').getByText('echo.EchoRequest', { exact: true })).toBeVisible()
await expect(page.locator('[role="listbox"]').getByText('echo.EchoResponse', { exact: true })).toBeVisible()
await expect(page.locator('[role="listbox"]').getByText('echo.echo', { exact: true })).toBeVisible()
})
13 changes: 0 additions & 13 deletions frontend/console/e2e/command-palette.ts

This file was deleted.

10 changes: 10 additions & 0 deletions frontend/console/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ export async function navigateToDecl(page: Page, moduleName: string, declName: s
await page.locator(`a#decl-${declName}`).click()
await expect(page).toHaveURL(new RegExp(`/modules/${moduleName}/verb/${declName}`))
}

export async function pressShortcut(page: Page, key: string) {
// Get the platform-specific modifier key
const isMac = await page.evaluate(() => navigator.userAgent.includes('Mac'))
const modifier = isMac ? 'Meta' : 'Control'

await page.keyboard.down(modifier)
await page.keyboard.press(key)
await page.keyboard.up(modifier)
}
Loading