mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-22 06:08:13 +00:00
test: guard acp startup mock calls
This commit is contained in:
@@ -165,6 +165,18 @@ describe("serveAcpGateway startup", () => {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
function getGatewayBootstrapParams(): { env?: unknown; gatewayUrl?: unknown } {
|
||||
const firstCall = mockState.resolveGatewayClientBootstrap.mock.calls.at(0);
|
||||
if (!firstCall) {
|
||||
throw new Error("Expected gateway bootstrap resolution call");
|
||||
}
|
||||
const params = firstCall.at(0);
|
||||
if (!params || typeof params !== "object") {
|
||||
throw new Error("Expected gateway bootstrap params");
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
function captureProcessSignalHandlers() {
|
||||
const signalHandlers = new Map<NodeJS.Signals, () => void>();
|
||||
const onceSpy = vi.spyOn(process, "once").mockImplementation(((
|
||||
@@ -307,10 +319,8 @@ describe("serveAcpGateway startup", () => {
|
||||
const servePromise = serveAcpGateway({});
|
||||
await Promise.resolve();
|
||||
|
||||
const bootstrapParams = mockState.resolveGatewayClientBootstrap.mock.calls[0]?.[0] as
|
||||
| { env?: unknown }
|
||||
| undefined;
|
||||
expect(bootstrapParams?.env).toBe(process.env);
|
||||
const bootstrapParams = getGatewayBootstrapParams();
|
||||
expect(bootstrapParams.env).toBe(process.env);
|
||||
expect(mockState.gatewayAuth[0]).toEqual({
|
||||
token: undefined,
|
||||
password: "resolved-secret-password", // pragma: allowlist secret
|
||||
@@ -332,11 +342,9 @@ describe("serveAcpGateway startup", () => {
|
||||
});
|
||||
await Promise.resolve();
|
||||
|
||||
const bootstrapParams = mockState.resolveGatewayClientBootstrap.mock.calls[0]?.[0] as
|
||||
| { env?: unknown; gatewayUrl?: unknown }
|
||||
| undefined;
|
||||
expect(bootstrapParams?.env).toBe(process.env);
|
||||
expect(bootstrapParams?.gatewayUrl).toBe("wss://override.example/ws");
|
||||
const bootstrapParams = getGatewayBootstrapParams();
|
||||
expect(bootstrapParams.env).toBe(process.env);
|
||||
expect(bootstrapParams.gatewayUrl).toBe("wss://override.example/ws");
|
||||
|
||||
await emitHelloAndWaitForAgentSideConnection();
|
||||
await stopServeWithSigint(signalHandlers, servePromise);
|
||||
|
||||
Reference in New Issue
Block a user