settings.spec.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { test, expect } from "./fixtures"
  2. import { modKey } from "./utils"
  3. test("smoke settings dialog opens, switches tabs, closes", 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: "Shortcuts" }).click()
  16. await expect(dialog.getByRole("button", { name: "Reset to defaults" })).toBeVisible()
  17. await expect(dialog.getByPlaceholder("Search shortcuts")).toBeVisible()
  18. await page.keyboard.press("Escape")
  19. const closed = await dialog
  20. .waitFor({ state: "detached", timeout: 1500 })
  21. .then(() => true)
  22. .catch(() => false)
  23. if (closed) return
  24. await page.keyboard.press("Escape")
  25. const closedSecond = await dialog
  26. .waitFor({ state: "detached", timeout: 1500 })
  27. .then(() => true)
  28. .catch(() => false)
  29. if (closedSecond) return
  30. await page.locator('[data-component="dialog-overlay"]').click({ position: { x: 5, y: 5 } })
  31. await expect(dialog).toHaveCount(0)
  32. })