跳到主要内容

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

浏览文件

downloads-smoke.mjs

53 行 · 3.2 KB历史下载
1import assert from 'node:assert/strict';
2import { createRequire } from 'node:module';
3import { readFile, mkdir } from 'node:fs/promises';
4const require = createRequire(import.meta.url);
5const { chromium } = require(process.env.CAGE_PLAYWRIGHT_MODULE || 'playwright');
6const origin = process.env.CAGE_SITE_URL || 'http://127.0.0.1:4833/Claude-Cage/';
7const output = process.env.CAGE_SITE_REPORT || '_output/platform-publication/site';
8const release = JSON.parse(await readFile(new URL('../src/data/release.json', import.meta.url), 'utf8'));
9const expected = {
10 macOS: release.downloadURL,
11 Windows: release.windowsDownloadURL || release.windowsPreview?.downloadURL,
12 Linux: release.linuxDownloadURL,
13};
14for (const [platform, url] of Object.entries(expected)) assert.ok(url, `${platform} must have a verified public installer`);
15await mkdir(output, { recursive: true });
16const browser = await chromium.launch({ headless: true });
17try {
18 for (const { route, width, height } of [{ route: '', width: 1280, height: 900 }, { route: '', width: 390, height: 844 }, { route: 'fr/', width: 1280, height: 900 }, { route: 'ar/', width: 390, height: 844 }]) {
19 const page = await browser.newPage({ viewport: { width, height } });
20 const errors = [];
21 page.on('pageerror', error => errors.push(error.message));
22 await page.goto(new URL(route, origin).href);
23 await page.locator('[data-download-open]').first().click();
24 const dialog = page.getByRole('dialog');
25 await dialog.waitFor({ state: 'visible' });
26 for (const [platform, url] of Object.entries(expected)) {
27 const option = dialog.locator(`[data-platform="${platform}"]`);
28 await option.getByRole('heading', { name: platform, exact: true }).waitFor();
29 assert.equal(await option.locator('a.button').getAttribute('href'), url);
30 }
31 if (!release.windowsDownloadURL) {
32 const status = await dialog.locator('[data-platform="Windows"] .platform-status').textContent();
33 assert.ok(status.trim() && !status.trim().startsWith('.exe'), 'unsigned Windows requires an explicit label');
34 if (!route) assert.match(status, /未签名/);
35 }
36 const bounds = await dialog.boundingBox();
37 assert.ok(bounds.x >= 0 && bounds.x + bounds.width <= width + 1, 'download chooser overflows viewport');
38 await page.screenshot({ path: `${output}/${route.replaceAll('/', '') || 'zh'}-${width}.png` });
39 await page.keyboard.press('Escape');
40 await dialog.waitFor({ state: 'hidden' });
41 await page.goto(new URL(`${route}#download`, origin).href);
42 await dialog.waitFor({ state: 'visible' });
43 await dialog.getByRole('button').click();
44 await dialog.waitFor({ state: 'hidden' });
45 assert.deepEqual(errors, []);
46 await page.close();
47 }
48 const context = await browser.newContext({ javaScriptEnabled: false });
49 const page = await context.newPage(); await page.goto(origin);
50 for (const url of Object.values(expected)) await page.locator(`noscript a[href="${url}"]`).waitFor({ state: 'visible' });
51 await context.close();
52 console.log('PASS: three public installer links, unsigned Windows label, desktop/mobile/RTL layout, modal open/close, deep link and no-JavaScript downloads');
53} finally { await browser.close(); }