fix(bulk): node-safe toast (globalThis.window) + common-tags test matches non-empty spec guard
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user