import { describe, it, expect, vi, beforeEach } from "vitest"; import { render, screen, fireEvent, waitFor, act } from "@testing-library/react"; import { DbViewerScreen, deriveStagedValues, derivePendingCellKeys, pickDisplayColumn, } from "./DbViewerScreen"; import { useDbViewerStore } from "../../stores/dbViewerStore"; import { useUiStore } from "../../stores/uiStore"; import * as commands from "../../lib/commands"; vi.mock("../../hooks/useDbConnection", () => ({ useDbConnection: (_connectionId: string) => ({ connectionError: null, connect: vi.fn(), }), })); vi.mock("@tanstack/react-virtual", () => ({ useVirtualizer: ({ count }: any) => ({ getVirtualItems: () => count > 0 ? Array.from({ length: count }, (_, i) => ({ key: i, index: i, start: i * 36, size: 36, })) : [], getTotalSize: () => count * 36, measureElement: () => {}, }), })); const { registeredActions } = vi.hoisted(() => ({ registeredActions: [] as Array<{ run: () => void }>, })); // monaco-editor's global font re-measure — stub so jsdom stays light vi.mock("monaco-editor", () => ({ editor: { remeasureFonts: vi.fn() }, })); vi.mock("@monaco-editor/react", async () => { const { useEffect } = await import("react"); return { default: ({ value, onChange, onMount }: any) => { useEffect(() => { onMount?.({ addAction: (action: any) => registeredActions.push(action), getValue: () => value, setValue: (v: string) => onChange?.(v), focus: () => {}, }); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return (