test: share sessions list details helper

This commit is contained in:
Peter Steinberger
2026-04-19 03:00:06 +01:00
parent e28984c74a
commit e39af9545f

View File

@@ -30,6 +30,27 @@ vi.mock("./sessions-helpers.js", async (importActual) => {
};
});
type SessionsListDetails = {
sessions?: Array<{
deliveryContext?: {
accountId?: string;
channel?: string;
threadId?: string | number;
to?: string;
};
elevatedLevel?: string;
fastMode?: boolean;
reasoningLevel?: string;
responseUsage?: string;
thinkingLevel?: string;
verboseLevel?: string;
}>;
};
function getSessionsListDetails(result: { details?: unknown }): SessionsListDetails {
return result.details as SessionsListDetails;
}
describe("sessions-list-tool", () => {
let createSessionsListTool: typeof import("./sessions-list-tool.js").createSessionsListTool;
@@ -89,16 +110,7 @@ describe("sessions-list-tool", () => {
const tool = createSessionsListTool({ config: {} as never });
const result = await tool.execute("call-1", {});
const details = result.details as {
sessions?: Array<{
deliveryContext?: {
channel?: string;
to?: string;
accountId?: string;
threadId?: string | number;
};
}>;
};
const details = getSessionsListDetails(result);
expect(details.sessions?.[0]?.deliveryContext).toEqual({
channel: "discord",
@@ -140,16 +152,7 @@ describe("sessions-list-tool", () => {
const tool = createSessionsListTool({ config: {} as never });
const result = await tool.execute("call-2", {});
const details = result.details as {
sessions?: Array<{
deliveryContext?: {
channel?: string;
to?: string;
accountId?: string;
threadId?: string | number;
};
}>;
};
const details = getSessionsListDetails(result);
expect(details.sessions?.[0]?.deliveryContext).toEqual({
channel: "telegram",
@@ -185,16 +188,7 @@ describe("sessions-list-tool", () => {
const tool = createSessionsListTool({ config: {} as never });
const result = await tool.execute("call-3", {});
const details = result.details as {
sessions?: Array<{
thinkingLevel?: string;
fastMode?: boolean;
verboseLevel?: string;
reasoningLevel?: string;
elevatedLevel?: string;
responseUsage?: string;
}>;
};
const details = getSessionsListDetails(result);
expect(details.sessions?.[0]).toMatchObject({
thinkingLevel: "high",