mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 16:44:45 +00:00
test: guard gateway runtime assertions
This commit is contained in:
@@ -651,7 +651,9 @@ describe("buildGatewayCronService", () => {
|
||||
?.sessionKey;
|
||||
const wakeOpts = wakeCall?.[0] as { agentId?: string; sessionKey?: string } | undefined;
|
||||
|
||||
expect(enqueueSessionKey).toBeDefined();
|
||||
if (!enqueueSessionKey) {
|
||||
throw new Error("Expected enqueue session key");
|
||||
}
|
||||
expect(enqueueSessionKey).toMatch(/^agent:ops:/);
|
||||
expect(wakeOpts?.agentId).toBe("ops");
|
||||
expect(wakeOpts?.sessionKey).toMatch(/^agent:ops:/);
|
||||
|
||||
@@ -189,8 +189,9 @@ describe("server-runtime-services", () => {
|
||||
expect(log.child).toHaveBeenNthCalledWith(2, "session-delivery-recovery");
|
||||
const deliveryLog = log.child.mock.results[0]?.value;
|
||||
const sessionDeliveryLog = log.child.mock.results[1]?.value;
|
||||
expect(deliveryLog).toBeDefined();
|
||||
expect(sessionDeliveryLog).toBeDefined();
|
||||
if (!deliveryLog || !sessionDeliveryLog) {
|
||||
throw new Error("Expected delivery recovery log children");
|
||||
}
|
||||
expect(hoisted.recoverPendingDeliveries).toHaveBeenCalledWith({
|
||||
deliver: hoisted.deliverOutboundPayloads,
|
||||
cfg: {},
|
||||
|
||||
@@ -131,9 +131,9 @@ describe("gateway server chat", () => {
|
||||
.filter((value): value is string => typeof value === "string");
|
||||
|
||||
const expectRecordFields = (value: unknown, expected: Record<string, unknown>) => {
|
||||
expect(value).toBeDefined();
|
||||
expect(typeof value).toBe("object");
|
||||
expect(value).not.toBeNull();
|
||||
if (!value || typeof value !== "object") {
|
||||
throw new Error("Expected record");
|
||||
}
|
||||
const actual = value as Record<string, unknown>;
|
||||
for (const [key, expectedValue] of Object.entries(expected)) {
|
||||
expect(actual[key]).toEqual(expectedValue);
|
||||
@@ -973,7 +973,9 @@ describe("gateway server chat", () => {
|
||||
message !== null &&
|
||||
(message as { role?: unknown }).role === "assistant",
|
||||
);
|
||||
expect(assistantMessage).toBeDefined();
|
||||
if (!assistantMessage) {
|
||||
throw new Error("Expected assistant history message");
|
||||
}
|
||||
});
|
||||
const assistantContent = (assistantMessage as { content?: unknown[] }).content ?? [];
|
||||
expect(assistantContent).toHaveLength(2);
|
||||
|
||||
Reference in New Issue
Block a user