File size: 1,152 Bytes
06671aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// @ts-ignore vitest is provided by the backend test runner.
import { describe, expect, it } from "vitest";
import {
    PILOT_FAST_MODEL_ID,
    PILOT_PRO_MODEL_ID,
    normalizeModelForAccess,
} from "./modelAccess";

describe("model access policy", () => {
    it("keeps a selectable internal model for operators", () => {
        expect(
            normalizeModelForAccess("gemini-3-flash-agent-high", true),
        ).toBe("gemini-3-flash-agent-high");
    });

    it("falls back to Fast for forbidden non-operator models", () => {
        expect(
            normalizeModelForAccess("gemini-3-flash-agent-high", false),
        ).toBe(PILOT_FAST_MODEL_ID);
    });

    it("lets non-operators select Pro", () => {
        expect(normalizeModelForAccess(PILOT_PRO_MODEL_ID, false)).toBe(
            PILOT_PRO_MODEL_ID,
        );
    });

    it("uses Fast for missing or invalid non-operator requests", () => {
        expect(normalizeModelForAccess(undefined, false)).toBe(
            PILOT_FAST_MODEL_ID,
        );
        expect(normalizeModelForAccess("not-a-model", false)).toBe(
            PILOT_FAST_MODEL_ID,
        );
    });
});