跳到主要内容

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

浏览文件

guest-system-icon-smoke.mjs

55 行 · 2.7 KB历史下载
1import assert from "node:assert/strict";
2import { fileURLToPath } from "node:url";
3import { createServer } from "vite";
4import { createWorkbench } from "./workbench-fixture.mjs";
5
6const root = fileURLToPath(new URL("..", import.meta.url));
7const vite = await createServer({ root, configFile: `${root}/vite.config.js`, server: { host: "127.0.0.1", port: 0 } });
8await vite.listen();
9const url = `http://127.0.0.1:${vite.httpServer.address().port}`;
10try {
11 for (const [host, accountSystem, statusSystem, label] of [
12 ["windows", "macos", undefined, "macOS"],
13 ["darwin", "windows-11", "windows-11", "Windows"],
14 ["darwin", undefined, undefined, "Linux"],
15 ]) {
16 const { browser, page, state, errors } = await createWorkbench({
17 url,
18 clientContext: { mode: "local", connection_id: "local", client_platform: host, server_platform: host },
19 });
20 try {
21 state.account.guest_system = accountSystem;
22 state.status.guest_system = statusSystem;
23 await page.reload();
24 const sidebar = page.getByRole("complementary", { name: "项目与终端" });
25 const icon = sidebar.getByRole("img", { name: `客户机系统:${label}` });
26 await icon.waitFor();
27 assert.equal(await icon.getAttribute("title"), `客户机系统:${label}`);
28 const iconBox = await icon.boundingBox();
29 const brandBox = await sidebar.locator(".sidebar-brand").boundingBox();
30 const collapseBox = await sidebar.getByRole("button", { name: "收起侧栏" }).boundingBox();
31 assert.ok(iconBox.x > brandBox.x && iconBox.x + iconBox.width < collapseBox.x);
32 if (process.env.CAGE_TEST_CAPTURE) await page.screenshot({ path: `${process.env.CAGE_TEST_CAPTURE}-${label}.png` });
33 await page.reload();
34 await icon.waitFor();
35 assert.deepEqual(errors, []);
36 console.log(`PASS 客机 ${label},客户端 ${host}`);
37 } finally { await browser.close(); }
38 }
39 const fixture = await createWorkbench({
40 url,
41 beforeNavigate: async (page, state) => {
42 state.status.local_vm_storage = true;
43 await page.route("**/api/environment/guest-systems", route => route.fulfill({ json: { fresh: true, system: "macos", available: true } }));
44 },
45 });
46 try {
47 const { page } = fixture;
48 await page.getByRole("img", { name: "客户机系统:Linux" }).waitFor();
49 await page.getByRole("combobox", { name: "客户机系统" }).click();
50 await page.getByRole("option", { name: "macOS", exact: true }).click();
51 await page.getByRole("img", { name: "客户机系统:macOS" }).waitFor();
52 assert.deepEqual(fixture.errors, []);
53 console.log("PASS 首次安装选择时图标随客机系统变化");
54 } finally { await fixture.browser.close(); }
55} finally { await vite.close(); }