跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

guest-system-picker-smoke.mjs

40 行 · 2.1 KB历史下载
1import assert from "node:assert/strict";
2import { createWorkbench } from "./workbench-fixture.mjs";
3
4for (const [platform, id] of [["darwin","macos"], ["windows","windows-11"], ["linux",null]]) {
5 for (const fresh of [true, false]) {
6 const fixture = await createWorkbench({
7 clientContext: {mode:"local", connection_id:"local", client_platform:platform, server_platform:platform},
8 async beforeNavigate(page, state) {
9 state.status.local_vm_storage = true;
10 await page.route("**/api/environment/guest-systems", route => route.fulfill({
11 json:{fresh, available:false, system:fresh ? id : null, reason:"此构建缺少原生客户机安装组件"},
12 }));
13 },
14 });
15 const { browser, page, errors } = fixture;
16 try {
17 const region = page.locator(".guest-system-picker");
18 if (fresh) {
19 await region.waitFor();
20 if (id) {
21 const picker = region.getByRole("combobox");
22 const storage = page.getByRole("button",{name:"选择环境存储位置"});
23 const initialY = (await storage.boundingBox()).y;
24 await picker.click();
25 const option = page.getByRole("option").last();
26 assert.equal(await option.getAttribute("aria-disabled"),"true");
27 const position = await option.boundingBox();
28 assert.ok(Math.abs((await storage.boundingBox()).y - initialY) < 1 && position.height > 0);
29 await picker.press("Escape");
30 assert.ok(Math.abs((await storage.boundingBox()).y - initialY) <= 1, "collapsed picker restores the following control");
31 }
32 } else await region.waitFor({state:"hidden"});
33 const submitted = page.waitForRequest(req => req.url().endsWith("/api/start") && req.method()==="POST");
34 await page.getByRole("button",{name:"启动 Cage 环境",exact:true}).click();
35 assert.deepEqual((await submitted).postDataJSON(), fresh ? {guest_system:"debian-13"} : {});
36 assert.deepEqual(errors,[]);
37 } finally { await browser.close(); }
38 }
39}
40console.log("Debian fallback and existing environments verified on all three host types.");