fix(frontend): order proposed changes list newest-first

Merged
BI
4mo ago
+104-1

Why

The proposed changes list came back in an arbitrary order (node UUID), so
recently created proposed changes were buried instead of appearing at the top —
most visible on the Closed tab. Neither the ProposedChange schema nor the list
query specified any ordering.

Goal: list proposed changes newest-first on both the Opened and Closed tabs.

Non-goals: does not add a user-facing sort/filter control, and does not add
date-based filtering (the other half of the issue) — only default ordering.

Refs #9915

What changed

  • Proposed changes now display newest-first (by creation date) on both the
    Opened and Closed tabs, and in the homepage widget.
  • Implemented by requesting order: { by: [{ field: node_metadata__created_at, direction: DESC }] } in the list query builder.

Implementation notes:

  • Frontend-only — consumes the existing GraphQL order argument, so no
    schema change
    and no change to ordering for any other API/SDK consumer.
  • Ordering is by creation time, not close time, so it's stable against later
    edits; on the Closed tab the most-recently-closed item is not floated to
    the top (accepted tradeoff).
  • Pagination stays stable — the backend still appends n.uuid as a tiebreaker.

How to test

# e2e (needs a local image built from this branch)
INFRAHUB_IMAGE_VER=e2e-pytest uv run invoke dev.build
INFRAHUB_TESTING_IMAGE_VER=e2e-pytest INFRAHUB_TESTING_DOCKER_PULL=false \
  uv run pytest -c tests/e2e/pytest.ini \
  tests/e2e/proposed-changes/test_proposed_changes_ordering.py -m shard_branches_repo

Verified locally: the new e2e test passes (1 passed) — it creates three
proposed changes, asserts newest-first on the Opened tab, closes them in reverse
order, and asserts the Closed tab is still newest-created-first.

Impact & rollout

  • Backward compatibility: no breaking changes; UI-only ordering.
  • Config/env changes: none.
  • Deployment notes: safe to deploy.

Checklist

  • Tests added/updated (e2e)
  • Changelog entry added
  • External docs updated (n/a — no documented behavior contract changes)
  • I have reviewed AI generated content

Summary by cubic

Order proposed changes by creation date (newest first) on the Opened and Closed tabs and the homepage widget, fixing the previous arbitrary order. Addresses #9915.

  • Bug Fixes
    • Added explicit GraphQL order by node_metadata__created_at DESC in the list query (using json-to-graphql-query EnumType).
    • Applies across Opened/Closed tabs and the homepage widget; UI-only with no schema changes.
    • Added e2e test to verify newest-first on both tabs, independent of close time.