跳到主要内容

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

浏览文件

ubuntu-guest-choice-smoke.mjs

74 行 · 4.0 KB历史下载
1import assert from "node:assert/strict";
2import { createWorkbench } from "./workbench-fixture.mjs";
3
4for (const [platform, system] of [["darwin", "macos"], ["windows", "windows-11"], ["linux", "ubuntu-24.04"], ["linux", ""]]) {
5 let submitted;
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({ json: {
11 fresh: true, available: Boolean(system), ...(system ? { system } : {}), linux_systems: ["ubuntu-22.04"],
12 } }));
13 await page.route("**/api/environment/guest-systems/clone", () => { throw Error("Ubuntu requested host clone metadata"); });
14 await page.route("**/api/start", route => {
15 submitted = route.request().postDataJSON();
16 return route.fulfill({ json: { id: "ubuntu-choice", running: true, kind: "guest-install" } });
17 });
18 },
19 });
20 try {
21 const { page } = fixture;
22 const picker = page.getByRole("combobox", { name: "客户机系统" });
23 const storage = page.getByRole("button", { name: "选择环境存储位置" });
24 await picker.waitFor();
25 const initial = await storage.boundingBox();
26 await picker.click();
27 const option = page.getByRole("option", { name: "Ubuntu 22.04", exact: true });
28 await option.waitFor();
29 const box = await option.boundingBox();
30 const expanded = await storage.boundingBox();
31 assert.ok(Math.abs(expanded.y - initial.y) < 1 && box.height > 0, "floating options must not move the next control");
32 await picker.press("Escape");
33 assert.equal((await storage.boundingBox()).y, initial.y);
34 await picker.press("Enter");
35 await picker.press("Home");
36 for (let index = 0; index < (system ? 2 : 1); index++) await picker.press("ArrowDown");
37 await picker.press("Enter");
38 await picker.click();
39 await option.click();
40 await page.getByText("从 Ubuntu 官方源下载 Ubuntu 22.04 LTS 镜像", { exact: false }).waitFor();
41 assert.equal(await page.getByLabel("ISO 的 SHA-256").count(), 0);
42 assert.equal(await page.getByRole("button", { name: "选择本机 ISO" }).count(), 0);
43 const install = page.getByRole("button", { name: "安装客户机", exact: true });
44 assert.equal(await install.isEnabled(), true);
45 await Promise.all([page.waitForResponse(response => response.url().endsWith("/api/start")), install.click()]);
46 assert.equal(submitted.guest_system, "ubuntu-22.04");
47 assert.equal(submitted.clone_key || "", "");
48 assert.equal(submitted.media, "");
49 assert.deepEqual(fixture.errors, []);
50 console.log(`${platform}/${system || "other-linux"}: explicit Ubuntu option, inline layout and install request passed`);
51 } finally { await fixture.browser.close(); }
52}
53
54{
55 const fixture = await createWorkbench({
56 async beforeNavigate(page, state) {
57 state.status.local_vm_storage = true;
58 await page.route("**/api/environment/guest-systems", route => route.fulfill({ json: {
59 fresh: false, available: true, system: "macos", linux_systems: ["ubuntu-22.04"], reselect: false,
60 pending: { id: "ubuntu-resume", system: "ubuntu-22.04", source_kind: "linux-image", source: { host: { system: "ubuntu-22.04", arch: "arm64" } } },
61 } }));
62 await page.route("**/api/environment/guest-systems/clone", () => { throw Error("Ubuntu resume was treated as a host clone"); });
63 },
64 });
65 try {
66 const picker = fixture.page.getByRole("combobox", { name: "客户机系统" });
67 await picker.waitFor();
68 assert.equal(await picker.isDisabled(), true);
69 assert.match(await picker.innerText(), /Ubuntu 22.04/);
70 assert.equal(await fixture.page.getByRole("button", { name: "重新选择系统或镜像" }).count(), 0);
71 assert.deepEqual(fixture.errors, []);
72 console.log("Ubuntu interrupted installation retains its system and cannot replace an existing disk");
73 } finally { await fixture.browser.close(); }
74}