tab-close.spec.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import { test, expect } from "../fixtures"
  2. import { promptSelector } from "../selectors"
  3. import { modKey } from "../utils"
  4. test("mod+w closes the active file tab", async ({ page, gotoSession }) => {
  5. await gotoSession()
  6. await page.locator(promptSelector).click()
  7. await page.keyboard.type("/open")
  8. await expect(page.locator('[data-slash-id="file.open"]').first()).toBeVisible()
  9. await page.keyboard.press("Enter")
  10. const dialog = page
  11. .getByRole("dialog")
  12. .filter({ has: page.getByPlaceholder(/search files/i) })
  13. .first()
  14. await expect(dialog).toBeVisible()
  15. await dialog.getByRole("textbox").first().fill("package.json")
  16. const item = dialog.locator('[data-slot="list-item"][data-key^="file:"]').first()
  17. await expect(item).toBeVisible({ timeout: 30_000 })
  18. await item.click()
  19. await expect(dialog).toHaveCount(0)
  20. const tab = page.getByRole("tab", { name: "package.json" }).first()
  21. await expect(tab).toBeVisible()
  22. await tab.click()
  23. await expect(tab).toHaveAttribute("aria-selected", "true")
  24. await page.keyboard.press(`${modKey}+W`)
  25. await expect(page.getByRole("tab", { name: "package.json" })).toHaveCount(0)
  26. })