session-child-navigation.spec.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { seedSessionTask, withSession } from "../actions"
  2. import { test, expect } from "../fixtures"
  3. import { inputMatch } from "../prompt/mock"
  4. import { promptSelector } from "../selectors"
  5. test("task tool child-session link does not trigger stale show errors", async ({ page, llm, project }) => {
  6. test.setTimeout(120_000)
  7. const errs: string[] = []
  8. const onError = (err: Error) => {
  9. errs.push(err.message)
  10. }
  11. page.on("pageerror", onError)
  12. try {
  13. await project.open()
  14. await withSession(project.sdk, `e2e child nav ${Date.now()}`, async (session) => {
  15. const taskInput = {
  16. description: "Open child session",
  17. prompt: "Search the repository for AssistantParts and then reply with exactly CHILD_OK.",
  18. subagent_type: "general",
  19. }
  20. await llm.toolMatch(inputMatch(taskInput), "task", taskInput)
  21. const child = await seedSessionTask(project.sdk, {
  22. sessionID: session.id,
  23. description: taskInput.description,
  24. prompt: taskInput.prompt,
  25. })
  26. project.trackSession(child.sessionID)
  27. await project.gotoSession(session.id)
  28. const link = page
  29. .locator("a.subagent-link")
  30. .filter({ hasText: /open child session/i })
  31. .first()
  32. await expect(link).toBeVisible({ timeout: 30_000 })
  33. await link.click()
  34. await expect(page).toHaveURL(new RegExp(`/session/${child.sessionID}(?:[/?#]|$)`), { timeout: 30_000 })
  35. await expect(page.locator(promptSelector)).toBeVisible({ timeout: 30_000 })
  36. await expect.poll(() => errs, { timeout: 5_000 }).toEqual([])
  37. })
  38. } finally {
  39. page.off("pageerror", onError)
  40. }
  41. })