session-timeline-context-state.spec.ts 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. import { expect, test } from "@playwright/test"
  2. import {
  3. assistantMessage,
  4. partUpdated,
  5. setupTimeline,
  6. toolPart,
  7. userMessage,
  8. } from "../performance/timeline-stability/fixture"
  9. test("preserves a collapsed context group through count and status updates", async ({ page }) => {
  10. const ids = ["prt_closed_01_read", "prt_closed_02_glob"]
  11. const inputs = {
  12. read: { filePath: "src/a.ts", offset: 0, limit: 120 },
  13. glob: { path: ".", pattern: "**/*.ts" },
  14. }
  15. const timeline = await setupTimeline(page, {
  16. messages: [
  17. userMessage(),
  18. assistantMessage(
  19. [toolPart(ids[0]!, "read", "running", inputs.read), toolPart(ids[1]!, "glob", "running", inputs.glob)],
  20. { completed: false },
  21. ),
  22. ],
  23. })
  24. const group = page.locator(`[data-timeline-part-ids="${ids.join(",")}"]`)
  25. const trigger = group.locator('[data-slot="collapsible-trigger"]')
  26. await expect(trigger).toHaveAttribute("aria-expanded", "false")
  27. await timeline.send(partUpdated(toolPart(ids[0]!, "read", "completed", inputs.read)), 100)
  28. await timeline.send(partUpdated(toolPart(ids[1]!, "glob", "completed", inputs.glob)), 300)
  29. await expect(trigger).toHaveAttribute("aria-expanded", "false")
  30. })