43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
|
|
import { describe, expect, it } from "vitest";
|
||
|
|
import * as schema from "~/database/schema";
|
||
|
|
import { SIMULATOR_MANIFEST } from "../manifest";
|
||
|
|
import { SIMULATOR_TYPES } from "../registry";
|
||
|
|
import { assertRegistrySchemaDriftFree } from "~/models/simulator";
|
||
|
|
|
||
|
|
describe("simulator manifest", () => {
|
||
|
|
it("has a manifest profile for every registered simulator type", () => {
|
||
|
|
expect(Object.keys(SIMULATOR_MANIFEST).toSorted()).toEqual([...SIMULATOR_TYPES].toSorted());
|
||
|
|
});
|
||
|
|
|
||
|
|
it("keeps the registry and database enum in sync", () => {
|
||
|
|
expect([...schema.simulatorTypeEnum.enumValues].toSorted()).toEqual([...SIMULATOR_TYPES].toSorted());
|
||
|
|
});
|
||
|
|
|
||
|
|
it("assertRegistrySchemaDriftFree does not throw when registry and schema are aligned", async () => {
|
||
|
|
await expect(assertRegistrySchemaDriftFree()).resolves.toBeUndefined();
|
||
|
|
});
|
||
|
|
|
||
|
|
it("documents admin setup requirements for all profiles", () => {
|
||
|
|
for (const simulatorType of SIMULATOR_TYPES) {
|
||
|
|
const profile = SIMULATOR_MANIFEST[simulatorType];
|
||
|
|
expect(profile.displayName).toBeTruthy();
|
||
|
|
expect(profile.description).toBeTruthy();
|
||
|
|
expect(Array.isArray(profile.requiredInputs)).toBe(true);
|
||
|
|
expect(Array.isArray(profile.optionalInputs)).toBe(true);
|
||
|
|
expect(profile.setupSections.length).toBeGreaterThan(0);
|
||
|
|
expect(profile.defaultConfig).toBeTypeOf("object");
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
it("only derives inputs from declared optional inputs", () => {
|
||
|
|
for (const simulatorType of SIMULATOR_TYPES) {
|
||
|
|
const profile = SIMULATOR_MANIFEST[simulatorType];
|
||
|
|
for (const alternatives of Object.values(profile.derivableInputs ?? {})) {
|
||
|
|
for (const alternative of alternatives ?? []) {
|
||
|
|
expect(profile.optionalInputs).toContain(alternative);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
});
|