context.spec.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { test, expect } from "./fixtures"
  2. import { promptSelector } from "./utils"
  3. test("context panel can be opened from the prompt", async ({ page, sdk, gotoSession }) => {
  4. const title = `e2e smoke context ${Date.now()}`
  5. const created = await sdk.session.create({ title }).then((r) => r.data)
  6. if (!created?.id) throw new Error("Session create did not return an id")
  7. const sessionID = created.id
  8. try {
  9. await sdk.session.promptAsync({
  10. sessionID,
  11. noReply: true,
  12. parts: [
  13. {
  14. type: "text",
  15. text: "seed context",
  16. },
  17. ],
  18. })
  19. await expect
  20. .poll(async () => {
  21. const messages = await sdk.session.messages({ sessionID, limit: 1 }).then((r) => r.data ?? [])
  22. return messages.length
  23. })
  24. .toBeGreaterThan(0)
  25. await gotoSession(sessionID)
  26. const contextButton = page
  27. .locator('[data-component="button"]')
  28. .filter({ has: page.locator('[data-component="progress-circle"]').first() })
  29. .first()
  30. await expect(contextButton).toBeVisible()
  31. await contextButton.click()
  32. const tabs = page.locator('[data-component="tabs"][data-variant="normal"]')
  33. await expect(tabs.getByRole("tab", { name: "Context" })).toBeVisible()
  34. } finally {
  35. await sdk.session.delete({ sessionID }).catch(() => undefined)
  36. }
  37. })