conversation-session-node-repl-frontend-restart.json 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-node-repl-frontend-restart",
  4. "spec": "./test/e2e/conversation-session/browser-use/conversation-session-node-repl-frontend-restart.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "node-repl-frontend-restart-title",
  8. "description": "固定 frontend 重启 case 的异步标题响应。",
  9. "metadata": {
  10. "kind": "common",
  11. "timingPolicy": "fast-text",
  12. "source": "synthetic",
  13. "syntheticReason": "标题不属于本用例语义,只需避免误命中主请求。"
  14. },
  15. "maxMatches": 1,
  16. "match": {
  17. "method": "POST",
  18. "pathIncludes": "/messages",
  19. "bodyIncludes": ["Generate a concise title", "E2E_NODE_REPL_FRONTEND_RESTART_WARMUP"]
  20. },
  21. "response": {
  22. "statusCode": 200,
  23. "statusMessage": "OK",
  24. "headers": {
  25. "content-type": "application/json; charset=utf-8"
  26. },
  27. "body": "{\"id\":\"upstream-node-repl-frontend-restart-title\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\": \\\"Node REPL 重启\\\"}\"}],\"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\"}}"
  28. }
  29. },
  30. {
  31. "id": "node-repl-frontend-restart-warmup",
  32. "description": "预热轮只返回文本,让会话先启动并连上 node_repl。",
  33. "metadata": {
  34. "kind": "main",
  35. "timingPolicy": "fast-text",
  36. "source": "synthetic",
  37. "syntheticReason": "MCP 异步启动时首个请求可能早于 node_repl 连上;预热轮把这段时序移出本 case。"
  38. },
  39. "maxMatches": 1,
  40. "match": {
  41. "method": "POST",
  42. "pathIncludes": "/messages",
  43. "lastUserMessageIncludes": ["E2E_NODE_REPL_FRONTEND_RESTART_WARMUP"],
  44. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  45. },
  46. "response": {
  47. "statusCode": 200,
  48. "text": "E2E_NODE_REPL_FRONTEND_RESTART_WARMUP_DONE"
  49. }
  50. },
  51. {
  52. "id": "node-repl-frontend-restart-setup",
  53. "description": "首轮调用 node_repl 创建真实 IAB tab、打开 fixture 页并写入 state,返回稳定 tab id。",
  54. "metadata": {
  55. "kind": "main",
  56. "timingPolicy": "fast-text",
  57. "source": "synthetic",
  58. "syntheticReason": "稳定构造 frontend 重启前的 tab/page 状态。"
  59. },
  60. "maxMatches": 1,
  61. "match": {
  62. "method": "POST",
  63. "pathIncludes": "/messages",
  64. "lastUserMessageIncludes": [
  65. "E2E_NODE_REPL_FRONTEND_RESTART_TURN_1",
  66. "E2E_BROWSER_FIXTURE_URL:"
  67. ],
  68. "bodyIncludes": ["mcp__node_repl__js"],
  69. "bodyExcludes": [
  70. "toolu_e2e_node_repl_frontend_restart_setup",
  71. "Generate a concise title",
  72. "CRITICAL: Respond with TEXT ONLY"
  73. ]
  74. },
  75. "response": {
  76. "statusCode": 200,
  77. "toolUse": {
  78. "id": "toolu_e2e_node_repl_frontend_restart_setup",
  79. "name": "mcp__node_repl__js",
  80. "input": {
  81. "title": "创建重启前的 Browser tab",
  82. "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 { setupBrowserRuntime } = await import(pathToFileURL(join(browserPluginRoot, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst browser = await agent.browsers.get('iab');\nconst tab = await browser.tabs.new();\nawait tab.goto(new URL('/restart', '{{browserFixtureUrl}}').href);\nawait tab.playwright.getByLabel('State').fill('before-restart');\nconst tabs = await browser.tabs.list();\nconst setupOk = tabs.length === 1 && tabs[0]?.id === tab.id;\n({ marker: setupOk ? 'E2E_NODE_REPL_FRONTEND_RESTART_SETUP_OK' : 'E2E_NODE_REPL_FRONTEND_RESTART_SETUP_FAILED', e2eBrowserTabId: tab.id, count: tabs.length });"
  83. }
  84. }
  85. }
  86. },
  87. {
  88. "id": "node-repl-frontend-restart-setup-final",
  89. "description": "首轮在 tab 创建成功后完成。",
  90. "metadata": {
  91. "kind": "main",
  92. "timingPolicy": "fast-text",
  93. "source": "synthetic",
  94. "syntheticReason": "形成 frontend 终止前的 turn 边界。"
  95. },
  96. "maxMatches": 1,
  97. "match": {
  98. "method": "POST",
  99. "pathIncludes": "/messages",
  100. "bodyIncludes": [
  101. "E2E_NODE_REPL_FRONTEND_RESTART_TURN_1",
  102. "toolu_e2e_node_repl_frontend_restart_setup"
  103. ],
  104. "lastUserMessageIncludes": ["E2E_NODE_REPL_FRONTEND_RESTART_SETUP_OK"],
  105. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  106. },
  107. "response": {
  108. "statusCode": 200,
  109. "text": "E2E_NODE_REPL_FRONTEND_RESTART_SETUP_DONE"
  110. }
  111. },
  112. {
  113. "id": "node-repl-frontend-restart-verify",
  114. "description": "frontend 重启后的下一轮按上一条 tool result 的稳定 id 取回原 tab,读取并更新页面 state。",
  115. "metadata": {
  116. "kind": "main",
  117. "timingPolicy": "fast-text",
  118. "source": "synthetic",
  119. "syntheticReason": "验证重启后 js 仍在工具列表里且可调用,tab/page 状态连续;tab id 从真实 tool result 动态注入。"
  120. },
  121. "maxMatches": 1,
  122. "match": {
  123. "method": "POST",
  124. "pathIncludes": "/messages",
  125. "lastUserMessageIncludes": ["E2E_NODE_REPL_FRONTEND_RESTART_TURN_2"],
  126. "bodyIncludes": ["mcp__node_repl__js", "toolu_e2e_node_repl_frontend_restart_setup"],
  127. "bodyExcludes": [
  128. "toolu_e2e_node_repl_frontend_restart_verify",
  129. "Generate a concise title",
  130. "CRITICAL: Respond with TEXT ONLY"
  131. ]
  132. },
  133. "response": {
  134. "statusCode": 200,
  135. "toolUse": {
  136. "id": "toolu_e2e_node_repl_frontend_restart_verify",
  137. "name": "mcp__node_repl__js",
  138. "input": {
  139. "title": "重启后取回原 Browser tab",
  140. "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 { setupBrowserRuntime } = await import(pathToFileURL(join(browserPluginRoot, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst browser = await agent.browsers.get('iab');\nconst tabId = '{{latestBrowserTabId}}';\nconst tabs = await browser.tabs.list();\nconst tab = await browser.tabs.get(tabId);\nconst stateBefore = await tab.playwright.getByRole('status').innerText();\nawait tab.playwright.getByLabel('State').fill('after-restart');\nconst verifyOk = tabs.length === 1 && tabs[0]?.id === tabId && stateBefore === 'before-restart';\n({ marker: verifyOk ? 'E2E_NODE_REPL_FRONTEND_RESTART_VERIFY_OK' : 'E2E_NODE_REPL_FRONTEND_RESTART_VERIFY_FAILED', tabId, count: tabs.length, stateBefore });"
  141. }
  142. }
  143. }
  144. },
  145. {
  146. "id": "node-repl-frontend-restart-final",
  147. "description": "第二轮只在 tab/page 连续时完成。",
  148. "metadata": {
  149. "kind": "main",
  150. "timingPolicy": "fast-text",
  151. "source": "synthetic",
  152. "syntheticReason": "证明重启后的真实 tool result 已进入同一 session continuation。"
  153. },
  154. "maxMatches": 1,
  155. "match": {
  156. "method": "POST",
  157. "pathIncludes": "/messages",
  158. "bodyIncludes": [
  159. "E2E_NODE_REPL_FRONTEND_RESTART_TURN_2",
  160. "toolu_e2e_node_repl_frontend_restart_verify"
  161. ],
  162. "lastUserMessageIncludes": ["E2E_NODE_REPL_FRONTEND_RESTART_VERIFY_OK"],
  163. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  164. },
  165. "response": {
  166. "statusCode": 200,
  167. "text": "E2E_NODE_REPL_FRONTEND_RESTART_DONE"
  168. }
  169. }
  170. ]
  171. }