{ "version": 1, "caseName": "conversation-session-node-repl-frontend-restart", "spec": "./test/e2e/conversation-session/browser-use/conversation-session-node-repl-frontend-restart.test.ts", "fixtures": [ { "id": "node-repl-frontend-restart-title", "description": "固定 frontend 重启 case 的异步标题响应。", "metadata": { "kind": "common", "timingPolicy": "fast-text", "source": "synthetic", "syntheticReason": "标题不属于本用例语义,只需避免误命中主请求。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyIncludes": ["Generate a concise title", "E2E_NODE_REPL_FRONTEND_RESTART_WARMUP"] }, "response": { "statusCode": 200, "statusMessage": "OK", "headers": { "content-type": "application/json; charset=utf-8" }, "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\"}}" } }, { "id": "node-repl-frontend-restart-warmup", "description": "预热轮只返回文本,让会话先启动并连上 node_repl。", "metadata": { "kind": "main", "timingPolicy": "fast-text", "source": "synthetic", "syntheticReason": "MCP 异步启动时首个请求可能早于 node_repl 连上;预热轮把这段时序移出本 case。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "lastUserMessageIncludes": ["E2E_NODE_REPL_FRONTEND_RESTART_WARMUP"], "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"] }, "response": { "statusCode": 200, "text": "E2E_NODE_REPL_FRONTEND_RESTART_WARMUP_DONE" } }, { "id": "node-repl-frontend-restart-setup", "description": "首轮调用 node_repl 创建真实 IAB tab、打开 fixture 页并写入 state,返回稳定 tab id。", "metadata": { "kind": "main", "timingPolicy": "fast-text", "source": "synthetic", "syntheticReason": "稳定构造 frontend 重启前的 tab/page 状态。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "lastUserMessageIncludes": [ "E2E_NODE_REPL_FRONTEND_RESTART_TURN_1", "E2E_BROWSER_FIXTURE_URL:" ], "bodyIncludes": ["mcp__node_repl__js"], "bodyExcludes": [ "toolu_e2e_node_repl_frontend_restart_setup", "Generate a concise title", "CRITICAL: Respond with TEXT ONLY" ] }, "response": { "statusCode": 200, "toolUse": { "id": "toolu_e2e_node_repl_frontend_restart_setup", "name": "mcp__node_repl__js", "input": { "title": "创建重启前的 Browser tab", "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 });" } } } }, { "id": "node-repl-frontend-restart-setup-final", "description": "首轮在 tab 创建成功后完成。", "metadata": { "kind": "main", "timingPolicy": "fast-text", "source": "synthetic", "syntheticReason": "形成 frontend 终止前的 turn 边界。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyIncludes": [ "E2E_NODE_REPL_FRONTEND_RESTART_TURN_1", "toolu_e2e_node_repl_frontend_restart_setup" ], "lastUserMessageIncludes": ["E2E_NODE_REPL_FRONTEND_RESTART_SETUP_OK"], "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"] }, "response": { "statusCode": 200, "text": "E2E_NODE_REPL_FRONTEND_RESTART_SETUP_DONE" } }, { "id": "node-repl-frontend-restart-verify", "description": "frontend 重启后的下一轮按上一条 tool result 的稳定 id 取回原 tab,读取并更新页面 state。", "metadata": { "kind": "main", "timingPolicy": "fast-text", "source": "synthetic", "syntheticReason": "验证重启后 js 仍在工具列表里且可调用,tab/page 状态连续;tab id 从真实 tool result 动态注入。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "lastUserMessageIncludes": ["E2E_NODE_REPL_FRONTEND_RESTART_TURN_2"], "bodyIncludes": ["mcp__node_repl__js", "toolu_e2e_node_repl_frontend_restart_setup"], "bodyExcludes": [ "toolu_e2e_node_repl_frontend_restart_verify", "Generate a concise title", "CRITICAL: Respond with TEXT ONLY" ] }, "response": { "statusCode": 200, "toolUse": { "id": "toolu_e2e_node_repl_frontend_restart_verify", "name": "mcp__node_repl__js", "input": { "title": "重启后取回原 Browser tab", "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 });" } } } }, { "id": "node-repl-frontend-restart-final", "description": "第二轮只在 tab/page 连续时完成。", "metadata": { "kind": "main", "timingPolicy": "fast-text", "source": "synthetic", "syntheticReason": "证明重启后的真实 tool result 已进入同一 session continuation。" }, "maxMatches": 1, "match": { "method": "POST", "pathIncludes": "/messages", "bodyIncludes": [ "E2E_NODE_REPL_FRONTEND_RESTART_TURN_2", "toolu_e2e_node_repl_frontend_restart_verify" ], "lastUserMessageIncludes": ["E2E_NODE_REPL_FRONTEND_RESTART_VERIFY_OK"], "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"] }, "response": { "statusCode": 200, "text": "E2E_NODE_REPL_FRONTEND_RESTART_DONE" } } ] }