§22 S6: type-driven entry noun (§22.4a) — backend source of truth + chrome
The displayed noun for an entry is a framework concept keyed on the collection's immutable type — document→"RFC", specification→"Spec", bdd→"Feature" — not deployment content. The chrome reads it from the API instead of hardcoding "RFC". - collections.ENTRY_NOUN + entry_noun(type) (unknown type → generic "RFC"). - Surfaced as entry_noun on get_collection, list_collections items, the /api/deployment directory items, and GET /api/projects/:id. - Frontend: Catalog reads entry_noun for the "+ Propose New <noun>" control; ProposeModal fetches the active collection's noun for its title + field copy. - test_s6_entry_noun_vertical.py: map + API surfacing (collection + directory). Scope note: this is §22.4a item (2) — terminology. The deeper type-module work (item 1 per-type frontmatter schemas; item 3 specification release-planning + bdd scenario/coverage surfaces) is flagged OPEN in the design doc and is handed off to a follow-up spec+slice. Backend 528 passed; frontend 30 passed + build green. Part of v0.45.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""§22.4a S6 — the type-driven entry noun.
|
||||
|
||||
The displayed noun for an entry is a framework concept keyed on the
|
||||
collection's immutable type: document→"RFC", specification→"Spec", bdd→"Feature".
|
||||
The chrome reads it from the API rather than hardcoding "RFC", so the propose
|
||||
CTA + entry chrome name entries correctly per collection type with no
|
||||
per-deployment config.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app import collections, db
|
||||
from test_propose_vertical import ( # noqa: F401
|
||||
app_with_fake_gitea, provision_user_row, sign_in_as, tmp_env,
|
||||
)
|
||||
|
||||
|
||||
def test_entry_noun_map():
|
||||
assert collections.entry_noun("document") == "RFC"
|
||||
assert collections.entry_noun("specification") == "Spec"
|
||||
assert collections.entry_noun("bdd") == "Feature"
|
||||
# An unknown/future type falls back to the generic noun, never label-less.
|
||||
assert collections.entry_noun("mystery") == "RFC"
|
||||
|
||||
|
||||
def test_collection_api_surfaces_entry_noun(app_with_fake_gitea):
|
||||
app, _ = app_with_fake_gitea
|
||||
with TestClient(app) as client:
|
||||
provision_user_row(user_id=1, login="ben", role="owner")
|
||||
sign_in_as(client, user_id=1, gitea_login="ben", display_name="Ben",
|
||||
role="owner", email="ben@test")
|
||||
# Flip the default collection to a bdd type and confirm the noun follows.
|
||||
db.conn().execute("UPDATE collections SET type='bdd' WHERE id='default'")
|
||||
r = client.get("/api/projects/default/collections/default")
|
||||
assert r.status_code == 200, r.text
|
||||
assert r.json()["entry_noun"] == "Feature"
|
||||
|
||||
|
||||
def test_directory_items_carry_entry_noun(app_with_fake_gitea):
|
||||
app, _ = app_with_fake_gitea
|
||||
with TestClient(app) as client:
|
||||
db.conn().execute("UPDATE projects SET visibility='public' WHERE id='default'")
|
||||
db.conn().execute("UPDATE collections SET type='specification' WHERE id='default'")
|
||||
r = client.get("/api/deployment")
|
||||
assert r.status_code == 200, r.text
|
||||
item = next(p for p in r.json()["projects"] if p["id"] == "default")
|
||||
assert item["entry_noun"] == "Spec"
|
||||
Reference in New Issue
Block a user