Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

test(web): drain input-otp timers before cleanup in verify-otp

justina039849342c8
diff --git a/apps/web/src/routes/auth/verify-otp.test.tsx b/apps/web/src/routes/auth/verify-otp.test.tsx
index 83d94ecd8..7b7b17db2 100644
--- a/apps/web/src/routes/auth/verify-otp.test.tsx
+++ b/apps/web/src/routes/auth/verify-otp.test.tsx
@@ -1,4 +1,5 @@
import {
+ act,
cleanup,
fireEvent,
render,
@@ -76,7 +77,16 @@ beforeEach(() => {
emailOtp.mockResolvedValue({ data: {}, error: null });
});
-afterEach(() => {
+afterEach(async () => {
+ // input-otp schedules internal timers (0ms, 2s, 5s, 6s) for password
+ // manager detection when the input focuses. The 0ms timer can fire after
+ // vitest tears down the jsdom environment, which surfaces as an
+ // unhandled "window is not defined" error. Drain pending timers inside
+ // act() so React's pending updates flush and the timer calls complete
+ // before cleanup runs.
+ await act(async () => {
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ });
cleanup();
emailOtp.mockReset();
push.mockReset();