pattern-flow.spec.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. // The sheet contains a "Play" button with exact text (not "Play Next")
  23. await expect(page.getByRole('button', { name: 'play_arrow Play' })).toBeVisible({ timeout: 5000 })
  24. })
  25. test('can run pattern and UI shows running state', async ({ page }) => {
  26. await page.goto('/')
  27. // Wait for patterns
  28. await expect(page.getByText('star.thr')).toBeVisible()
  29. // Click pattern to open detail
  30. await page.getByText('star.thr').click()
  31. // Wait for detail panel
  32. await page.waitForTimeout(500)
  33. // Find and click run button
  34. const runButton = page.getByRole('button', { name: /run|play/i }).first()
  35. await expect(runButton).toBeVisible()
  36. await runButton.click()
  37. // Verify API was called and status updated
  38. await page.waitForTimeout(500)
  39. const status = getMockStatus()
  40. expect(status.is_running).toBe(true)
  41. expect(status.current_file).toContain('star')
  42. })
  43. test('search filters patterns correctly', async ({ page }) => {
  44. await page.goto('/')
  45. // Wait for patterns
  46. await expect(page.getByText('star.thr')).toBeVisible()
  47. await expect(page.getByText('spiral.thr')).toBeVisible()
  48. // Type in search
  49. const searchInput = page.getByPlaceholder(/search/i)
  50. await searchInput.fill('spiral')
  51. // Only spiral should be visible
  52. await expect(page.getByText('spiral.thr')).toBeVisible()
  53. await expect(page.getByText('star.thr')).not.toBeVisible()
  54. })
  55. })