Files
edgeever/apps/web/src/lib/version-check.test.mjs
T
tianma-if e8ed6b1019 fix(desktop): allow auto-restart even when the instance is behind
Stop holding downloaded desktop updates until the connected instance
catches up. When the client is newer, system info shows a small hint
that some features may not work yet and that the instance can update
automatically each day or be updated manually.
2026-09-11 10:36:36 +08:00

62 lines
2.6 KiB
JavaScript

import { describe, expect, test } from "bun:test";
import { findDesktopReleaseVersion, getReleaseTagForVersion, isClientAheadOfInstance, isVersionOutdated, resolveLocalizedReleaseChanges } from "./version-check";
describe("platform release version checks", () => {
test("derives the installed desktop version from the DMG asset", () => {
expect(findDesktopReleaseVersion([
"EdgeEver-1.6.50-mac-arm64.dmg",
"EdgeEver-1.6.50-mac-arm64.dmg.blockmap",
"EdgeEver-1.6.50-mac-x64.dmg",
"EdgeEver-1.6.50-mac-x64.dmg.blockmap",
"edgeever-android-v1.6.49-arm64-v8a.apk",
])).toBe("1.6.50");
});
test("rejects missing or ambiguous desktop assets", () => {
expect(findDesktopReleaseVersion([])).toBeNull();
expect(findDesktopReleaseVersion([
"EdgeEver-1.6.49-mac-arm64.dmg",
"EdgeEver-1.6.50-mac-x64.dmg",
])).toBeNull();
expect(findDesktopReleaseVersion([
"EdgeEver-1.6.50-mac-arm64.dmg",
])).toBeNull();
});
test("compares semantic release components and ignores build metadata", () => {
expect(isVersionOutdated("1.6.49+12", "1.6.50")).toBe(true);
expect(isVersionOutdated("1.6.50+3", "1.6.50")).toBe(false);
expect(isVersionOutdated("1.6.50-beta.2", "1.6.50-beta.10")).toBe(true);
expect(isVersionOutdated("1.6.50-beta.10", "1.6.50")).toBe(true);
expect(isVersionOutdated("1.6.50", "1.6.50-beta.10")).toBe(false);
});
test("treats the client as ahead only when it is newer than a known instance", () => {
expect(isClientAheadOfInstance("1.66.0", "1.65.1")).toBe(true);
expect(isClientAheadOfInstance("1.65.1+4", "1.65.1")).toBe(false);
expect(isClientAheadOfInstance("1.66.0", null)).toBe(false);
expect(isClientAheadOfInstance("1.66.0", "local")).toBe(false);
});
test("maps deployed builds back to their formal release tag", () => {
expect(getReleaseTagForVersion("1.34.1+18")).toBe("v1.34.1");
expect(getReleaseTagForVersion("v1.35.0-beta.2+4")).toBe("v1.35.0-beta.2");
expect(getReleaseTagForVersion("local")).toBeNull();
});
test("selects exact and related locales before falling back to English", () => {
const changes = {
"en-US": ["English"],
"ja-JP": ["日本語"],
"pt-BR": ["Português"],
"zh-CN": ["中文"],
};
expect(resolveLocalizedReleaseChanges(changes, "ja-JP")).toEqual(["日本語"]);
expect(resolveLocalizedReleaseChanges(changes, "pt_PT")).toEqual(["Português"]);
expect(resolveLocalizedReleaseChanges(changes, "zh-Hans")).toEqual(["中文"]);
expect(resolveLocalizedReleaseChanges(changes, "de-DE")).toEqual(["English"]);
});
});