File size: 2,147 Bytes
e3714c1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import {
ANNOTATOR_PROFILE_SCHEMA,
profileFromFile,
resolveProfile,
SOTAC_PROFILE,
TEMPLATE_PROFILE,
templateProfileFile,
} from "../rigProfile";
describe("dataset-side profile files", () => {
test("the shipped template equals the code's template (no drift)", () => {
const shipped = JSON.parse(
readFileSync(
join(process.cwd(), "public", "annotator_profile.template.json"),
"utf-8",
),
);
expect(shipped).toEqual(JSON.parse(JSON.stringify(templateProfileFile())));
});
test("the template parses back into an UNVERIFIED profile with sotac's numbers", () => {
const p = profileFromFile(
JSON.parse(JSON.stringify(templateProfileFile())),
);
expect(p).not.toBeNull();
expect(p!.verified).toBe(false);
expect(p!.calibration.weakAttemptMaxN).toBe(
SOTAC_PROFILE.calibration.weakAttemptMaxN,
);
expect(p!.calibration.screenReference).toBeNull();
});
test("a broken file is rejected, not half-applied", () => {
expect(
profileFromFile({ schema: ANNOTATOR_PROFILE_SCHEMA, id: "x" }),
).toBeNull();
const bad = JSON.parse(JSON.stringify(templateProfileFile()));
bad.calibration.handLossN = "one newton";
expect(profileFromFile(bad)).toBeNull();
expect(profileFromFile(null)).toBeNull();
});
test("resolution order: dataset file > override > registry > template", () => {
const file = profileFromFile({
...templateProfileFile(),
id: "their-rig",
verified: true,
});
expect(resolveProfile("someone/x", SOTAC_PROFILE.id, file).source).toBe(
"dataset-file",
);
expect(resolveProfile("someone/x", SOTAC_PROFILE.id, null).source).toBe(
"override",
);
expect(resolveProfile("Jingyi-Z/sotac", null, null).source).toBe(
"registry",
);
const t = resolveProfile("someone/x", null, null);
expect(t.source).toBe("template");
expect(t.profile).toBe(TEMPLATE_PROFILE);
expect(t.profile.verified).toBe(false);
});
});
|