import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { setArtifactsFetch } from "../artifacts/api"; import { jsonResponse } from "../artifacts/http-stub"; import { planTableViewer, tableCatalogPosture } from "./catalog"; import { clampHistogram, MAX_TABLE_PROFILE_BINS, readApproximate } from "./histogram"; import { PROFILE_FORBIDDEN, tableExportPath, tableExportSearch, tableProfilePath, tableProfileSearch, } from "./query"; import type { TableProfile, TableProfileColumn } from "./types"; import { renderTableArtifact } from "./workbench"; import { renderTableZones } from "./zones"; class FakeClassList { readonly tokens = new Set(); constructor(initial?: string) { if (initial) for (const t of initial.split(/\s+/).filter(Boolean)) this.tokens.add(t); } add(...names: string[]): void { for (const n of names) this.tokens.add(n); } contains(name: string): boolean { return this.tokens.has(name); } get value(): string { return [...this.tokens].join(" "); } } class FakeEl { tagName: string; classList: FakeClassList; children: FakeEl[] = []; parent: FakeEl | null = null; dataset: Record = {}; style: Record = {}; attrs: Record = {}; _text = ""; _html = ""; ownerDocument: FakeDoc; isConnected = true; disabled = false; placeholder = ""; value = ""; href = ""; title = ""; onclick: ((ev?: unknown) => void) | null = null; onchange: ((ev?: unknown) => void) | null = null; constructor(tag: string, doc: FakeDoc) { this.tagName = tag.toUpperCase(); this.ownerDocument = doc; this.classList = new FakeClassList(); } get className(): string { return this.classList.value; } set className(value: string) { this.classList = new FakeClassList(value); } get textContent(): string { if (this.children.length) return this.children.map((c) => c.textContent).join(""); return this._text; } set textContent(value: string) { this.children = []; this._text = value == null ? "" : String(value); } get innerHTML(): string { return this._html || this.textContent; } set innerHTML(value: string) { this._html = value; this.children = []; // To a fixed point: one pass leaves `<script>` as `