Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

test(reading): flush optional tool updates before assertions

Bingxi Zhao (Frank)b4cfe8e82089
diff --git a/web/tests/workspace-chat-actions-hidden-capability.spec.tsx b/web/tests/workspace-chat-actions-hidden-capability.spec.tsx
index 6a7a7aa5f..ad287f1ff 100644
--- a/web/tests/workspace-chat-actions-hidden-capability.spec.tsx
+++ b/web/tests/workspace-chat-actions-hidden-capability.spec.tsx
@@ -1,4 +1,4 @@
-import { renderHook } from "@testing-library/react";
+import { act, renderHook } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { CHAT_CAPABILITIES } from "@/features/capabilities/presentation";
@@ -39,35 +39,39 @@ describe("useWorkspaceChatActions with a stored action the workspace hides", ()
captured.setCapability.mockClear();
});
- it("sends Chat when Course Study is carried into Reading", () => {
+ it("sends Chat when Course Study is carried into Reading", async () => {
captured.activeCapability = "course_study";
const { result } = renderHook(() => useWorkspaceChatActions());
+ await act(async () => {});
expect(result.current.activeCapabilityValue).toBe("");
expect(captured.setCapability).toHaveBeenCalledWith(null);
});
- it("keeps an action the workspace offers", () => {
+ it("keeps an action the workspace offers", async () => {
captured.activeCapability = "deep_solve";
const { result } = renderHook(() => useWorkspaceChatActions());
+ await act(async () => {});
expect(result.current.activeCapabilityValue).toBe("deep_solve");
expect(captured.setCapability).not.toHaveBeenCalled();
});
- it("waits for the catalog before resetting an unknown action", () => {
+ it("waits for the catalog before resetting an unknown action", async () => {
captured.activeCapability = "plugin_only_action";
captured.catalogLoading = true;
renderHook(() => useWorkspaceChatActions());
+ await act(async () => {});
expect(captured.setCapability).not.toHaveBeenCalled();
});
- it("still asserts a pinned action", () => {
+ it("still asserts a pinned action", async () => {
captured.activeCapability = "course_study";
renderHook(() =>
useWorkspaceChatActions({ pinnedCapability: "mastery_path" }),
);
+ await act(async () => {});
expect(captured.setCapability).toHaveBeenCalledWith("mastery_path");
expect(captured.setCapability).not.toHaveBeenCalledWith(null);