Files
govoplan-search/webui/scripts/test-search-overlay-structure.mjs
T

27 lines
1.8 KiB
JavaScript

import { readFileSync } from "node:fs";
function assert(condition, message) {
if (!condition) throw new Error(message);
}
const source = readFileSync("src/components/GlobalSearch.tsx", "utf8");
const layoutSource = readFileSync("src/components/searchOverlayLayout.ts", "utf8");
const styles = readFileSync("src/styles/search.css", "utf8");
assert(source.includes("onFocus={handleSourceFocus}"), "focusing the titlebar field opens Search");
assert(source.includes("suppressRestoredFocusRef.current"), "restored dialog focus does not immediately reopen Search");
assert(source.includes("<Dialog"), "Search uses the shared Dialog component");
assert(source.includes("portal"), "the Search dialog portals above the complete shell");
assert(source.includes("calculateSearchOverlayLayout"), "the overlay is anchored to the titlebar field");
assert(source.includes("listSearchProviders"), "the overlay loads the complete filter catalogue");
assert(source.includes("limit: 50"), "the overlay requests full result windows rather than titlebar suggestions");
assert(source.includes("response?.next_cursor"), "the overlay retains cursor pagination");
assert(source.includes('usePlatformUiCapabilities<SearchContextsUiCapability>("search.contexts")'), "contextual Search contributions are consumed");
assert(!source.includes("navigate(`/search"), "normal Search interaction no longer opens a page route");
assert(layoutSource.includes("anchor.left - left"), "desktop input placement is derived from the original field");
assert(styles.includes(".global-search-source.is-overlay-open"), "the original field is hidden while its overlay counterpart is active");
assert(styles.includes(".search-overlay-results-panel"), "full Search results have a bounded overlay panel");
console.log("Search overlay structure checks passed.");