conversation-session-browser-use-iab-full-chain.json 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-browser-use-iab-full-chain",
  4. "spec": "./test/e2e/conversation-session/browser-use/conversation-session-browser-use-iab-full-chain.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "upstream-browser-use-iab-title",
  8. "description": "Browser Use case 内固定标题响应,避免异步标题请求污染主链 matcher。",
  9. "metadata": {
  10. "kind": "common",
  11. "timingPolicy": "fast-text",
  12. "source": "synthetic",
  13. "syntheticReason": "标题不是本用例产品语义,只需稳定返回并与 Browser tool continuation 隔离。"
  14. },
  15. "match": {
  16. "method": "POST",
  17. "pathIncludes": "/messages",
  18. "bodyIncludes": ["Generate a concise title", "E2E_BROWSER_USE_IAB_FULL_CHAIN"]
  19. },
  20. "response": {
  21. "statusCode": 200,
  22. "statusMessage": "OK",
  23. "headers": {
  24. "content-type": "application/json; charset=utf-8"
  25. },
  26. "body": "{\"id\":\"upstream-browser-use-iab-title\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\":\\\"Browser Use IAB\\\"}\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":64,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":8,\"service_tier\":\"standard\"}}"
  27. }
  28. },
  29. {
  30. "id": "upstream-browser-use-iab-bootstrap",
  31. "description": "在 fresh node_repl kernel 中初始化 Browser client,创建 IAB tab,导航本地 fixture,并把 stable tab id 与 DOM snapshot 返回模型。",
  32. "metadata": {
  33. "kind": "main",
  34. "timingPolicy": "fast-text",
  35. "source": "synthetic",
  36. "syntheticReason": "稳定驱动真实 BrowserControl 链路,并让下一次模型响应只能从真实 tool result 恢复 stable tab id。"
  37. },
  38. "maxMatches": 1,
  39. "match": {
  40. "method": "POST",
  41. "pathIncludes": "/messages",
  42. "lastUserMessageIncludes": ["E2E_BROWSER_USE_IAB_FULL_CHAIN", "E2E_BROWSER_FIXTURE_URL:"],
  43. "bodyIncludes": ["mcp__node_repl__js"],
  44. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  45. },
  46. "response": {
  47. "statusCode": 200,
  48. "toolUse": {
  49. "id": "toolu_e2e_browser_iab_bootstrap",
  50. "name": "mcp__node_repl__js",
  51. "input": {
  52. "code": "const browserPluginRoot = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!browserPluginRoot) throw new Error('Browser plugin root is unavailable in the node_repl host');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst browserClientUrl = pathToFileURL(join(browserPluginRoot, 'scripts', 'browser-client.mjs')).href;\nconst { setupBrowserRuntime } = await import(browserClientUrl);\nawait setupBrowserRuntime({ globals: globalThis });\nconst browser = await agent.browsers.get('iab');\nconst tab = await browser.tabs.new();\nawait tab.goto('{{browserFixtureUrl}}');\nawait tab.setViewportSize({ width: 375, height: 667 });\nconst snapshot = await tab.playwright.domSnapshot();\n({ marker: 'E2E_BROWSER_USE_IAB_BOOTSTRAP_OK', e2eBrowserTabId: tab.id, snapshot });",
  53. "title": "打开 Browser Use 测试页面"
  54. }
  55. }
  56. }
  57. },
  58. {
  59. "id": "upstream-browser-use-iab-action",
  60. "description": "在新的 fresh kernel 中重新初始化 Browser client,使用上一条 tool result 的动态 stable id 恢复 tab,再覆盖 locator、CUA、click 与截图。",
  61. "metadata": {
  62. "kind": "main",
  63. "timingPolicy": "fast-text",
  64. "source": "synthetic",
  65. "syntheticReason": "验证不依赖跨 cell binding 的 tab/page 连续性,同时稳定覆盖 actionability、trusted guest input、页面副作用、显式图片和 viewport 回读。"
  66. },
  67. "maxMatches": 1,
  68. "match": {
  69. "method": "POST",
  70. "pathIncludes": "/messages",
  71. "bodyIncludes": [
  72. "E2E_BROWSER_USE_IAB_FULL_CHAIN",
  73. "toolu_e2e_browser_iab_bootstrap",
  74. "E2E_BROWSER_USE_IAB_BOOTSTRAP_OK",
  75. "e2eBrowserTabId",
  76. "E2E Browser Use Fixture",
  77. "Submit"
  78. ],
  79. "bodyExcludes": [
  80. "Submitted ZCode",
  81. "Generate a concise title",
  82. "CRITICAL: Respond with TEXT ONLY"
  83. ]
  84. },
  85. "response": {
  86. "statusCode": 200,
  87. "toolUse": {
  88. "id": "toolu_e2e_browser_iab_action",
  89. "name": "mcp__node_repl__js",
  90. "input": {
  91. "code": "const browserPluginRoot = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!browserPluginRoot) throw new Error('Browser plugin root is unavailable in the node_repl host');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst browserClientUrl = pathToFileURL(join(browserPluginRoot, 'scripts', 'browser-client.mjs')).href;\nconst { setupBrowserRuntime } = await import(browserClientUrl);\nawait setupBrowserRuntime({ globals: globalThis });\nconst browser = await agent.browsers.get('iab');\nconst expectedTabId = '{{latestBrowserTabId}}';\nconst tab = await browser.tabs.get(expectedTabId);\nconst animatedInput = tab.playwright.getByLabel('Animated Name');\nconst sharedCount = await animatedInput.count();\nconst fillStartedAt = Date.now();\nawait animatedInput.fill('ZCode');\nconst fillCompletedBefore25s = Date.now() - fillStartedAt < 25000;\nlet strictMessage = '';\ntry {\n await tab.playwright.getByRole('button', { name: 'Duplicate' }).click();\n} catch (error) {\n strictMessage = error instanceof Error ? error.message : String(error);\n}\nlet overlayMessage = '';\ntry {\n await tab.playwright.locator('#covered-button').click();\n} catch (error) {\n overlayMessage = error instanceof Error ? error.message : String(error);\n}\nconst leakedInternalError = /AbortError|Cannot read properties of undefined|undefined.*count/i.test(strictMessage + '\\n' + overlayMessage);\nconst cuaInput = tab.playwright.getByLabel('CUA Name');\nawait cuaInput.click();\nawait new Promise((resolve) => setTimeout(resolve, 4000));\nawait tab.cua.type({ text: 'ZCode' });\nawait tab.playwright.getByRole('button', { name: 'Submit' }).click();\nfor (const width of [373, 374]) {\n await tab.setViewportSize({ width, height: 667 });\n await nodeRepl.emitImage(await tab.screenshot());\n}\nawait tab.setViewportSize({ width: 375, height: 667 });\nconst status = await tab.playwright.getByRole('status').innerText();\nconst guestMetrics = await tab.playwright.evaluate(() => ({ width: innerWidth, height: innerHeight, dpr: devicePixelRatio }));\nconst recoveredSameTab = tab.id === expectedTabId;\nconst allActionabilityChecksPassed = guestMetrics.width === 375 && guestMetrics.height === 667 && guestMetrics.dpr === 1 && recoveredSameTab && sharedCount === 2 && fillCompletedBefore25s && strictMessage.length > 0 && overlayMessage.length > 0 && !leakedInternalError && status === 'Submitted ZCode / ZCode';\n({\n marker: allActionabilityChecksPassed ? 'E2E_BROWSER_USE_IAB_ACTIONABILITY_OK' : 'E2E_BROWSER_USE_IAB_ACTIONABILITY_FAILED',\n recoveredSameTab,\n guestMetrics,\n sharedCount,\n fillCompletedBefore25s,\n strictRejected: strictMessage.length > 0,\n overlayRejected: overlayMessage.length > 0,\n leakedInternalError,\n animatedInputValue: await animatedInput.getAttribute('value'),\n inputValue: await cuaInput.getAttribute('value'),\n status,\n viewport: tab.viewportSize(),\n tabs: await browser.tabs.list()\n});",
  92. "title": "填写并截图 Browser Use 测试页面"
  93. }
  94. }
  95. }
  96. },
  97. {
  98. "id": "upstream-browser-use-iab-final",
  99. "description": "消费真实页面 action 与截图结果,正常完成 turn 以触发轮尾自动截图。",
  100. "metadata": {
  101. "kind": "main",
  102. "timingPolicy": "fast-text",
  103. "source": "synthetic",
  104. "syntheticReason": "稳定形成 normal completion,验证显式 emitImage 不抑制 Browser turn-end screenshot。"
  105. },
  106. "maxMatches": 1,
  107. "match": {
  108. "method": "POST",
  109. "pathIncludes": "/messages",
  110. "bodyIncludes": [
  111. "E2E_BROWSER_USE_IAB_FULL_CHAIN",
  112. "toolu_e2e_browser_iab_action",
  113. "E2E_BROWSER_USE_IAB_ACTIONABILITY_OK",
  114. "Submitted ZCode / ZCode"
  115. ],
  116. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  117. },
  118. "response": {
  119. "statusCode": 200,
  120. "text": "E2E_BROWSER_USE_IAB_DONE"
  121. }
  122. },
  123. {
  124. "id": "upstream-browser-use-iab-shot-title",
  125. "description": "轮尾截图用例的标题生成固定响应。",
  126. "metadata": {
  127. "kind": "common",
  128. "timingPolicy": "fast-text",
  129. "source": "synthetic",
  130. "syntheticReason": "标题不是本用例的产品语义;固定响应避免标题请求误命中主请求。"
  131. },
  132. "match": {
  133. "method": "POST",
  134. "pathIncludes": "/messages",
  135. "bodyIncludes": ["Generate a concise title", "E2E_BROWSER_USE_IAB_TURN_SHOT"]
  136. },
  137. "response": {
  138. "statusCode": 200,
  139. "text": "{\"title\":\"Browser Use Turn Shot\"}"
  140. }
  141. },
  142. {
  143. "id": "upstream-browser-use-iab-shot-open",
  144. "description": "轮尾截图用例:一次 Node REPL 调用打开测试页面。",
  145. "metadata": {
  146. "kind": "main",
  147. "timingPolicy": "fast-text",
  148. "source": "synthetic",
  149. "syntheticReason": "一轮只打开一次页面并正常完成,产生轮尾截图;冷恢复前后各续发一次,比较请求里的工具调用和已发送消息。"
  150. },
  151. "maxMatches": 1,
  152. "match": {
  153. "method": "POST",
  154. "pathIncludes": "/messages",
  155. "lastUserMessageIncludes": ["E2E_BROWSER_USE_IAB_TURN_SHOT", "E2E_BROWSER_FIXTURE_URL:"],
  156. "bodyIncludes": ["mcp__node_repl__js"],
  157. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  158. },
  159. "response": {
  160. "statusCode": 200,
  161. "toolUse": {
  162. "id": "toolu_e2e_browser_iab_shot_open",
  163. "name": "mcp__node_repl__js",
  164. "input": {
  165. "code": "const browserPluginRoot = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!browserPluginRoot) throw new Error('Browser plugin root is unavailable in the node_repl host');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst browserClientUrl = pathToFileURL(join(browserPluginRoot, 'scripts', 'browser-client.mjs')).href;\nconst { setupBrowserRuntime } = await import(browserClientUrl);\nawait setupBrowserRuntime({ globals: globalThis });\nconst browser = await agent.browsers.get('iab');\nconst tab = await browser.tabs.new();\nawait tab.goto('{{browserFixtureUrl}}');\n({ marker: 'E2E_BROWSER_USE_IAB_SHOT_OPEN_OK', e2eBrowserTabId: tab.id });",
  166. "title": "打开轮尾截图测试页面"
  167. }
  168. }
  169. }
  170. },
  171. {
  172. "id": "upstream-browser-use-iab-shot-final",
  173. "description": "轮尾截图用例:页面打开后正常完成,触发轮尾截图。",
  174. "metadata": {
  175. "kind": "main",
  176. "timingPolicy": "fast-text",
  177. "source": "synthetic",
  178. "syntheticReason": "一轮只打开一次页面并正常完成,产生轮尾截图;冷恢复前后各续发一次,比较请求里的工具调用和已发送消息。"
  179. },
  180. "maxMatches": 1,
  181. "match": {
  182. "method": "POST",
  183. "pathIncludes": "/messages",
  184. "bodyIncludes": [
  185. "E2E_BROWSER_USE_IAB_TURN_SHOT",
  186. "toolu_e2e_browser_iab_shot_open",
  187. "E2E_BROWSER_USE_IAB_SHOT_OPEN_OK"
  188. ],
  189. "bodyExcludes": [
  190. "Generate a concise title",
  191. "CRITICAL: Respond with TEXT ONLY",
  192. "E2E_BROWSER_USE_IAB_SHOT_FOLLOW"
  193. ]
  194. },
  195. "response": {
  196. "statusCode": 200,
  197. "text": "E2E_BROWSER_USE_IAB_SHOT_DONE"
  198. }
  199. },
  200. {
  201. "id": "upstream-browser-use-iab-shot-follow-live",
  202. "description": "轮尾截图用例冷恢复前的续发。",
  203. "metadata": {
  204. "kind": "main",
  205. "timingPolicy": "fast-text",
  206. "source": "synthetic",
  207. "syntheticReason": "一轮只打开一次页面并正常完成,产生轮尾截图;冷恢复前后各续发一次,比较请求里的工具调用和已发送消息。"
  208. },
  209. "maxMatches": 1,
  210. "match": {
  211. "method": "POST",
  212. "pathIncludes": "/messages",
  213. "lastUserMessageIncludes": ["E2E_BROWSER_USE_IAB_SHOT_FOLLOW_LIVE"],
  214. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  215. },
  216. "response": {
  217. "statusCode": 200,
  218. "text": "E2E_BROWSER_USE_IAB_SHOT_FOLLOW_LIVE_DONE"
  219. }
  220. },
  221. {
  222. "id": "upstream-browser-use-iab-shot-follow-cold",
  223. "description": "轮尾截图用例冷恢复后的续发。",
  224. "metadata": {
  225. "kind": "main",
  226. "timingPolicy": "fast-text",
  227. "source": "synthetic",
  228. "syntheticReason": "一轮只打开一次页面并正常完成,产生轮尾截图;冷恢复前后各续发一次,比较请求里的工具调用和已发送消息。"
  229. },
  230. "maxMatches": 1,
  231. "match": {
  232. "method": "POST",
  233. "pathIncludes": "/messages",
  234. "lastUserMessageIncludes": ["E2E_BROWSER_USE_IAB_SHOT_FOLLOW_COLD"],
  235. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  236. },
  237. "response": {
  238. "statusCode": 200,
  239. "text": "E2E_BROWSER_USE_IAB_SHOT_FOLLOW_COLD_DONE"
  240. }
  241. }
  242. ]
  243. }