test: stabilize order-sensitive assertions

This commit is contained in:
Peter Steinberger
2026-06-01 09:38:50 -04:00
parent cb7a4239ef
commit bdd6cf3d5e
2 changed files with 10 additions and 8 deletions

View File

@@ -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,

View File

@@ -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", () => {