Context
preserveExistingObjectOrder() (scripts/write-ui-openapi.ts:38-49) recursively re-orders keys of the freshly generated OpenAPI spec to match the committed file's existing key order, specifically so ui:openapi:check (a hard gate in test:ci, package.json:114) produces a stable diff. The only test referencing this pipeline, test/unit/ci-ui-build-openapi.test.ts, asserts CI workflow text (that ui:openapi:check isn't redundantly re-run) — not the ordering logic itself. A regression in this recursive function (e.g. mishandling a key whose value is undefined, or an array-vs-object shape change between builds) would either produce spurious "stale" failures blocking every PR that touches the API surface, or mask a genuinely stale spec.
Requirements
Add direct unit tests for preserveExistingObjectOrder() covering: a nested-object reorder, a key present in the new spec but not the old (and vice versa), an array-valued key, and an undefined/null-valued key. Follow the template this repo already uses for unit-testing a generator/comparator's pure logic directly — e.g. test/unit/check-branding-drift-script.test.ts.
Deliverables
Test Coverage Requirements
This is the coverage deliverable. Match the existing check-branding-drift-script.test.ts-style direct-unit-test pattern.
Expected Outcome
A regression in the OpenAPI key-ordering logic is caught by a direct unit test instead of only surfacing as a confusing spurious/masked ui:openapi:check CI failure on an unrelated PR.
Links & Resources
scripts/write-ui-openapi.ts:38-49, test/unit/ci-ui-build-openapi.test.ts (existing but non-overlapping coverage), test/unit/check-branding-drift-script.test.ts (the direct-unit-test pattern to follow)
Context
preserveExistingObjectOrder()(scripts/write-ui-openapi.ts:38-49) recursively re-orders keys of the freshly generated OpenAPI spec to match the committed file's existing key order, specifically soui:openapi:check(a hard gate intest:ci,package.json:114) produces a stable diff. The only test referencing this pipeline,test/unit/ci-ui-build-openapi.test.ts, asserts CI workflow text (thatui:openapi:checkisn't redundantly re-run) — not the ordering logic itself. A regression in this recursive function (e.g. mishandling a key whose value isundefined, or an array-vs-object shape change between builds) would either produce spurious "stale" failures blocking every PR that touches the API surface, or mask a genuinely stale spec.Requirements
Add direct unit tests for
preserveExistingObjectOrder()covering: a nested-object reorder, a key present in the new spec but not the old (and vice versa), an array-valued key, and anundefined/null-valued key. Follow the template this repo already uses for unit-testing a generator/comparator's pure logic directly — e.g.test/unit/check-branding-drift-script.test.ts.Deliverables
preserveExistingObjectOrder()in a new or existingtest/unit/*.test.tsfile, covering the cases listed above.Test Coverage Requirements
This is the coverage deliverable. Match the existing
check-branding-drift-script.test.ts-style direct-unit-test pattern.Expected Outcome
A regression in the OpenAPI key-ordering logic is caught by a direct unit test instead of only surfacing as a confusing spurious/masked
ui:openapi:checkCI failure on an unrelated PR.Links & Resources
scripts/write-ui-openapi.ts:38-49,test/unit/ci-ui-build-openapi.test.ts(existing but non-overlapping coverage),test/unit/check-branding-drift-script.test.ts(the direct-unit-test pattern to follow)