mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 21:04:45 +00:00
test: guard discord thread title mock calls
This commit is contained in:
@@ -11,6 +11,16 @@ const extractAssistantTextMock = vi.fn<typeof agentRuntimeModule.extractAssistan
|
||||
|
||||
let generateThreadTitle: typeof import("./thread-title.js").generateThreadTitle;
|
||||
|
||||
function firstCompletionArgs(): Parameters<
|
||||
typeof agentRuntimeModule.completeWithPreparedSimpleCompletionModel
|
||||
>[0] {
|
||||
const firstCall = completeWithPreparedSimpleCompletionModelMock.mock.calls.at(0);
|
||||
if (!firstCall) {
|
||||
throw new Error("expected completion call");
|
||||
}
|
||||
return firstCall[0];
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
({ generateThreadTitle } = await import("./thread-title.js"));
|
||||
});
|
||||
@@ -162,10 +172,7 @@ describe("generateThreadTitle", () => {
|
||||
|
||||
expect(result).toBe("Generated title");
|
||||
expect(completeWithPreparedSimpleCompletionModelMock).toHaveBeenCalledTimes(1);
|
||||
const completionArgs = completeWithPreparedSimpleCompletionModelMock.mock.calls[0]?.[0];
|
||||
if (!completionArgs) {
|
||||
throw new Error("expected completion call");
|
||||
}
|
||||
const completionArgs = firstCompletionArgs();
|
||||
expect(completionArgs.context).toEqual({
|
||||
systemPrompt:
|
||||
"Generate a concise Discord thread title (3-6 words). Return only the title. Use channel context when provided and avoid redundant channel-name words unless needed for clarity.",
|
||||
|
||||
Reference in New Issue
Block a user