mirror of
https://github.com/murashit/codex-panel.git
synced 2026-07-22 06:57:10 +00:00
test(runtime): cover approval policy commit state
This commit is contained in:
parent
d114c3e473
commit
d3b426d500
1 changed files with 56 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { setRuntimeIntentValue } from "../../../../../src/features/chat/domain/runtime/intent";
|
||||
import {
|
||||
clearRequestedApprovalsReviewerRuntimeState,
|
||||
clearRequestedFastModeRuntimeState,
|
||||
|
|
@ -52,6 +53,61 @@ describe("chat runtime state", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ applied: "never" as const, expectedPolicy: "never" as const, expectedKnown: true },
|
||||
{ applied: null, expectedPolicy: null, expectedKnown: false },
|
||||
])("applies approval policy $applied with the correct known state", ({ applied, expectedPolicy, expectedKnown }) => {
|
||||
const state = {
|
||||
...initialChatRuntimeState(),
|
||||
active: {
|
||||
...initialChatRuntimeState().active,
|
||||
approvalPolicy: "on-request" as const,
|
||||
approvalPolicyKnown: true,
|
||||
},
|
||||
};
|
||||
|
||||
const next = commitAppliedRuntimeSettingsPatchState(state, { approvalPolicy: applied });
|
||||
|
||||
expect(next.active.approvalPolicy).toBe(expectedPolicy);
|
||||
expect(next.active.approvalPolicyKnown).toBe(expectedKnown);
|
||||
});
|
||||
|
||||
it("clears only the applied approval policy intent and preserves unrelated state", () => {
|
||||
const initial = initialChatRuntimeState();
|
||||
const state = {
|
||||
...initial,
|
||||
active: {
|
||||
...initial.active,
|
||||
model: "gpt-5.1",
|
||||
reasoningEffort: "high" as const,
|
||||
serviceTier: "flex" as const,
|
||||
serviceTierKnown: true,
|
||||
approvalsReviewer: "user" as const,
|
||||
},
|
||||
pending: {
|
||||
...initial.pending,
|
||||
model: setRuntimeIntentValue("gpt-5.1"),
|
||||
reasoningEffort: setRuntimeIntentValue("high" as const),
|
||||
permissionProfile: setRuntimeIntentValue(":workspace"),
|
||||
approvalPolicy: setRuntimeIntentValue("never" as const),
|
||||
approvalsReviewer: setRuntimeIntentValue("auto_review" as const),
|
||||
fastMode: setRuntimeIntentValue("enabled" as const),
|
||||
},
|
||||
};
|
||||
|
||||
const next = commitAppliedRuntimeSettingsPatchState(state, { approvalPolicy: "never" });
|
||||
|
||||
expect(next.active).toMatchObject({
|
||||
...state.active,
|
||||
approvalPolicy: "never",
|
||||
approvalPolicyKnown: true,
|
||||
});
|
||||
expect(next.pending).toMatchObject({
|
||||
...state.pending,
|
||||
approvalPolicy: { kind: "unchanged" },
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves unknown service tier state when committing unrelated settings", () => {
|
||||
const state = requestModelRuntimeState(initialChatRuntimeState(), "gpt-5.1");
|
||||
const next = commitAppliedRuntimeSettingsPatchState(state, { model: "gpt-5.1" });
|
||||
|
|
|
|||
Loading…
Reference in a new issue