fix(lex): live test restores the family registry; dossier view labels years on file
This commit is contained in:
@@ -31,7 +31,7 @@ export function render(data) {
|
||||
<span class="eyebrow">Active codes</span><div class="codes">${codes(g.active)}</div>
|
||||
${(g.deleted || []).length ? `<span class="eyebrow">Deleted codes</span><div class="codes">${codes(g.deleted, "del")}</div>` : ""}
|
||||
${(g.linked || []).length ? `<span class="eyebrow">Linked codes</span><div class="codes">${codes(g.linked, "lnk")}</div>` : ""}
|
||||
${row("Status", esc(H.status))}${row("Years", esc(H.years_active))}${row("Built", esc(H.built_at))}
|
||||
${row("Status", esc(H.status))}${row("Years on file", esc(H.years_on_file || H.years_active))}${row("Built", esc(H.built_at))}
|
||||
${row("Citation check", passed ? "citation check passed" : "citation check failed")}
|
||||
${row("Extractor", esc(H.extractor))}
|
||||
${(H.fallbacks || []).length ? row("Fallbacks", H.fallbacks.map(esc).join("; ")) : ""}
|
||||
|
||||
@@ -38,6 +38,14 @@ test("dossier view", () => {
|
||||
ok(h.includes("Invented governance excerpt."));
|
||||
});
|
||||
|
||||
test("dossier years label reads years_on_file, falls back to years_active", () => {
|
||||
const st0 = st("/dossier?family=HOME-VISITS");
|
||||
const old = dossier.render({ header: H }, st0);
|
||||
ok(old.includes("Years on file") && old.includes(esc(H.years_active)));
|
||||
const cur = dossier.render({ header: { ...H, years_on_file: "2019–2027" } }, st0);
|
||||
ok(cur.includes("Years on file") && cur.includes("2019–2027") && !cur.includes(esc(H.years_active)));
|
||||
});
|
||||
|
||||
test("dossier with no governance and a failed check", () => {
|
||||
const H2 = { ...H, governance: [], check_passed: false, facts: {}, gaps: ["No governance findings captured."] };
|
||||
const h = dossier.render({ header: H2 }, st("/dossier?family=HOME-VISITS"));
|
||||
|
||||
@@ -23,6 +23,36 @@ FAMILY = "HOME-VISITS"
|
||||
VIEW_SECTIONS = ("header", "timeline", "valuation", "payment", "politics")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def _restore_registry():
|
||||
"""Opening the live replica loads its 8,662-family registry into
|
||||
``pfs.families`` (and caches the handle); put both back afterwards so
|
||||
neighbouring tests see the registry they expect."""
|
||||
from llm import evidence
|
||||
from pfs import families
|
||||
|
||||
saved = (
|
||||
dict(families.FAMILIES),
|
||||
families._PHRASE_RE,
|
||||
families._PHRASE_INDEX,
|
||||
families._CODE_INDEX,
|
||||
)
|
||||
prior = evidence._REPLICA
|
||||
yield
|
||||
with families._REGISTRY_LOCK:
|
||||
families.FAMILIES.clear()
|
||||
families.FAMILIES.update(saved[0])
|
||||
(
|
||||
families._PHRASE_RE,
|
||||
families._PHRASE_INDEX,
|
||||
families._CODE_INDEX,
|
||||
) = saved[1:]
|
||||
if evidence._REPLICA is not prior:
|
||||
if evidence._REPLICA is not None:
|
||||
evidence._REPLICA[2].close()
|
||||
evidence._REPLICA = prior
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def cfg():
|
||||
from llm import config
|
||||
|
||||
Reference in New Issue
Block a user