import { describe, expect, it } from "vitest"; import { TOOLCRAFT_PERFORMANCE_PROFILE_CATALOG_VERSION, TOOLCRAFT_PERFORMANCE_PROFILE_NAMES, getToolcraftPerformanceProfile, getToolcraftPerformanceProfileNames, } from "./profile-catalog"; import { TOOLCRAFT_PERFORMANCE_PROFILE_MANIFEST } from "./profile-catalog-manifest.mjs"; describe("Toolcraft performance profile catalog", () => { it("owns every supported profile in deterministic order", () => { expect(getToolcraftPerformanceProfileNames()).toEqual([ "batch-responsive", "initial-render", "interactive-continuous", "interactive-discrete", ]); expect(TOOLCRAFT_PERFORMANCE_PROFILE_CATALOG_VERSION).toBe(1); expect(TOOLCRAFT_PERFORMANCE_PROFILE_NAMES).toBe( TOOLCRAFT_PERFORMANCE_PROFILE_MANIFEST.names, ); expect(TOOLCRAFT_PERFORMANCE_PROFILE_CATALOG_VERSION).toBe( TOOLCRAFT_PERFORMANCE_PROFILE_MANIFEST.version, ); }); it("returns fresh deeply immutable profile values", () => { const first = getToolcraftPerformanceProfile("interactive-continuous"); const second = getToolcraftPerformanceProfile("interactive-continuous"); expect(first).toEqual(second); expect(first).not.toBe(second); expect(first.thresholds).not.toBe(second.thresholds); expect(Object.isFrozen(first)).toBe(true); expect(Object.isFrozen(first.thresholds)).toBe(true); expect(first).toMatchObject({ name: "interactive-continuous", version: TOOLCRAFT_PERFORMANCE_PROFILE_CATALOG_VERSION, thresholds: { maxDroppedFrameRatio: expect.any(Number), maxFrameGapMs: expect.any(Number), maxFrameGapP95Ms: expect.any(Number), maxLongTaskMs: expect.any(Number), maxVisibleOutputLatencyMs: expect.any(Number), }, }); }); });