fix(repository-api): preserve optional fields and schema combinations

This commit is contained in:
2026-09-18 20:44:45 +09:00
parent 8ba89e7cee
commit e6d3905dc6
3 changed files with 136 additions and 28 deletions
@@ -50,6 +50,40 @@ Deno.test("generated repository wrapper validates current Backend JSON", () => {
}
});
Deno.test("repository git optional nullable fields accept omission and null", () => {
const omitted = structuredClone(repositoryList) as Record<string, unknown>;
const omittedItems = omitted.items as Array<Record<string, unknown>>;
omittedItems[0].git = {
status: "available",
dirty: false,
remotes: [],
};
const omittedParsed = parseRepositoryListResponse(omitted);
if (
omittedParsed.items[0]?.git?.head !== undefined ||
omittedParsed.items[0]?.git?.branch !== undefined
) {
throw new Error("omitted git fields were not preserved");
}
const nullable = structuredClone(repositoryList) as Record<string, unknown>;
const nullableItems = nullable.items as Array<Record<string, unknown>>;
nullableItems[0].git = {
status: "available",
head: null,
branch: null,
dirty: false,
remotes: [],
};
const nullableParsed = parseRepositoryListResponse(nullable);
if (
nullableParsed.items[0]?.git?.head !== null ||
nullableParsed.items[0]?.git?.branch !== null
) {
throw new Error("null git fields were not preserved");
}
});
Deno.test("plain HTTP repository source kind fails closed at the JSON boundary", () => {
const stale = structuredClone(repositoryList) as Record<string, unknown>;
const items = stale.items as Array<Record<string, unknown>>;