Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(frontend): await the onImagesChange assertion in ThumbnailImages local-media test (#14529)

Reinier van der Leer977d605432e1
diff --git a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/components/__tests__/ThumbnailImages.local-media.test.tsx b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/components/__tests__/ThumbnailImages.local-media.test.tsx
index 9924cbb84c..71dd965d2e 100644
--- a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/components/__tests__/ThumbnailImages.local-media.test.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/components/__tests__/ThumbnailImages.local-media.test.tsx
@@ -1,5 +1,10 @@
import { afterEach, describe, expect, it, vi } from "vitest";
-import { fireEvent, render, screen } from "@/tests/integrations/test-utils";
+import {
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@/tests/integrations/test-utils";
import { ThumbnailImages } from "../ThumbnailImages";
vi.mock("next/image", async () => {
@@ -38,7 +43,8 @@ describe("local marketplace image previews", () => {
const image = await screen.findByRole("img", { name: "Thumbnail 1" });
expect(image.getAttribute("src")).toBe(url);
expect(image.hasAttribute("srcset")).toBe(false);
- expect(onImagesChange).toHaveBeenCalledWith([url]);
+ // The image commits before the effect that reports it; a bare assert races it.
+ await waitFor(() => expect(onImagesChange).toHaveBeenCalledWith([url]));
});
it("keeps GCS thumbnails optimized", () => {