Files
AgentCompany/landing/tests/unit/downloads.test.ts
T
ZacharyZhang-NYandClaude Opus 5.5 2d7af224dd
CI / Typecheck, lint, tests, e2e (push) Failing after 3m51s
Website: 16-bit pixel-art rebuild with a live Three.js office, downloads from Gitea v1.5.1
- Title screen over a real-time voxel office rendered at low resolution and quantized to a rotating 32-colour palette with Bayer dithering; day part and season re-light the scene and every surface.
- 16-bit UI kit: name-plate dialogs, menu cursor, inventory, XP bar, badges, NPC speech, GAME OVER with CONTINUE, hand-placed 12x12 icons, Fusion Pixel font (Latin subset preloaded).
- Sections as a game: quest log (onboarding), character select (AI CEO / AI Co-Founder), inventory (features), party roster (providers), live download XP, save point (all v1.5.1 builds), FAQ as NPC dialog, credits.
- Downloads and source point to the Gitea release; the download function only redirects to git.zacharyzhang.com.
- Tailwind and the old components removed; unit tests for platform/downloads, rewritten e2e suite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 23:37:23 -04:00

48 lines
1.7 KiB
TypeScript

import assert from "node:assert/strict";
import { test } from "node:test";
import {
DOWNLOAD_DEDUP_WINDOW_MS,
downloadAssets,
getDownloadAsset,
getTrackedDownloadHref,
isAllowedDownloadUrl,
} from "../../lib/downloads";
import { releaseVersion } from "../../lib/release-links";
test("lists every v1.5.1 build with unique ids", () => {
assert.deepEqual(
downloadAssets.map((asset) => asset.id),
[
"macos-arm64-dmg",
"macos-arm64-zip",
"macos-x64-dmg",
"macos-x64-zip",
"windows-x64-installer",
"linux-x64-appimage",
"linux-x64-deb",
],
);
});
test("points every asset at the Gitea release for the current version", () => {
for (const asset of downloadAssets) {
assert.ok(isAllowedDownloadUrl(asset.href), asset.href);
assert.ok(asset.href.endsWith(`/releases/download/v${releaseVersion}/${asset.fileName}`), asset.href);
assert.match(asset.size, /^\d+ MB$/);
}
});
test("looks assets up by id and tracks downloads through the API", () => {
assert.equal(getDownloadAsset("linux-x64-deb")?.platformId, "linux");
assert.equal(getDownloadAsset("missing"), null);
assert.equal(getTrackedDownloadHref("macos-arm64-dmg"), "/api/download?asset=macos-arm64-dmg");
assert.equal(getTrackedDownloadHref("a b&c"), "/api/download?asset=a%20b%26c");
assert.equal(DOWNLOAD_DEDUP_WINDOW_MS, 86_400_000);
});
test("rejects download urls off the release host", () => {
assert.equal(isAllowedDownloadUrl("https://evil.example/AgentCompany.dmg"), false);
assert.equal(isAllowedDownloadUrl("http://git.zacharyzhang.com/x.dmg"), false);
assert.equal(isAllowedDownloadUrl("https://git.zacharyzhang.com.evil.example/x.dmg"), false);
});