model-picker.spec.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { test, expect } from "./fixtures"
  2. import { promptSelector } from "./utils"
  3. test("smoke model selection updates prompt footer", async ({ page, gotoSession }) => {
  4. await gotoSession()
  5. await page.locator(promptSelector).click()
  6. await page.keyboard.type("/model")
  7. const command = page.locator('[data-slash-id="model.choose"]')
  8. await expect(command).toBeVisible()
  9. await command.hover()
  10. await page.keyboard.press("Enter")
  11. const dialog = page.getByRole("dialog")
  12. await expect(dialog).toBeVisible()
  13. const input = dialog.getByRole("textbox").first()
  14. const selected = dialog.locator('[data-slot="list-item"][data-selected="true"]').first()
  15. await expect(selected).toBeVisible()
  16. const other = dialog.locator('[data-slot="list-item"]:not([data-selected="true"])').first()
  17. const target = (await other.count()) > 0 ? other : selected
  18. const key = await target.getAttribute("data-key")
  19. if (!key) throw new Error("Failed to resolve model key from list item")
  20. const name = (await target.locator("span").first().innerText()).trim()
  21. const model = key.split(":").slice(1).join(":")
  22. await input.fill(model)
  23. const item = dialog.locator(`[data-slot="list-item"][data-key="${key}"]`)
  24. await expect(item).toBeVisible()
  25. await item.click()
  26. await expect(dialog).toHaveCount(0)
  27. const form = page.locator(promptSelector).locator("xpath=ancestor::form[1]")
  28. await expect(form.locator('[data-component="button"]').filter({ hasText: name }).first()).toBeVisible()
  29. })