Extends the existing label manager (create/rename/color/delete) with the two missing maintenance tools (task 1904), so the label list stays clean — which matters more now that #tags mint labels automatically. Backend: GET /api/labels returns a per-label note count (one grouped query); new POST /api/labels/<id>/merge moves the source label's notes onto a target and deletes the source (repoint via delete+reinsert to avoid mutating the composite PK; preserves via_tag; dedupes notes already on the target). Body #tags are NOT rewritten, so a tag-sourced label re-mints on next edit if its #tag text remains — a documented nuance. Frontend: LabelsModal shows each label's note count and a 'merge into…' picker; also restores the previously-missing close (x) and merge icons. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
33 lines
792 B
Python
33 lines
792 B
Python
import pytest
|
|
|
|
from thoughtsync.app import create_app
|
|
|
|
|
|
@pytest.fixture
|
|
def app():
|
|
return create_app()
|
|
|
|
|
|
async def test_labels_requires_auth(app):
|
|
client = app.test_client()
|
|
resp = await client.get("/api/labels")
|
|
assert resp.status_code == 401
|
|
|
|
|
|
async def test_set_note_labels_requires_auth(app):
|
|
client = app.test_client()
|
|
resp = await client.put(
|
|
"/api/notes/00000000-0000-0000-0000-000000000000/labels",
|
|
json={"label_ids": []},
|
|
)
|
|
assert resp.status_code == 401
|
|
|
|
|
|
async def test_merge_label_requires_auth(app):
|
|
client = app.test_client()
|
|
resp = await client.post(
|
|
"/api/labels/00000000-0000-0000-0000-000000000000/merge",
|
|
json={"into": "00000000-0000-0000-0000-000000000001"},
|
|
)
|
|
assert resp.status_code == 401
|