models-visibility.spec.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { test, expect } from "../fixtures"
  2. import { promptSelector } from "../selectors"
  3. import { closeDialog, openSettings, clickListItem } from "../actions"
  4. test("hiding a model removes it from the model picker", async ({ page, gotoSession }) => {
  5. await gotoSession()
  6. await page.locator(promptSelector).click()
  7. await page.keyboard.type("/model")
  8. const command = page.locator('[data-slash-id="model.choose"]')
  9. await expect(command).toBeVisible()
  10. await command.hover()
  11. await page.keyboard.press("Enter")
  12. const picker = page.getByRole("dialog")
  13. await expect(picker).toBeVisible()
  14. const target = picker.locator('[data-slot="list-item"]').first()
  15. await expect(target).toBeVisible()
  16. const key = await target.getAttribute("data-key")
  17. if (!key) throw new Error("Failed to resolve model key from list item")
  18. const name = (await target.locator("span").first().innerText()).trim()
  19. if (!name) throw new Error("Failed to resolve model name from list item")
  20. await page.keyboard.press("Escape")
  21. await expect(picker).toHaveCount(0)
  22. const settings = await openSettings(page)
  23. await settings.getByRole("tab", { name: "Models" }).click()
  24. const search = settings.getByPlaceholder("Search models")
  25. await expect(search).toBeVisible()
  26. await search.fill(name)
  27. const toggle = settings.locator('[data-component="switch"]').filter({ hasText: name }).first()
  28. const input = toggle.locator('[data-slot="switch-input"]')
  29. await expect(toggle).toBeVisible()
  30. await expect(input).toHaveAttribute("aria-checked", "true")
  31. await toggle.locator('[data-slot="switch-control"]').click()
  32. await expect(input).toHaveAttribute("aria-checked", "false")
  33. await closeDialog(page, settings)
  34. await page.locator(promptSelector).click()
  35. await page.keyboard.type("/model")
  36. await expect(command).toBeVisible()
  37. await command.hover()
  38. await page.keyboard.press("Enter")
  39. const pickerAgain = page.getByRole("dialog")
  40. await expect(pickerAgain).toBeVisible()
  41. await expect(pickerAgain.locator('[data-slot="list-item"]').first()).toBeVisible()
  42. await expect(pickerAgain.locator(`[data-slot="list-item"][data-key="${key}"]`)).toHaveCount(0)
  43. await page.keyboard.press("Escape")
  44. await expect(pickerAgain).toHaveCount(0)
  45. })