Files
resolutionflow/frontend/e2e/command-palette.spec.ts
chihlasm d71638ffb4 test: add Playwright e2e tests for new features and uncovered workflows
High priority (new PR #108 features):
- Command palette: open/close, search flows, page navigation, FlowPilot handoff
- Fallback branches: add in editor, execute in session runner
- Session-to-flow: verify button appears on completed session detail

Medium priority (existing features without coverage):
- Procedural session: intake form, step-through, completion
- Tree editor: troubleshooting and procedural editor load/edit/save
- FlowPilot chat: page load, new chat creation
- Admin panel: dashboard, user management, settings access

Also adds API helpers: createProceduralTree(), createProceduralTreeWithFallbacks()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 02:48:57 -04:00

95 lines
3.1 KiB
TypeScript

import { expect, test } from '@playwright/test'
import {
createAuthenticatedApiContext,
createTroubleshootingTree,
disposeApiContext,
uniqueName,
} from './helpers/api'
test.describe('command palette smoke tests', () => {
test('opens with Cmd+K and shows empty state with quick actions', async ({ page }) => {
await page.goto('/')
await expect(page.getByTestId('app-shell')).toBeVisible()
// Open command palette with keyboard shortcut
await page.keyboard.press('Meta+k')
// Should show the palette modal
const palette = page.locator('[class*="fixed"][class*="z-"]').filter({ hasText: 'Quick Actions' })
await expect(palette).toBeVisible()
// Empty state should show quick actions, no FlowPilot
await expect(palette.getByText('Quick Actions')).toBeVisible()
await expect(palette.getByText('FlowPilot AI')).not.toBeVisible()
// Close with Escape
await page.keyboard.press('Escape')
await expect(palette).not.toBeVisible()
})
test('searches flows and shows results grouped by category', async ({ page }) => {
const api = await createAuthenticatedApiContext()
const tree = await createTroubleshootingTree(api, {
name: uniqueName('PW Palette Search Flow'),
})
try {
await page.goto('/')
await expect(page.getByTestId('app-shell')).toBeVisible()
await page.keyboard.press('Meta+k')
// Type a search query matching the flow name
const input = page.getByPlaceholder(/Search flows/)
await input.fill('PW Palette Search')
// Should show FlowPilot AI section and Flows section
await expect(page.getByText('FlowPilot AI')).toBeVisible({ timeout: 5000 })
await expect(page.getByText('Flows')).toBeVisible()
await expect(page.getByText(tree.name)).toBeVisible()
} finally {
await disposeApiContext(api)
}
})
test('navigates to a page when typing a page name', async ({ page }) => {
await page.goto('/')
await expect(page.getByTestId('app-shell')).toBeVisible()
await page.keyboard.press('Meta+k')
const input = page.getByPlaceholder(/Search flows/)
await input.fill('analytics')
// Pages section should appear
await expect(page.getByText('Pages')).toBeVisible({ timeout: 3000 })
await expect(page.getByText('Analytics')).toBeVisible()
// Select the analytics page
await page.getByText('Analytics').click()
await expect(page).toHaveURL(/\/analytics/)
})
test('FlowPilot option navigates to assistant chat with prefilled query', async ({ page }) => {
await page.goto('/')
await expect(page.getByTestId('app-shell')).toBeVisible()
await page.keyboard.press('Meta+k')
const input = page.getByPlaceholder(/Search flows/)
await input.fill('how do I fix a print spooler issue')
// FlowPilot should be prominent (question intent)
await expect(page.getByText('FlowPilot AI')).toBeVisible({ timeout: 3000 })
const flowpilotOption = page.getByText('Ask FlowPilot')
await expect(flowpilotOption).toBeVisible()
// Select FlowPilot
await flowpilotOption.click()
// Should navigate to assistant chat page
await expect(page).toHaveURL(/\/assistant/)
})
})