mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
test: repair hosted CI baseline assertions (#98533)
This commit is contained in:
committed by
GitHub
parent
cf2efbe5d5
commit
aae1189d90
@@ -5,7 +5,7 @@ import type { CliDeps } from "../cli/deps.types.js";
|
||||
import type { CronJob } from "../cron/types.js";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
fetchWithSsrFGuard: vi.fn(async () => ({ release: vi.fn() })),
|
||||
fetchWithSsrFGuard: vi.fn(async (_request: unknown) => ({ release: vi.fn() })),
|
||||
sendFailureNotificationAnnounce: vi.fn(),
|
||||
}));
|
||||
|
||||
@@ -33,7 +33,10 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
function webhookRequestBody() {
|
||||
const request = requireRecord(mocks.fetchWithSsrFGuard.mock.calls[0]?.[0], "webhook request");
|
||||
const init = requireRecord(request.init, "webhook request init");
|
||||
return JSON.parse(String(init.body));
|
||||
if (typeof init.body !== "string") {
|
||||
throw new Error("expected webhook request body");
|
||||
}
|
||||
return JSON.parse(init.body);
|
||||
}
|
||||
|
||||
describe("dispatchGatewayCronFinishedNotifications", () => {
|
||||
|
||||
@@ -41,7 +41,7 @@ const {
|
||||
summary: "ok",
|
||||
})),
|
||||
cleanupBrowserSessionsForLifecycleEndMock: vi.fn(async () => {}),
|
||||
runCronChangedMock: vi.fn(async () => {}),
|
||||
runCronChangedMock: vi.fn(async (_event: unknown, _context?: unknown) => {}),
|
||||
getGlobalHookRunnerMock: vi.fn(() => ({
|
||||
hasHooks: (hookName: string) => hookName === "cron_changed",
|
||||
runCronChanged: runCronChangedMock,
|
||||
@@ -623,7 +623,7 @@ describe("buildGatewayCronService", () => {
|
||||
const event = runCronChangedMock.mock.calls
|
||||
.map((call) => requireRecord(call[0], "cron_changed event"))
|
||||
.find((hookEvent) => hookEvent.action === "finished");
|
||||
const summary = String(event?.summary ?? "");
|
||||
const summary = typeof event?.summary === "string" ? event.summary : "";
|
||||
expect(summary).toContain("[redacted-url]");
|
||||
expect(summary).toContain("[redacted-code]");
|
||||
expect(summary).toContain("token=***");
|
||||
@@ -673,7 +673,7 @@ describe("buildGatewayCronService", () => {
|
||||
callArg(sendCronAnnouncePayloadStrictMock, 0, 0, "cron announce payload"),
|
||||
"cron announce payload",
|
||||
);
|
||||
const message = String(announcePayload.message ?? "");
|
||||
const message = typeof announcePayload.message === "string" ? announcePayload.message : "";
|
||||
expect(message).toContain("token=***");
|
||||
expect(message).not.toContain("opaque-secret-value");
|
||||
} finally {
|
||||
|
||||
@@ -425,7 +425,7 @@ describe("Anthropic provider", () => {
|
||||
timestamp: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
} as unknown as Context,
|
||||
{
|
||||
apiKey: "sk-ant-provider",
|
||||
onPayload: (payload) => {
|
||||
|
||||
@@ -295,7 +295,8 @@ describe("Mistral provider", () => {
|
||||
const toolContent = Array.isArray(toolMessage!.content) ? toolMessage!.content : [];
|
||||
const textBlock = toolContent.find((block) => block.type === "text");
|
||||
expect(textBlock?.text).toEqual(expect.stringContaining('{"type":"resource"'));
|
||||
expect(textBlock?.text).toContain('{\\"key\\":\\"value\\"}');
|
||||
expect(textBlock?.text).toContain('{\\"key\\":\\"***\\"}');
|
||||
expect(textBlock?.text).not.toContain('{\\"key\\":\\"value\\"}');
|
||||
});
|
||||
|
||||
it("serializes structured-only tool results instead of empty fallback", async () => {
|
||||
|
||||
Reference in New Issue
Block a user