import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { SessionAutomationJob } from "@/lib/types"; const job: SessionAutomationJob = { id: "job-1", name: "Morning check", enabled: true, schedule: { kind: "every", every_ms: 3_600_000 }, payload: { message: "Check the project status" }, state: { next_run_at_ms: Date.now() + 3_600_000 }, }; let release: (() => void) | undefined; let moduleLoad: Promise | undefined; async function loadView(fail = false) { const loaded = vi.fn(); const gate = new Promise((resolve) => { release = resolve; }); vi.doMock("@/components/settings/system/AutomationsSettings", (original) => { loaded(); moduleLoad = gate.then(() => { if (fail) throw new Error("Automation chunk unavailable"); return original(); }); return moduleLoad; }); const { initializeI18n, loadAllLocaleResources } = await import("@/i18n"); await initializeI18n(); await loadAllLocaleResources(); const { SessionInfoPopoverView } = await import("@/components/thread/SessionInfoPopoverView"); render(<>