fix(review): slug-scoped tags, decode names, drop fig picker & AI labels
- Taxonomy sync keeps fig-/feat- by slug (hyphen), not name; HTML-unescape names - Review: remove AI assist labels; Features picker for feat-*; derive fig_tag_ids from Figure term names (casefold match, no bridges); decodeName on display - Unit tests for scoped_tags, fig match, Review UI contract; docs slug wording
This commit is contained in:
@@ -95,12 +95,29 @@ def test_401_raises_auth_error(db_dir):
|
||||
c.get_categories()
|
||||
|
||||
|
||||
def test_scoped_tags_by_slug_not_name():
|
||||
"""SETTINGS-51: keep fig-/feat- by slug prefix with hyphen; human names stay."""
|
||||
tags = [
|
||||
{"id": 1, "name": "Curl", "slug": "fig-curl"},
|
||||
{"id": 2, "name": "Knot", "slug": "feat-knot"},
|
||||
{"id": 3, "name": "fig-looks-like", "slug": "other"}, # name prefix alone — drop
|
||||
{"id": 4, "name": "Figured", "slug": "figured"}, # no hyphen — drop
|
||||
{"id": 5, "name": "other", "slug": "other-tag"},
|
||||
]
|
||||
kept = taxonomy_mod._scoped_tags(tags)
|
||||
assert {t["id"] for t in kept} == {1, 2}
|
||||
|
||||
|
||||
def test_sync_populates_scoped(db_dir):
|
||||
cats = (200, {"X-WP-TotalPages": "1"}, json.dumps([{"id": 1, "name": "Cedar", "slug": "cedar", "parent_id": None, "woo_id": 10}]).encode())
|
||||
# Live Woo: human names + fig-/feat- slugs. Name-prefix filter would keep 0.
|
||||
cats = (200, {"X-WP-TotalPages": "1"}, json.dumps([
|
||||
{"id": 1, "name": "Cookies & Burl Slices", "slug": "cookies-burl", "parent_id": None, "woo_id": 10},
|
||||
]).encode())
|
||||
tags = (200, {"X-WP-TotalPages": "1"}, json.dumps([
|
||||
{"id": 2, "name": "fig-curl", "slug": "fig-curl", "woo_id": 20},
|
||||
{"id": 3, "name": "feat-knot", "slug": "feat-knot", "woo_id": 21},
|
||||
{"id": 4, "name": "other-tag", "slug": "other-tag", "woo_id": 22}, # must be dropped
|
||||
{"id": 2, "name": "Curl", "slug": "fig-curl", "woo_id": 20},
|
||||
{"id": 3, "name": "Knot", "slug": "feat-knot", "woo_id": 21},
|
||||
{"id": 4, "name": "fig-fake", "slug": "other-tag", "woo_id": 22}, # name looks scoped; slug not — drop
|
||||
{"id": 5, "name": "other-tag", "slug": "other-tag-2", "woo_id": 23},
|
||||
]).encode())
|
||||
attrs = (200, {"X-WP-TotalPages": "1"}, json.dumps([{"id": 5, "name": "Edge Type", "slug": "edge", "woo_id": 30}]).encode())
|
||||
terms = (200, {"X-WP-TotalPages": "1"}, json.dumps([{"id": 6, "name": "Flat", "slug": "flat", "woo_id": 40}]).encode())
|
||||
@@ -108,8 +125,11 @@ def test_sync_populates_scoped(db_dir):
|
||||
result = taxonomy_mod.sync(c, db_mod.get_connection())
|
||||
conn = db_mod.get_connection()
|
||||
assert [r[0] for r in conn.execute("SELECT id FROM woo_categories")] == [1]
|
||||
tag_ids = {r[0] for r in conn.execute("SELECT id FROM woo_tags")}
|
||||
assert tag_ids == {2, 3} # fig- + feat- kept, other-tag dropped
|
||||
assert conn.execute("SELECT name FROM woo_categories WHERE id=1").fetchone()[0] == "Cookies & Burl Slices"
|
||||
tag_rows = {r[0]: (r[1], r[2]) for r in conn.execute("SELECT id, name, slug FROM woo_tags")}
|
||||
assert set(tag_rows) == {2, 3} # fig- + feat- by slug; name-only fig-fake dropped
|
||||
assert tag_rows[2] == ("Curl", "fig-curl")
|
||||
assert tag_rows[3] == ("Knot", "feat-knot")
|
||||
assert [r[0] for r in conn.execute("SELECT id FROM woo_attribute_terms")] == [6]
|
||||
assert result["taxonomy_anchor"]
|
||||
assert conn.execute("SELECT value FROM settings WHERE key='taxonomy_last_sync_at'").fetchone()[0]
|
||||
|
||||
Reference in New Issue
Block a user