Skip to content

preserveExistingObjectOrder() in write-ui-openapi.ts has zero direct unit tests despite gating every PR touching the API surface #7770

Description

@JSONbored

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

  • New unit tests for preserveExistingObjectOrder() in a new or existing test/unit/*.test.ts file, 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: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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions