test(ui): repair routine tests for React 19 act

This commit is contained in:
Dotta committed 2026-06-09 23:00:54 +00:00
1 parent f5e4483782
commit 33b6f9704c
3 files changed
+22 -3

No files matched your search

+6 -1
View File
@@ -1,11 +1,16 @@
// @vitest-environment jsdom
import { act } from "react";
import type React from "react";
import { flushSync } from "react-dom";
import { createRoot } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { RoutineSaveBar } from "./RoutineSaveBar";
import type { RoutineHistoryDirtyFieldDescriptor } from "./RoutineHistoryTab";
function act(callback: () => void) {
flushSync(callback);
}
let container: HTMLDivElement;
let root: ReturnType<typeof createRoot>;
+6 -1
View File
@@ -1,6 +1,7 @@
// @vitest-environment jsdom
import { act, type AnchorHTMLAttributes, type ReactNode } from "react";
import type { AnchorHTMLAttributes, ReactNode } from "react";
import { flushSync } from "react-dom";
import { createRoot } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -22,6 +23,10 @@ vi.mock("@/lib/router", () => ({
import { RoutineSubSidebar } from "./RoutineSubSidebar";
import type { RoutineSectionKey } from "./routine-sections/context";
function act(callback: () => void) {
flushSync(callback);
}
let container: HTMLDivElement;
let root: ReturnType<typeof createRoot>;
+10 -1
View File
@@ -1,6 +1,7 @@
// @vitest-environment jsdom
import { act, type AnchorHTMLAttributes, type ReactNode } from "react";
import type { AnchorHTMLAttributes, ReactNode } from "react";
import { flushSync } from "react-dom";
import { createRoot } from "react-dom/client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import type { Issue, RoutineListItem } from "@paperclipai/shared";
@@ -9,6 +10,14 @@ import { Routines, buildRoutineGroups, sortRoutines } from "./Routines";
let currentSearch = "";
async function act(callback: () => void | Promise<void>) {
let result: void | Promise<void> = undefined;
flushSync(() => {
result = callback();
});
await result;
}
const navigateMock = vi.fn();
const routinesListMock = vi.fn<(companyId: string) => Promise<RoutineListItem[]>>();
const issuesListMock = vi.fn<(companyId: string, filters?: Record<string, unknown>) => Promise<Issue[]>>();