fix(ci): repair test-type breakage from generated image actions

The image-actions feature landed with an untyped fetch spy and an unknown
URL argument; newer vitest types surface both. Capture anchor downloads via
a typed mock implementation and coerce the probed block URL. Also add the
toolCallId/itemId fields to the Discord harness's stale local copies of the
onToolStart/onCommandOutput payload types (canonical type already has them).
This commit is contained in:
Peter Steinberger
2026-08-10 10:24:15 -07:00
parent 3d2f134d16
commit 4e5029e43b
3 changed files with 14 additions and 4 deletions
@@ -158,6 +158,8 @@ export type DispatchInboundParams = {
}) => Promise<void> | void;
onReasoningEnd?: () => Promise<void> | void;
onToolStart?: (payload: {
itemId?: string;
toolCallId?: string;
name?: string;
phase?: string;
args?: Record<string, unknown>;
@@ -189,6 +191,7 @@ export type DispatchInboundParams = {
}) => Promise<void> | void;
onApprovalEvent?: (payload: { phase?: string; command?: string }) => Promise<void> | void;
onCommandOutput?: (payload: {
toolCallId?: string;
phase?: string;
name?: string;
title?: string;
@@ -122,7 +122,7 @@ describe("managed image actions Gateway E2E", () => {
height: 84,
});
const authenticated = await fetch(new URL(block.url, fullUrl), {
const authenticated = await fetch(new URL(String(block.url), fullUrl), {
headers: { Authorization: `Bearer ${GATEWAY_TOKEN}` },
});
expect(authenticated.status).toBe(200);
@@ -4574,7 +4574,12 @@ describe("grouped chat rendering", () => {
});
vi.stubGlobal("ClipboardItem", ClipboardItemMock);
vi.stubGlobal("navigator", { clipboard: { write } });
const click = vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => {});
const clickedDownloads: string[] = [];
const click = vi
.spyOn(HTMLAnchorElement.prototype, "click")
.mockImplementation(function (this: HTMLAnchorElement) {
clickedDownloads.push(this.download);
});
const toastHost = document.body.appendChild(document.createElement("openclaw-toast-host"));
const container = document.body.appendChild(document.createElement("div"));
renderAssistantMessage(
@@ -4587,12 +4592,14 @@ describe("grouped chat rendering", () => {
expectElement(container, 'button[aria-label="Download image"]', HTMLButtonElement).click();
await vi.waitFor(() => expect(click).toHaveBeenCalledOnce());
expect(click.mock.instances[0]?.download).toBe("Ticketed image.png");
expect(clickedDownloads[0]).toBe("Ticketed image.png");
expectElement(container, 'button[aria-label="Copy image"]', HTMLButtonElement).click();
await vi.waitFor(() => expect(copiedBlob?.type).toBe("image/png"));
await vi.waitFor(() => expect(toastHost.textContent).toContain("Copied!"));
expect(fetchMock.mock.calls.filter(([url]) => url === ticketedUrl)).toHaveLength(1);
expect(fetchMock.mock.calls.filter((call: unknown[]) => call[0] === ticketedUrl)).toHaveLength(
1,
);
expect(resolveArtifactDownload).toHaveBeenCalledTimes(2);
toastHost.remove();
container.remove();