pattern-flow.spec.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { test, expect } from '@playwright/test'
  2. import { setupApiMocks, resetMockStatus, getMockStatus } from './mocks/api'
  3. test.describe('Pattern Flow E2E', () => {
  4. test.beforeEach(async ({ page }) => {
  5. resetMockStatus()
  6. await setupApiMocks(page)
  7. })
  8. test('displays pattern list on browse page', async ({ page }) => {
  9. await page.goto('/')
  10. // Wait for patterns to load
  11. await expect(page.getByText('star.thr')).toBeVisible()
  12. await expect(page.getByText('spiral.thr')).toBeVisible()
  13. await expect(page.getByText('wave.thr')).toBeVisible()
  14. })
  15. test('can select pattern to view details', async ({ page }) => {
  16. await page.goto('/')
  17. // Wait for patterns to load
  18. await expect(page.getByText('star.thr')).toBeVisible()
  19. // Click on pattern
  20. await page.getByText('star.thr').click()
  21. // Detail panel should open (Sheet component)
  22. // Look for common detail panel indicators
  23. await expect(
  24. page.getByRole('dialog').or(page.locator('[data-state="open"]'))
  25. ).toBeVisible({ timeout: 5000 })
  26. })
  27. test('can run pattern and UI shows running state', async ({ page }) => {
  28. await page.goto('/')
  29. // Wait for patterns
  30. await expect(page.getByText('star.thr')).toBeVisible()
  31. // Click pattern to open detail
  32. await page.getByText('star.thr').click()
  33. // Wait for detail panel
  34. await page.waitForTimeout(500)
  35. // Find and click run button
  36. const runButton = page.getByRole('button', { name: /run|play/i }).first()
  37. await expect(runButton).toBeVisible()
  38. await runButton.click()
  39. // Verify API was called and status updated
  40. await page.waitForTimeout(500)
  41. const status = getMockStatus()
  42. expect(status.is_running).toBe(true)
  43. expect(status.current_file).toContain('star')
  44. })
  45. test('search filters patterns correctly', async ({ page }) => {
  46. await page.goto('/')
  47. // Wait for patterns
  48. await expect(page.getByText('star.thr')).toBeVisible()
  49. await expect(page.getByText('spiral.thr')).toBeVisible()
  50. // Type in search
  51. const searchInput = page.getByPlaceholder(/search/i)
  52. await searchInput.fill('spiral')
  53. // Only spiral should be visible
  54. await expect(page.getByText('spiral.thr')).toBeVisible()
  55. await expect(page.getByText('star.thr')).not.toBeVisible()
  56. })
  57. })