60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
|
|
import { validateReleaseCandidateRecord } from "../../scripts/lib/release-candidate.mjs";
|
|
|
|
function fixture() {
|
|
return {
|
|
app_version: "0.0.0",
|
|
browsers: [
|
|
{
|
|
brand: "Google Chrome",
|
|
executable_sha256: "A".repeat(64),
|
|
file_name: "chrome.exe",
|
|
full_version: "150.0.7871.187",
|
|
major: 150,
|
|
source: "installed_executable",
|
|
},
|
|
{
|
|
brand: "Microsoft Edge",
|
|
executable_sha256: "B".repeat(64),
|
|
file_name: "msedge.exe",
|
|
full_version: "151.0.4129.59",
|
|
major: 151,
|
|
source: "installed_executable",
|
|
},
|
|
],
|
|
build_commit: "c".repeat(40),
|
|
candidate_package: {
|
|
file_name: "Dada-P0A-0.0.0-win-x64.zip",
|
|
fixed_port: 43121,
|
|
release_status: "candidate_unvalidated",
|
|
sha256: "D".repeat(64),
|
|
size_bytes: 123,
|
|
},
|
|
final_release: false,
|
|
fixed_port: 43121,
|
|
recorded_at: "2026-08-04T05:00:00.000Z",
|
|
schema_version: "1.0",
|
|
status: "candidate_unvalidated",
|
|
windows: { arch: "x64", build: "26200.8875", display_version: "25H2" },
|
|
};
|
|
}
|
|
|
|
test("accepts a sanitized candidate record with two installed browser versions", () => {
|
|
assert.equal(validateReleaseCandidateRecord(fixture()).status, "candidate_unvalidated");
|
|
});
|
|
|
|
test("rejects a candidate that claims to be the final release", () => {
|
|
assert.throws(
|
|
() => validateReleaseCandidateRecord({ ...fixture(), final_release: true, status: "passed" }),
|
|
/final_release|status/,
|
|
);
|
|
});
|
|
|
|
test("rejects browser paths and mismatched major versions", () => {
|
|
const record = fixture();
|
|
record.browsers[0] = { ...record.browsers[0], executable_path: "C:\\Users\\person\\chrome.exe", major: 149 };
|
|
assert.throws(() => validateReleaseCandidateRecord(record), /major|path/);
|
|
});
|