Skip to content

"Vibe-Trading: Your Personal Trading Agent"

test(frontend): wait on the sector re-render, not on the spinner disappearing

Haozhe Wu20a2d514e8f9
diff --git a/frontend/src/components/run/__tests__/PositionsTab.test.tsx b/frontend/src/components/run/__tests__/PositionsTab.test.tsx
index a07697fab..d6e011ce4 100644
--- a/frontend/src/components/run/__tests__/PositionsTab.test.tsx
+++ b/frontend/src/components/run/__tests__/PositionsTab.test.tsx
@@ -221,15 +221,18 @@ describe("PositionsTab", () => {
fireEvent.click(screen.getByRole("button", { name: "Resolve industries" }));
+ // Wait on the re-render itself, not on the spinner going away: when the
+ // stubbed fetch settles before waitFor's first poll, "Resolving..." is never
+ // observed, the wait returns immediately and the sector chart has not been
+ // re-rendered yet.
await waitFor(() => {
- expect(screen.queryByText("Resolving...")).not.toBeInTheDocument();
+ expect(barCategoryAxes().some((names) => names.includes("白酒Ⅱ"))).toBe(true);
});
expect(fetchMock).toHaveBeenCalledWith(
"/runs/run-test/positions/sectors",
expect.objectContaining({ headers: expect.anything() }),
);
- expect(barCategoryAxes().some((names) => names.includes("白酒Ⅱ"))).toBe(true);
});
it("shows an inline retryable error when sector resolution fails", async () => {