ComfyUI/tests-unit/assets_test
Matt Miller 00940fb24e fix(assets): preserve caller order in add_tags_to_reference + align response helper
Smoke test through the real HTTP upload + tag-add path exposed two
ordering bugs the unit-layer tests missed:

1. add_tags_to_reference did `to_add = sorted(want - current)` — an
   alphabetical pre-sort defeating the microsecond-stagger fix from the
   previous commit. The stagger was encoding alphabetical positions,
   not the caller's insertion order. Fix: build to_add by walking the
   already-normalized caller list and filtering against the current
   set, so the staggered added_at timestamps reflect what the caller
   actually requested.

2. get_reference_tags used .order_by(tag_name.asc()) — alphabetical.
   It's called by the upload response path; meanwhile
   list_references_page and fetch_reference_asset_and_tags were already
   updated to order by added_at. The mismatch meant POST /api/assets
   returned tags in alphabetical order but a subsequent GET returned
   them in insertion order. Fix: order get_reference_tags by added_at
   too, so all three response-path helpers agree.

New tests-unit/assets_test/test_user_tag_http_smoke.py exercises the
full HTTP layer: POST /api/assets to upload, POST /api/assets/{id}/tags
to add a user tag (using tag names like "aaa-user-tag" that would jump
to position 0 under alphabetical), GET /api/assets/{id} to verify
ordering. Catches the bugs above in CI going forward.

Full assets suite: 340 passed, 10 pre-existing skipped.
2026-05-19 21:10:53 -07:00
..
queries fix(assets): stagger added_at in set_reference_tags + add ordering tests 2026-05-19 21:05:54 -07:00
services fix(assets): lowercase subpath, parse slash-joined upload tags, stagger added_at 2026-05-19 20:30:04 -07:00
conftest.py
helpers.py
test_assets_missing_sync.py feat(assets): collapse nested asset path into a single slash-joined tag 2026-05-19 14:48:49 -07:00
test_crud.py feat(assets): collapse nested asset path into a single slash-joined tag 2026-05-19 14:48:49 -07:00
test_downloads.py
test_file_utils.py
test_list_filter.py
test_metadata_filters.py
test_prune_orphaned_assets.py feat(assets): collapse nested asset path into a single slash-joined tag 2026-05-19 14:48:49 -07:00
test_sync_references.py
test_tags_api.py
test_uploads.py
test_user_tag_http_smoke.py fix(assets): preserve caller order in add_tags_to_reference + align response helper 2026-05-19 21:10:53 -07:00