murashit_codex-panel/tests/features/chat/application/pending-requests/state.test.ts
2026-06-26 21:15:38 +09:00

42 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
type ChatRequestState,
initialChatRequestState,
resolveChatRequest,
} from "../../../../../src/features/chat/application/pending-requests/state";
describe("chat pending request state", () => {
it("ignores stale request resolutions", () => {
const state = initialChatRequestState();
expect(resolveChatRequest(state, 99)).toEqual(state);
});
it("preserves user input drafts when resolving an approval", () => {
const state: ChatRequestState = {
approvals: [
{
requestId: 1,
kind: "command",
turnId: "turn",
title: "Command approval",
summary: "pwd",
resultSummary: "pwd",
details: [{ key: "command", value: "pwd" }],
responses: { accept: {}, acceptSession: {}, decline: {}, cancel: {} },
actionOptions: null,
},
],
pendingUserInputs: [],
pendingMcpElicitations: [],
userInputDrafts: new Map([["2:note", "draft"]]),
mcpElicitationDrafts: new Map(),
};
const next = resolveChatRequest(state, 1);
expect(next.approvals).toEqual([]);
expect([...next.userInputDrafts]).toEqual([["2:note", "draft"]]);
});
});