| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- {
- "version": 1,
- "caseName": "conversation-session-node-repl-stateless-browser-multisession",
- "spec": "./test/e2e/conversation-session/browser-use/conversation-session-node-repl-stateless-browser-multisession.test.ts",
- "fixtures": [
- {
- "id": "node-repl-browser-stateless-title",
- "description": "固定两个 Browser Use session 的异步标题响应。",
- "metadata": {
- "kind": "common",
- "timingPolicy": "fast-text",
- "source": "synthetic",
- "syntheticReason": "标题不是本 case 的产品语义,只需避免误命中主请求。"
- },
- "maxMatches": 2,
- "match": {
- "method": "POST",
- "pathIncludes": "/messages",
- "bodyIncludes": ["Generate a concise title", "E2E_NODE_REPL_BROWSER_STATELESS_"]
- },
- "response": {
- "statusCode": 200,
- "statusMessage": "OK",
- "headers": { "content-type": "application/json; charset=utf-8" },
- "body": "{\"id\":\"upstream-node-repl-browser-stateless-title\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\":\\\"Browser 无状态复用\\\"}\"}],\"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\"}}"
- }
- },
- {
- "id": "node-repl-browser-a-initial",
- "description": "Session A 首次调用 node_repl,创建真实 IAB tab 并写入 kernel marker。",
- "metadata": {
- "kind": "main",
- "timingPolicy": "fast-text",
- "source": "synthetic",
- "syntheticReason": "稳定构造 fresh kernel 与 BrowserControl 连续性的前置状态。"
- },
- "maxMatches": 1,
- "match": {
- "method": "POST",
- "pathIncludes": "/messages",
- "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_STATELESS_A"],
- "bodyIncludes": ["mcp__node_repl__js"],
- "bodyExcludes": [
- "toolu_e2e_node_repl_browser_a_initial",
- "Generate a concise title",
- "CRITICAL: Respond with TEXT ONLY"
- ]
- },
- "response": {
- "statusCode": 200,
- "toolUse": {
- "id": "toolu_e2e_node_repl_browser_a_initial",
- "name": "mcp__node_repl__js",
- "input": {
- "title": "创建 Session A Browser tab",
- "code": "const root = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!root) throw new Error('Browser plugin root is unavailable');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst { setupBrowserRuntime } = await import(pathToFileURL(join(root, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst controlledBrowser = await agent.browsers.get('iab');\nconst before = await controlledBrowser.tabs.list();\nglobalThis.__zcodeBrowserKernelMarker = 'SESSION_A';\nawait controlledBrowser.tabs.new();\nconst after = await controlledBrowser.tabs.list();\n({ marker: before.length === 0 && after.length === 1 ? 'E2E_NODE_REPL_BROWSER_A_INITIAL_OK' : 'E2E_NODE_REPL_BROWSER_A_INITIAL_FAILED', beforeCount: before.length, afterCount: after.length, tabId: after[0]?.id });"
- }
- }
- }
- },
- {
- "id": "node-repl-browser-a-verify",
- "description": "Session A 第二次调用证明 kernel fresh 且 BrowserControl tab 连续。",
- "metadata": {
- "kind": "main",
- "timingPolicy": "fast-text",
- "source": "synthetic",
- "syntheticReason": "直接覆盖 Browser Use 的调用级无状态合同。"
- },
- "maxMatches": 1,
- "match": {
- "method": "POST",
- "pathIncludes": "/messages",
- "bodyIncludes": [
- "E2E_NODE_REPL_BROWSER_STATELESS_A",
- "toolu_e2e_node_repl_browser_a_initial"
- ],
- "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_A_INITIAL_OK"],
- "bodyExcludes": [
- "toolu_e2e_node_repl_browser_a_verify",
- "Generate a concise title",
- "CRITICAL: Respond with TEXT ONLY"
- ]
- },
- "response": {
- "statusCode": 200,
- "toolUse": {
- "id": "toolu_e2e_node_repl_browser_a_verify",
- "name": "mcp__node_repl__js",
- "input": {
- "title": "验证 Session A fresh kernel 与 tab 连续",
- "code": "const kernelState = typeof globalThis.__zcodeBrowserKernelMarker;\nconst root = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!root) throw new Error('Browser plugin root is unavailable');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst { setupBrowserRuntime } = await import(pathToFileURL(join(root, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst controlledBrowser = await agent.browsers.get('iab');\nconst tabs = await controlledBrowser.tabs.list();\n({ marker: kernelState === 'undefined' && tabs.length === 1 ? 'E2E_NODE_REPL_BROWSER_A_STATELESS_OK' : 'E2E_NODE_REPL_BROWSER_A_STATELESS_FAILED', kernelState, count: tabs.length, tabId: tabs[0]?.id });"
- }
- }
- }
- },
- {
- "id": "node-repl-browser-a-final",
- "description": "Session A 只在 fresh kernel 与 tab 连续同时成立后完成。",
- "metadata": {
- "kind": "main",
- "timingPolicy": "fast-text",
- "source": "synthetic",
- "syntheticReason": "证明真实 tool result 已进入同一 session continuation。"
- },
- "maxMatches": 1,
- "match": {
- "method": "POST",
- "pathIncludes": "/messages",
- "bodyIncludes": [
- "E2E_NODE_REPL_BROWSER_STATELESS_A",
- "toolu_e2e_node_repl_browser_a_verify"
- ],
- "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_A_STATELESS_OK"],
- "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
- },
- "response": { "statusCode": 200, "text": "E2E_NODE_REPL_BROWSER_STATELESS_A_DONE" }
- },
- {
- "id": "node-repl-browser-b-verify",
- "description": "Session B 证明没有继承 A 的 kernel 或 BrowserControl tab,再创建自己的 tab。",
- "metadata": {
- "kind": "main",
- "timingPolicy": "fast-text",
- "source": "synthetic",
- "syntheticReason": "覆盖共享 frontend 下的跨 session kernel、tab 与结果隔离。"
- },
- "maxMatches": 1,
- "match": {
- "method": "POST",
- "pathIncludes": "/messages",
- "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_STATELESS_B"],
- "bodyIncludes": ["mcp__node_repl__js"],
- "bodyExcludes": [
- "toolu_e2e_node_repl_browser_b_verify",
- "Generate a concise title",
- "CRITICAL: Respond with TEXT ONLY"
- ]
- },
- "response": {
- "statusCode": 200,
- "toolUse": {
- "id": "toolu_e2e_node_repl_browser_b_verify",
- "name": "mcp__node_repl__js",
- "input": {
- "title": "验证 Session B Browser 隔离",
- "code": "const kernelState = typeof globalThis.__zcodeBrowserKernelMarker;\nconst root = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!root) throw new Error('Browser plugin root is unavailable');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst { setupBrowserRuntime } = await import(pathToFileURL(join(root, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst controlledBrowser = await agent.browsers.get('iab');\nconst before = await controlledBrowser.tabs.list();\nawait controlledBrowser.tabs.new();\nconst after = await controlledBrowser.tabs.list();\n({ marker: kernelState === 'undefined' && before.length === 0 && after.length === 1 ? 'E2E_NODE_REPL_BROWSER_B_ISOLATED_OK' : 'E2E_NODE_REPL_BROWSER_B_ISOLATED_FAILED', kernelState, beforeCount: before.length, afterCount: after.length });"
- }
- }
- }
- },
- {
- "id": "node-repl-browser-b-final",
- "description": "Session B 只在跨 session 隔离成立后完成。",
- "metadata": {
- "kind": "main",
- "timingPolicy": "fast-text",
- "source": "synthetic",
- "syntheticReason": "证明 B 的结果只回到 B continuation。"
- },
- "maxMatches": 1,
- "match": {
- "method": "POST",
- "pathIncludes": "/messages",
- "bodyIncludes": [
- "E2E_NODE_REPL_BROWSER_STATELESS_B",
- "toolu_e2e_node_repl_browser_b_verify"
- ],
- "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_B_ISOLATED_OK"],
- "bodyExcludes": [
- "E2E_NODE_REPL_BROWSER_A_STATELESS_OK",
- "Generate a concise title",
- "CRITICAL: Respond with TEXT ONLY"
- ]
- },
- "response": { "statusCode": 200, "text": "E2E_NODE_REPL_BROWSER_STATELESS_B_DONE" }
- }
- ]
- }
|