panels.spec.ts 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. import { test, expect } from "../fixtures"
  2. import { modKey } from "../utils"
  3. const expanded = async (el: { getAttribute: (name: string) => Promise<string | null> }) => {
  4. const value = await el.getAttribute("aria-expanded")
  5. if (value !== "true" && value !== "false") throw new Error(`Expected aria-expanded to be true|false, got: ${value}`)
  6. return value === "true"
  7. }
  8. test("review panel can be toggled via keybind", async ({ page, gotoSession }) => {
  9. await gotoSession()
  10. const treeToggle = page.getByRole("button", { name: "Toggle file tree" }).first()
  11. await expect(treeToggle).toBeVisible()
  12. if (await expanded(treeToggle)) await treeToggle.click()
  13. await expect(treeToggle).toHaveAttribute("aria-expanded", "false")
  14. const reviewToggle = page.getByRole("button", { name: "Toggle review" }).first()
  15. await expect(reviewToggle).toBeVisible()
  16. if (await expanded(reviewToggle)) await reviewToggle.click()
  17. await expect(reviewToggle).toHaveAttribute("aria-expanded", "false")
  18. await expect(page.locator("#review-panel")).toHaveCount(0)
  19. await page.keyboard.press(`${modKey}+Shift+R`)
  20. await expect(reviewToggle).toHaveAttribute("aria-expanded", "true")
  21. await expect(page.locator("#review-panel")).toBeVisible()
  22. await page.keyboard.press(`${modKey}+Shift+R`)
  23. await expect(reviewToggle).toHaveAttribute("aria-expanded", "false")
  24. await expect(page.locator("#review-panel")).toHaveCount(0)
  25. })