import assert from "node:assert/strict";
import path from "node:path";
import { existsSync } from "node:fs";
import { createRequire } from "node:module";
import { fileURLToPath } from "node:url";
import { build } from "esbuild";
import { chromium } from "@playwright/test";
import { fillRoutineCreateForm, enableRoutineScheduleTrigger, setRoutineScheduleEnabled } from "./routine-schedule-ui.ts";
// Render the production form, entity pickers, schedule rows and Radix primitives.
// Only unrelated display/editor boundaries are replaced. No app, provider or QA
// credential is needed. The full journey retains independent API readback/grades.
const root = fileURLToPath(new URL("../../../", import.meta.url));
const uiRoot = path.join(root, "ui");
const uiRequire = createRequire(path.join(uiRoot, "package.json"));
const stubs = {
"@/components/AgentAvatar": "export const AgentAvatar = () => null;",
"@/components/Identity": "export const deriveInitials = name => name.slice(0, 2);",
"@/lib/utils": "export const cn = (...values) => values.filter(Boolean).join(' ');",
"../lib/utils": "export const cn = (...values) => values.filter(Boolean).join(' ');",
"@/lib/router": "export const Link = ({to, children, ...props}) => {children};",
"@/components/MarkdownBody": "export const MarkdownBody = () => null;",
"@/components/AgentActionButtons": "export const RunButton = () => null;",
"@/components/TaskSummaryList": "export const TaskSummaryList = () => null;",
"@/components/MarkdownEditor": `export const MarkdownEditor = ({value, onChange, ariaLabel}) =>