model-picker.spec.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { test, expect } from "../fixtures"
  2. import { promptSelector } from "../selectors"
  3. import { clickListItem } from "../actions"
  4. test("smoke model selection updates prompt footer", 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 dialog = page.getByRole("dialog")
  13. await expect(dialog).toBeVisible()
  14. const input = dialog.getByRole("textbox").first()
  15. const selected = dialog.locator('[data-slot="list-item"][data-selected="true"]').first()
  16. await expect(selected).toBeVisible()
  17. const other = dialog.locator('[data-slot="list-item"]:not([data-selected="true"])').first()
  18. const target = (await other.count()) > 0 ? other : selected
  19. const key = await target.getAttribute("data-key")
  20. if (!key) throw new Error("Failed to resolve model key from list item")
  21. const name = (await target.locator("span").first().innerText()).trim()
  22. const model = key.split(":").slice(1).join(":")
  23. await input.fill(model)
  24. await clickListItem(dialog, { key })
  25. await expect(dialog).toHaveCount(0)
  26. const form = page.locator(promptSelector).locator("xpath=ancestor::form[1]")
  27. await expect(form.locator('[data-component="button"]').filter({ hasText: name }).first()).toBeVisible()
  28. })