Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
34 lines
1.6 KiB
TypeScript
34 lines
1.6 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { test } from "node:test";
|
|
|
|
import { APP_VERSION } from "../src/lib/app-version";
|
|
|
|
const read = (path: string) => readFileSync(new URL(path, import.meta.url), "utf8");
|
|
|
|
test("BUG-2407: one product version, shown in settings and /api/health", () => {
|
|
assert.match(APP_VERSION, /^\d+\.\d+(\.\d+)?$/);
|
|
// The workflow reads the version with sed; keep the line shape exact.
|
|
assert.match(read("../src/lib/app-version.ts"), /^export const APP_VERSION = "\d+\.\d+(\.\d+)?";$/m);
|
|
const health = read("../src/app/api/health/route.ts");
|
|
assert.match(health, /appVersion: APP_VERSION/);
|
|
const dialogs = read("../src/components/account-dialog-provider.tsx");
|
|
assert.match(dialogs, /版本 \{APP_VERSION\}/);
|
|
});
|
|
|
|
test("BUG-2407: production deploy refuses a reused version and tags a successful release", () => {
|
|
const workflow = read("../../.gitea/workflows/deploy-production.yml");
|
|
assert.match(workflow, /raw\/frontend\/src\/lib\/app-version\.ts\?ref=\$REQUESTED_SHA/);
|
|
assert.match(workflow, /already tagged v\$app_version/);
|
|
assert.match(workflow, /echo "app_version=\$app_version"/);
|
|
assert.match(workflow, /- name: Tag the release\n\s+if: success\(\)\n\s+continue-on-error: true/);
|
|
assert.match(workflow, /could not create \$tag; run: git tag -a/);
|
|
});
|
|
|
|
test("BUG-2407: the internal release log covers every tagged version", () => {
|
|
const log = read("../../docs/RELEASES.md");
|
|
for (const version of ["1.0", "1.1", "1.1.1", "1.2", "1.3", "1.4", "1.5"]) {
|
|
assert.match(log, new RegExp(`^## ${version.replace(/\./g, "\\.")}\\b`, "m"));
|
|
}
|
|
});
|