跳到主要内容

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

浏览文件

host-clone-smoke.mjs

91 行 · 2.9 KB历史下载
1import assert from "node:assert/strict";
2import { createWorkbench } from "./workbench-fixture.mjs";
3for (const [platform, system, version, edition] of [
4 ["darwin", "macos", "26.5", ""],
5 ["windows", "windows-11", "25H2", "Professional"],
6 ["linux", "ubuntu-22.04", "22.04", ""],
7 ["linux", "ubuntu-24.04", "24.04", ""],
8]) {
9 let planRequests = 0;
10 const fixture = await createWorkbench({
11 clientContext: {
12 mode: "local",
13 connection_id: "local",
14 client_platform: platform,
15 server_platform: platform,
16 },
17 beforeNavigate: async (page, state) => {
18 state.status.local_vm_storage = true;
19 await page.route("**/api/environment/guest-systems", (route) =>
20 route.fulfill({ json: { fresh: true, available: true, system } }),
21 );
22 await page.route("**/api/environment/guest-systems/clone", (route) => {
23 planRequests++;
24 return route.fulfill({
25 json: {
26 key: "source-key",
27 enough_space: true,
28 minimum_free_gib: 64,
29 free_gib: 100,
30 download_bytes: 5000000000,
31 plan: {
32 host: {
33 system,
34 version,
35 build: "host-build",
36 edition,
37 language: "zh-CN",
38 },
39 version,
40 build: "image-build",
41 format: system === "macos" ? "ipsw" : "esd",
42 },
43 },
44 });
45 });
46 },
47 });
48 try {
49 const { page } = fixture;
50 const region = page.locator(".guest-system-picker");
51 const picker = region.getByRole("combobox");
52 await picker.waitFor();
53 const initialHeight = (await region.boundingBox()).height;
54 await picker.focus();
55 await picker.press("ArrowDown");
56 const option = page.getByRole("option", {
57 name: "自动匹配本机系统版本",
58 exact: true,
59 });
60 await option.waitFor();
61 assert.ok(
62 Math.abs((await region.boundingBox()).height - initialHeight) < 1,
63 "floating options must not change layout height",
64 );
65 await picker.press("Home");
66 await picker.press("Enter");
67 assert.equal(await picker.getAttribute("aria-expanded"), "false");
68 await region
69 .getByText("本机构建号 host-build · 镜像构建号 image-build")
70 .waitFor();
71 if (system === "windows-11") await region.getByRole("checkbox").check();
72 const submit = page.waitForRequest(
73 (request) =>
74 request.url().endsWith("/api/start") && request.method() === "POST",
75 );
76 await page
77 .getByRole("button", {
78 name: "安装客户机",
79 exact: true,
80 })
81 .click();
82 const body = (await submit).postDataJSON();
83 assert.equal(body.clone_key, "source-key");
84 assert.equal(body.guest_system, system);
85 assert.equal(planRequests, 1);
86 assert.deepEqual(fixture.errors, []);
87 console.log(platform, "host clone selection and submission passed");
88 } finally {
89 await fixture.browser.close();
90 }
91}