config: format sources before commit

This commit is contained in:
2026-08-15 01:28:25 +09:00
parent c5c89795e1
commit 404809ab6e
3 changed files with 143 additions and 35 deletions
@@ -98,3 +98,33 @@ Deno.test("main entrypoint always enables the fixed schema wrapper", async () =>
"the authoritative main source should not require an optional client-side conversion",
);
});
Deno.test("preview and commit format every draft Decodal source", async () => {
const source = await Deno.readTextFile(
new URL(
"../../src/lib/workspace/config-source/ConfigSourceEditor.svelte",
import.meta.url,
),
);
assert(
source.includes("async function formatDraftSources()") &&
source.includes('change.kind === "create" || change.kind === "update"') &&
source.includes('change.kind === "rename"') &&
source.includes('entry.content_type !== "decodal"') &&
source.includes("await toolchain.format(entry.content)"),
"all changed Decodal entries should be formatted rather than only the selected source",
);
assert(
source.includes("await formatDraftSources();") &&
source.includes("await requestCandidatePreview();") &&
source.includes("Committed formatted revision"),
"preview and commit should format first and refresh stale preflight before persistence",
);
assert(
!source.includes(
"Preview the complete candidate successfully before Commit.",
),
"format-driven candidate changes should trigger automatic preflight instead of a dead-end error",
);
});