diff --git a/frontend/src/stores/gallerySelection.js b/frontend/src/stores/gallerySelection.js index 881dbcf..daf31a0 100644 --- a/frontend/src/stores/gallerySelection.js +++ b/frontend/src/stores/gallerySelection.js @@ -51,7 +51,7 @@ export const useGallerySelectionStore = defineStore('gallerySelection', () => { body: { image_ids: order.value, tag_id: tagId, source } }) await refresh() - window.__fcToast?.({ + globalThis.window?.__fcToast?.({ text: `Added to ${body.added_count} image(s)`, type: 'success' }) return body @@ -62,7 +62,7 @@ export const useGallerySelectionStore = defineStore('gallerySelection', () => { body: { image_ids: order.value, tag_id: tagId } }) await refresh() - window.__fcToast?.({ + globalThis.window?.__fcToast?.({ text: `Removed from ${body.removed_count} image(s)`, type: 'success' }) return body diff --git a/tests/test_api_bulk_tags.py b/tests/test_api_bulk_tags.py index 86027b5..1917734 100644 --- a/tests/test_api_bulk_tags.py +++ b/tests/test_api_bulk_tags.py @@ -22,10 +22,11 @@ async def _mk_tag(client, name, kind="general"): @pytest.mark.asyncio -async def test_common_tags_route(client): +async def test_common_tags_rejects_empty_list(client): + # Spec guard: image_ids must be a non-empty list (the frontend never + # calls this with an empty selection). resp = await client.post("/api/images/common-tags", json={"image_ids": []}) - assert resp.status_code == 200 - assert (await resp.get_json())["tags"] == [] + assert resp.status_code == 400 @pytest.mark.asyncio @@ -34,6 +35,16 @@ async def test_common_tags_requires_list(client): assert resp.status_code == 400 +@pytest.mark.asyncio +async def test_common_tags_ok_shape(client): + # Unknown image ids are valid input; result is just an empty tag list. + resp = await client.post( + "/api/images/common-tags", json={"image_ids": [999999]} + ) + assert resp.status_code == 200 + assert (await resp.get_json())["tags"] == [] + + @pytest.mark.asyncio async def test_bulk_add_route_happy(client): tag = await _mk_tag(client, "RouteAdd")