declare const Deno: { test(name: string, fn: () => Promise | void): void; readTextFile(path: URL): Promise; }; function assert(condition: unknown, message: string): asserts condition { if (!condition) throw new Error(message); } Deno.test("config editor snapshots Svelte proxies before cloning baselines", async () => { const source = await Deno.readTextFile( new URL( "../../src/lib/workspace/config-source/ConfigSourceEditor.svelte", import.meta.url, ), ); assert( source.includes("$state.raw { const source = await Deno.readTextFile( new URL( "../../src/lib/workspace/settings/DecodalSourceEditor.svelte", import.meta.url, ), ); assert( source.includes("let view = $state.raw(null)") && source.includes("if (!host || untrack(() => view)) return"), "imperative EditorView should avoid deep proxying and remain outside the mount effect dependency graph", ); assert( source.includes("new Compartment()") && source.includes("readonlyCompartment.reconfigure") && source.includes("EditorView.editable.of(!nextReadonly)"), "readonly and editable facets should be reconfigured when the prop changes", ); assert( source.includes("syntaxHighlighting(syntaxTheme)") && source.includes("tags.keyword") && source.includes("tags.string"), "Decodal tokens should use an explicit syntax theme", ); assert( source.includes(".cm-cursor, .cm-dropCursor") && source.includes(".cm-selectionBackground") && source.includes("var(--interactive-selected)"), "cursor and selection should be visible against the workspace theme", ); assert( !source.includes("--surface-2") && !source.includes("--text-primary") && !source.includes("--border-subtle"), "CodeMirror theme must use workspace tokens that actually exist", ); assert( source.includes("fixedSchemaWrapperCompartment.reconfigure") && source.includes("fixedSchemaWrapperExtension()") && source.includes("filter: false"), "fixed schema wrapper protection should react to the main source and permit authoritative synchronization", ); }); Deno.test("main config wrapper is an explicit canonical draft conversion", async () => { const source = await Deno.readTextFile( new URL( "../../src/lib/workspace/config-source/ConfigSourceEditor.svelte", import.meta.url, ), ); assert( source.includes("Wrap with WorkspaceConfigSchema") && source.includes("wrapMainWithWorkspaceSchema") && source.includes("fixedSchemaWrapper={mainSchemaWrapped}"), "legacy main sources should offer an explicit conversion before fixed wrapper mode is enabled", ); assert( source.includes("source.trim()") && source.includes("toolchain.format") && source.includes("wrapper staged. Preview and Commit"), "conversion should remain a formatted local draft until the normal commit flow", ); });