fix: empty changeset must serialize as [] not null (white-screen after snapshot)
toChangesetResponse initialises updates/prunes/readOnly so a zone matching its template exactly (e.g. right after 'create template from zone') marshals arrays, not null. DiffView/DomainDiffPage also normalise null defensively. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BwxdSt4reTm7Dj1oxRvpP3
This commit is contained in:
@@ -26,3 +26,17 @@ test("marks read-only records", () => {
|
||||
render(<DiffView changeset={cs} />)
|
||||
expect(screen.getByText(/NS/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
test("does not crash when changeset fields are null", () => {
|
||||
// An empty changeset from an older/edge backend can arrive with null slices
|
||||
// instead of []. DiffView must normalise them, not blow up on .length/.map.
|
||||
const nullish = {
|
||||
updates: null,
|
||||
prunes: null,
|
||||
readOnly: null,
|
||||
inSyncCount: 5,
|
||||
} as unknown as ChangesetResponse
|
||||
render(<DiffView changeset={nullish} />)
|
||||
expect(screen.getByText(/5/)).toBeInTheDocument()
|
||||
expect(screen.getByText(/in sync/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user