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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-browser-use-iab-full-chain",
  4. "spec": "./test/e2e/conversation-session/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": [
  19. "Generate a concise title",
  20. "E2E_BROWSER_USE_IAB_FULL_CHAIN"
  21. ]
  22. },
  23. "response": {
  24. "statusCode": 200,
  25. "statusMessage": "OK",
  26. "headers": {
  27. "content-type": "application/json; charset=utf-8"
  28. },
  29. "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\"}}"
  30. }
  31. },
  32. {
  33. "id": "upstream-browser-use-iab-bootstrap",
  34. "description": "在 fresh node_repl kernel 中初始化 Browser client,创建 IAB tab,导航本地 fixture,并把 stable tab id 与 DOM snapshot 返回模型。",
  35. "metadata": {
  36. "kind": "main",
  37. "timingPolicy": "fast-text",
  38. "source": "synthetic",
  39. "syntheticReason": "稳定驱动真实 BrowserControl 链路,并让下一次模型响应只能从真实 tool result 恢复 stable tab id。"
  40. },
  41. "maxMatches": 1,
  42. "match": {
  43. "method": "POST",
  44. "pathIncludes": "/messages",
  45. "lastUserMessageIncludes": [
  46. "E2E_BROWSER_USE_IAB_FULL_CHAIN",
  47. "E2E_BROWSER_FIXTURE_URL:"
  48. ],
  49. "bodyIncludes": ["mcp__node_repl__js"],
  50. "bodyExcludes": [
  51. "Generate a concise title",
  52. "CRITICAL: Respond with TEXT ONLY"
  53. ]
  54. },
  55. "response": {
  56. "statusCode": 200,
  57. "toolUse": {
  58. "id": "toolu_e2e_browser_iab_bootstrap",
  59. "name": "mcp__node_repl__js",
  60. "input": {
  61. "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 });",
  62. "title": "打开 Browser Use 测试页面"
  63. }
  64. }
  65. }
  66. },
  67. {
  68. "id": "upstream-browser-use-iab-action",
  69. "description": "在新的 fresh kernel 中重新初始化 Browser client,使用上一条 tool result 的动态 stable id 恢复 tab,再覆盖 locator、CUA、click 与截图。",
  70. "metadata": {
  71. "kind": "main",
  72. "timingPolicy": "fast-text",
  73. "source": "synthetic",
  74. "syntheticReason": "验证不依赖跨 cell binding 的 tab/page 连续性,同时稳定覆盖 actionability、trusted guest input、页面副作用、显式图片和 viewport 回读。"
  75. },
  76. "maxMatches": 1,
  77. "match": {
  78. "method": "POST",
  79. "pathIncludes": "/messages",
  80. "bodyIncludes": [
  81. "E2E_BROWSER_USE_IAB_FULL_CHAIN",
  82. "toolu_e2e_browser_iab_bootstrap",
  83. "E2E_BROWSER_USE_IAB_BOOTSTRAP_OK",
  84. "e2eBrowserTabId",
  85. "E2E Browser Use Fixture",
  86. "Submit"
  87. ],
  88. "bodyExcludes": [
  89. "Submitted ZCode",
  90. "Generate a concise title",
  91. "CRITICAL: Respond with TEXT ONLY"
  92. ]
  93. },
  94. "response": {
  95. "statusCode": 200,
  96. "toolUse": {
  97. "id": "toolu_e2e_browser_iab_action",
  98. "name": "mcp__node_repl__js",
  99. "input": {
  100. "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 recoveredSameTab = tab.id === expectedTabId;\nconst allActionabilityChecksPassed = 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 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});",
  101. "title": "填写并截图 Browser Use 测试页面"
  102. }
  103. }
  104. }
  105. },
  106. {
  107. "id": "upstream-browser-use-iab-final",
  108. "description": "消费真实页面 action 与截图结果,正常完成 turn 以触发轮尾自动截图。",
  109. "metadata": {
  110. "kind": "main",
  111. "timingPolicy": "fast-text",
  112. "source": "synthetic",
  113. "syntheticReason": "稳定形成 normal completion,验证显式 emitImage 不抑制 Browser turn-end screenshot。"
  114. },
  115. "maxMatches": 1,
  116. "match": {
  117. "method": "POST",
  118. "pathIncludes": "/messages",
  119. "bodyIncludes": [
  120. "E2E_BROWSER_USE_IAB_FULL_CHAIN",
  121. "toolu_e2e_browser_iab_action",
  122. "E2E_BROWSER_USE_IAB_ACTIONABILITY_OK",
  123. "Submitted ZCode / ZCode"
  124. ],
  125. "bodyExcludes": [
  126. "Generate a concise title",
  127. "CRITICAL: Respond with TEXT ONLY"
  128. ]
  129. },
  130. "response": {
  131. "statusCode": 200,
  132. "text": "E2E_BROWSER_USE_IAB_DONE"
  133. }
  134. }
  135. ]
  136. }