mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-21 21:56:46 +00:00
test: guard cron auth profile helper
This commit is contained in:
@@ -17,6 +17,21 @@ vi.mock("../plugins/provider-runtime.js", () => ({
|
||||
resolveExternalAuthProfilesWithPlugins: () => [],
|
||||
}));
|
||||
|
||||
function getEmbeddedPiAgentParams(): {
|
||||
authProfileId?: string;
|
||||
authProfileIdSource?: string;
|
||||
} {
|
||||
const [call] = vi.mocked(runEmbeddedPiAgent).mock.calls;
|
||||
if (!call) {
|
||||
throw new Error("Expected embedded PI agent call for auth profile propagation");
|
||||
}
|
||||
const [params] = call;
|
||||
if (typeof params !== "object" || params === null || Array.isArray(params)) {
|
||||
throw new Error("Expected embedded PI agent params to be an object");
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
describe("runCronIsolatedAgentTurn auth profile propagation (#20624)", () => {
|
||||
beforeEach(() => {
|
||||
setupIsolatedAgentTurnMocks({ fast: true });
|
||||
@@ -84,15 +99,7 @@ describe("runCronIsolatedAgentTurn auth profile propagation (#20624)", () => {
|
||||
expect(vi.mocked(runEmbeddedPiAgent)).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 5. Check that authProfileId was passed
|
||||
const callArgs = vi.mocked(runEmbeddedPiAgent).mock.calls[0]?.[0] as
|
||||
| {
|
||||
authProfileId?: string;
|
||||
authProfileIdSource?: string;
|
||||
}
|
||||
| undefined;
|
||||
if (!callArgs) {
|
||||
throw new Error("Expected embedded PI agent call for auth profile propagation");
|
||||
}
|
||||
const callArgs = getEmbeddedPiAgentParams();
|
||||
|
||||
expect(callArgs.authProfileId).toBe("openrouter:default");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user