Files
Genarrative/apps/ai-game-creator-shell/scripts/build-release.test.mjs
T
kdletters a7e810b999
Project CI / Backend tests (push) Successful in 7m40s
Project CI / Native shell tests (push) Failing after 18m53s
Project CI / Repository checks (push) Failing after 1m11s
Project CI / Frontend tests (push) Failing after 2m27s
添加 AGC 客户端更新检查与下载能力 (#230)
实现 AGC 启动版本检测与 OSS 安装包下载。

- 每次客户端打开时从 OSS latest.json 检查新版本
- 新版本提示支持 releaseNotes,并通过 Tauri 命令下载到系统下载目录
- 下载地址限制受信任 OSS、HTTPS、大小与可选 SHA-256 校验
- 补充 Tauri capability/CSP、单测和发布文档

Closes #224

Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/230
2026-09-01 19:23:55 +08:00

49 lines
1.6 KiB
JavaScript

import assert from 'node:assert/strict';
import { test } from 'node:test';
import {
compareVersions,
createUpdateManifest,
nextPatchVersion,
selectReleaseArtifact,
} from './build-release.mjs';
test('selects an explicit release artifact when configured', () => {
const artifactPath = new URL('../package.json', import.meta.url).pathname;
const previous = process.env.AGC_UPDATE_ARTIFACT;
process.env.AGC_UPDATE_ARTIFACT = artifactPath;
try {
assert.equal(selectReleaseArtifact([]), artifactPath);
} finally {
if (previous === undefined) delete process.env.AGC_UPDATE_ARTIFACT;
else process.env.AGC_UPDATE_ARTIFACT = previous;
}
});
test('does not select unsupported files', () => {
assert.equal(
selectReleaseArtifact(['/tmp/latest.json', '/tmp/readme.txt']),
null,
);
});
test('manifest contains version, download URL and integrity fields', () => {
const manifest = createUpdateManifest(
new URL('../package.json', import.meta.url).pathname,
);
assert.match(manifest.version, /^\d+\.\d+\.\d+$/u);
assert.match(
manifest.downloadUrl,
new RegExp(`/agc/${manifest.version}/package\\.json$`, 'u'),
);
assert.equal(manifest.sha256.length, 64);
assert.equal(typeof manifest.size, 'number');
});
test('next release version follows the higher local or OSS version', () => {
assert.equal(compareVersions('0.1.15', '0.1.12'), 1);
assert.equal(nextPatchVersion('0.1.12', '0.1.15'), '0.1.16');
assert.equal(nextPatchVersion('0.1.18', '0.1.15'), '0.1.19');
assert.equal(nextPatchVersion('0.1.12', null), '0.1.13');
});