feat: expose reviewed media roles

This commit is contained in:
ik
2026-09-21 08:00:15 +07:00
parent 81af8a02b6
commit 86515a9da1
8 changed files with 28 additions and 8 deletions
+10
View File
@@ -7,6 +7,7 @@ import { tackleVisualKind, tackleVisualTone } from "../../src/lib/tackle-visuals
import { waterbodyVisual } from "../../src/lib/waterbody-visuals.ts";
import { pageHref, pageWindow } from "../../src/lib/pagination.ts";
import { adminEndsSession, adminErrorMessage } from "../../src/lib/admin-errors.ts";
import { findMediaByLabel } from "../../src/lib/media.ts";
test("activity levels share one complete 0-100 scale", () => {
assert.deepEqual(
@@ -62,6 +63,15 @@ test("waterbody fingerprints are stable, bounded and entity-specific", () => {
assert.match(kuori.code, /^[0-9A-Z]{2}$/);
});
test("waterbody media lookup only accepts reviewed roles when constrained", () => {
const assets = [
{ id: "screenshot", entity_type: "waterbody", entity_key: "kuori", media_role: "waterbody_screenshot", label: "Куори", width: 1, height: 1, content_type: "image/webp", image_url: "", source_system: "rf4db", source_url: "" },
{ id: "map", entity_type: "waterbody", entity_key: "kuori", media_role: "waterbody_map", label: "Куори", width: 1, height: 1, content_type: "image/webp", image_url: "", source_system: "rf4db", source_url: "" },
] as const;
assert.equal(findMediaByLabel([...assets], "Куори", ["waterbody_cover", "waterbody_map"])?.id, "map");
assert.equal(findMediaByLabel([...assets], "Куори", ["waterbody_cover"]), undefined);
});
test("45 records are reachable across three stable pages", () => {
const pages = [pageWindow(45, 20, 0), pageWindow(45, 20, 20), pageWindow(45, 20, 40)];
assert.deepEqual(pages.map(page => [page.start, page.end]), [[1, 20], [21, 40], [41, 45]]);