settings-providers.spec.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { test, expect } from "./fixtures"
  2. import { modKey, promptSelector } from "./utils"
  3. test("smoke providers settings opens provider selector", async ({ page, gotoSession }) => {
  4. await gotoSession()
  5. const dialog = page.getByRole("dialog")
  6. await page.keyboard.press(`${modKey}+Comma`).catch(() => undefined)
  7. const opened = await dialog
  8. .waitFor({ state: "visible", timeout: 3000 })
  9. .then(() => true)
  10. .catch(() => false)
  11. if (!opened) {
  12. await page.getByRole("button", { name: "Settings" }).first().click()
  13. await expect(dialog).toBeVisible()
  14. }
  15. await dialog.getByRole("tab", { name: "Providers" }).click()
  16. await expect(dialog.getByText("Connected providers", { exact: true })).toBeVisible()
  17. await expect(dialog.getByText("Popular providers", { exact: true })).toBeVisible()
  18. await dialog.getByRole("button", { name: "Show more providers" }).click()
  19. const providerDialog = page.getByRole("dialog").filter({ has: page.getByPlaceholder("Search providers") })
  20. await expect(providerDialog).toBeVisible()
  21. await expect(providerDialog.getByPlaceholder("Search providers")).toBeVisible()
  22. await expect(providerDialog.locator('[data-slot="list-item"]').first()).toBeVisible()
  23. await page.keyboard.press("Escape")
  24. await expect(providerDialog).toHaveCount(0)
  25. await expect(page.locator(promptSelector)).toBeVisible()
  26. const stillOpen = await dialog.isVisible().catch(() => false)
  27. if (!stillOpen) return
  28. await page.keyboard.press("Escape")
  29. const closed = await dialog
  30. .waitFor({ state: "detached", timeout: 1500 })
  31. .then(() => true)
  32. .catch(() => false)
  33. if (closed) return
  34. await page.keyboard.press("Escape")
  35. const closedSecond = await dialog
  36. .waitFor({ state: "detached", timeout: 1500 })
  37. .then(() => true)
  38. .catch(() => false)
  39. if (closedSecond) return
  40. await page.locator('[data-component="dialog-overlay"]').click({ position: { x: 5, y: 5 } })
  41. await expect(dialog).toHaveCount(0)
  42. })