From bdd6cf3d5e39db626a294dab515ac2f880698d3a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 1 Jun 2026 09:38:50 -0400 Subject: [PATCH] test: stabilize order-sensitive assertions --- .../auto-reply.web-auto-reply.last-route.test.ts | 2 +- ui/src/ui/chat/grouped-render.test.ts | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts b/extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts index e7e0047e6463..e1ef9e3e54cb 100644 --- a/extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts +++ b/extensions/whatsapp/src/auto-reply.web-auto-reply.last-route.test.ts @@ -166,7 +166,7 @@ describe("web auto-reply last-route", () => { SenderE164: "+1000", SenderId: "+1000", RawBody: "hello", - Body: expect.stringMatching(/^\[WhatsApp \+1000 .+\] hello$/), + Body: expect.stringMatching(/^\[WhatsApp \+1000 .+\] \+1000: hello$/), BodyForAgent: "hello", CommandBody: "hello", Timestamp: now, diff --git a/ui/src/ui/chat/grouped-render.test.ts b/ui/src/ui/chat/grouped-render.test.ts index 7f97c6996ae2..f4abcd722d99 100644 --- a/ui/src/ui/chat/grouped-render.test.ts +++ b/ui/src/ui/chat/grouped-render.test.ts @@ -1553,6 +1553,8 @@ describe("grouped chat rendering", () => { it("fetches managed chat images with auth and renders blob previews", async () => { resetAssistantAttachmentAvailabilityCacheForTest(); + const managedChatImageUrl = + "/api/chat/media/outgoing/agent%3Amain%3Amain/00000000-0000-4000-8000-000000000000/full"; const objectUrl = "blob:managed-image"; vi.stubGlobal( "URL", @@ -1580,7 +1582,7 @@ describe("grouped chat rendering", () => { content: [ { type: "image", - url: "/api/chat/media/outgoing/agent%3Amain%3Amain/00000000-0000-4000-8000-000000000000/full", + url: managedChatImageUrl, alt: "Generated image 1", width: 1, height: 1, @@ -1603,12 +1605,12 @@ describe("grouped chat rendering", () => { { interval: 1, timeout: 100 }, ); expect(fetchMock).toHaveBeenCalled(); - for (const [fetchUrl, fetchInit] of fetchMock.mock.calls as [string, RequestInit?][]) { - expect(fetchUrl).toBe( - "/api/chat/media/outgoing/agent%3Amain%3Amain/00000000-0000-4000-8000-000000000000/full", - ); - expectSameOriginGet(fetchInit); - } + const fetchedUrls = fetchMock.mock.calls.map(([url]) => url); + expect( + fetchedUrls.filter((url) => url !== managedChatImageUrl && url !== "/avatar/main?meta=1"), + ).toEqual([]); + const [, fetchInit] = requireFetchCallForUrl(fetchMock, managedChatImageUrl); + expectSameOriginGet(fetchInit); }); it("does not send auth to cross-origin managed-image-looking URLs", () => {