Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import { act, renderHook } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import type { AgentConversationVM } from "../../../shared/agentConversation/contracts/agentConversationVM";
|
|
import type { AgentGUINodeViewModel } from "../model/agentGuiNodeTypes";
|
|
import type { AgentGUINodeViewProps } from "./AgentGUINodeView.types";
|
|
import { useAgentGUIComposerInputHistoryProps } from "./useAgentGUIComposerInputHistoryProps";
|
|
|
|
describe("useAgentGUIComposerInputHistoryProps", () => {
|
|
it("keeps history disabled until the host opts in", () => {
|
|
const timeline = document.createElement("div");
|
|
Object.defineProperties(timeline, {
|
|
scrollHeight: { value: 900 },
|
|
scrollTop: { value: 120, writable: true }
|
|
});
|
|
const loadOlderConversationMessages = vi.fn();
|
|
const pendingPrependScrollAnchorRef = { current: null };
|
|
const input = {
|
|
actions: {
|
|
loadOlderConversationMessages
|
|
} as unknown as AgentGUINodeViewProps["actions"],
|
|
conversation: conversationWithPrompt(),
|
|
pendingPrependScrollAnchorRef,
|
|
timelineRef: { current: timeline },
|
|
viewModel: {
|
|
rail: { activeConversationId: "session-1" },
|
|
detail: {
|
|
hasOlderMessages: true,
|
|
isLoadingOlderMessages: false
|
|
}
|
|
} as AgentGUINodeViewModel
|
|
};
|
|
const { result, rerender } = renderHook(
|
|
({ enabled }) =>
|
|
useAgentGUIComposerInputHistoryProps({ ...input, enabled }),
|
|
{ initialProps: { enabled: false } }
|
|
);
|
|
|
|
expect(result.current).toEqual({
|
|
inputHistory: [],
|
|
inputHistoryHasOlderPage: false,
|
|
inputHistoryIsLoadingOlderPage: false,
|
|
onRequestOlderInputHistoryPage: undefined
|
|
});
|
|
|
|
rerender({ enabled: true });
|
|
|
|
expect(result.current.inputHistory).toHaveLength(1);
|
|
act(() => {
|
|
result.current.onRequestOlderInputHistoryPage?.();
|
|
});
|
|
expect(loadOlderConversationMessages).toHaveBeenCalledOnce();
|
|
expect(pendingPrependScrollAnchorRef.current).toEqual({
|
|
conversationId: "session-1",
|
|
scrollHeight: 900,
|
|
scrollTop: 120
|
|
});
|
|
});
|
|
});
|
|
|
|
function conversationWithPrompt(): AgentConversationVM {
|
|
return {
|
|
sourceDetail: {
|
|
turns: [
|
|
{
|
|
id: "turn-1",
|
|
userMessages: [{ id: "message-1", body: "hello" }]
|
|
}
|
|
]
|
|
}
|
|
} as unknown as AgentConversationVM;
|
|
}
|