test_wiki_ux_small.py

tests/test_wiki_ux_small.py

Consistency fixes from the independent UX review (group E, owner Q/A 2026-11-22).

test_a_short_call_flow_has_no_player

None test_wiki_ux_small.test_a_short_call_flow_has_no_player()

E-15: a player for one box is a control without purpose; it appears past five boxes.

tests/test_wiki_ux_small.py:74

Show on the map →

Called by none

Calls _callflow

Checks

  • assert "data-slice-control" not in one and "data-slice-control" in many

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-025inferredtest_a_short_call_flow_has_no_player → _callflow → symbol_href
REQ-DDB-WIKI-045measuredtest_a_short_call_flow_has_no_player → _callflow
Source · 9 lines
def test_a_short_call_flow_has_no_player() -> None:
    """@brief E-15: a player for one box is a control without purpose; it appears past five boxes."""
    from clew.wiki.testpages import _callflow

    one = _callflow("test_x", [("f", "a.py")], {}, set())
    many = _callflow("test_x", [(f"f{i}", "a.py") for i in range(6)], {}, set())
    assert "data-slice-control" not in one and "data-slice-control" in many

Activity · 4 steps
lines 76–76from clew.wiki.testpages import _callflowlines 78–78one = _callflow("test_x", [("f", "a.py")], {}, set())lines 79–79many = _callflow("test_x", [(f"f{i}", "a.py") for i in range(6)], {}, set())lines 80–80assert "data-slice-control" not in one and "data-slice-control" in many

test_flow_titles_read_one_way_and_an_empty_flow_says_so

None test_wiki_ux_small.test_flow_titles_read_one_way_and_an_empty_flow_says_so()

One title pattern; empty flows muted.

tests/test_wiki_ux_small.py:83

Show on the map →

Called by none

Calls _role_block

Checks

  • assert ">clew</a>" in html and '<span class="entry">`main` (clew/cli.py)</span>' not in html
  • assert '<span class="entry"><code>main</code> (clew/cli.py)</span>' in html
  • assert 'class="untraced"' in html and "not traced" in html

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-012measuredtest_flow_titles_read_one_way_and_an_empty_flow_says_so → _role_block → table
REQ-DDB-WIKI-022inferredtest_flow_titles_read_one_way_and_an_empty_flow_says_so → _role_block → _badges → page_of
Source · 19 lines
def test_flow_titles_read_one_way_and_an_empty_flow_says_so() -> None:
    """E-11: mixed registers ("Build this wiki…" beside `clew — main (clew/cli.py)`), and a 0-step
    flow listed as a peer. A discovered title shows its readable part, with the entry and file under
    it in small monospace; a flow with no steps is muted and says "not traced".

    @brief One title pattern; empty flows muted.
    """
    from clew.wiki.flowpage import FlowPage, _role_block

    pages = [
        FlowPage("flow-main", "clew — `main` (clew/cli.py)", frozenset(), role="product", steps=12),
        FlowPage("flow-s", "Find a name you do not have yet", frozenset(), role="product", steps=0),
    ]
    html = _role_block("product", pages)
    assert ">clew</a>" in html and '<span class="entry">`main` (clew/cli.py)</span>' not in html
    assert '<span class="entry"><code>main</code> (clew/cli.py)</span>' in html
    assert 'class="untraced"' in html and "not traced" in html

Activity · 6 steps
lines 90–90from clew.wiki.flowpage import FlowPage, _role_blocklines 92–95pages = [ FlowPage("flow-main", "clew — `main` (clew/cli.py)", frozenset(), role="product", steps=12), FlowPage("flow-s", "Find a name you do not have yet", frozenset(), role="product", steps=0), ]lines 96–96html = _role_block("product", pages)lines 97–97assert ">clew</a>" in html and '<span class="entry">`main` (clew/cli.py)</span>' not in htmllines 98–98assert '<span class="entry"><code>main</code> (clew/cli.py)</span>' in htmllines 99–99assert 'class="untraced"' in html and "not traced" in html

test_the_flow_page_puts_detail_behind_counts

None test_wiki_ux_small.test_the_flow_page_puts_detail_behind_counts()

A-1: the diagram box scrolls; table and functions fold.

tests/test_wiki_ux_small.py:232

Show on the map →

Called by none

Calls none

Checks

  • assert "data-goto" in _SCRIPT and ".flow-wrap{max-height:80vh;overflow:auto}" in _STYLE
  • assert '<details class="fold"><summary>2 functions</summary>' in "".join(_functions({("a", "x.py"), ("b", "y.py")}) )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-025measured
Source · 10 lines
def test_the_flow_page_puts_detail_behind_counts() -> None:
    """@brief A-1: the diagram box scrolls; table and functions fold."""
    from clew.wiki.flowpage import _SCRIPT, _STYLE, _functions

    assert "data-goto" in _SCRIPT and ".flow-wrap{max-height:80vh;overflow:auto}" in _STYLE
    assert '<details class="fold"><summary>2 functions</summary>' in "".join(
        _functions({("a", "x.py"), ("b", "y.py")})
    )

Activity · 3 steps
lines 234–234from clew.wiki.flowpage import _SCRIPT, _STYLE, _functionslines 236–236assert "data-goto" in _SCRIPT and ".flow-wrap{max-height:80vh;overflow:auto}" in _STYLElines 237–239assert '<details class="fold"><summary>2 functions</summary>' in "".join( _functions({("a", "x.py"), ("b", "y.py")}) )

test_the_sbom_drops_empty_columns_normalises_licences_and_states_coverage

None test_wiki_ux_small.test_the_sbom_drops_empty_columns_normalises_licences_and_states_coverage()

SBOM table and coverage.

tests/test_wiki_ux_small.py:139

Show on the map →

Called by none

Calls _cdx_licence, sbom_html

Checks

  • assert (_cdx_licence({ "licenses": [ {"license": {"id": "Apache-2.0"}}, {"license": {"name": "License :: OSI Approved :: Apache Software License"}}, ] }
  • assert "<th>digest</th>" not in html and "<th>source</th>" in html
  • assert '<p class="stat"><b>600 of 44,944</b> indexed files declare a licence (1%).</p>' in html

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-051measuredtest_the_sbom_drops_empty_columns_normalises_licences_and_states_coverage → sbom_html
REQ-DDB-WIKI-054inferredtest_the_sbom_drops_empty_columns_normalises_licences_and_states_coverage → sbom_html → _row → _accepted → all
Source · 28 lines
def test_the_sbom_drops_empty_columns_normalises_licences_and_states_coverage() -> None:
    """E-25 / E-22: an empty Digest column in every row; "Apache-2.0 AND License :: OSI Approved ::
    …" as a licence; "44344 indexed files carry no SPDX identifier" buried as a footnote.

    @brief SBOM table and coverage.
    """
    from clew.wiki.sbom import Component, _cdx_licence, sbom_html

    assert (
        _cdx_licence(
            {
                "licenses": [
                    {"license": {"id": "Apache-2.0"}},
                    {"license": {"name": "License :: OSI Approved :: Apache Software License"}},
                ]
            }
        )
        == "Apache-2.0"
    )
    comps = [
        Component("a", "1", "MIT", "library", "pkg:pypi/a", ""),
        Component("b", "2", "MIT", "library", "pkg:pypi/b", ""),
    ]
    html = sbom_html([("bom.cdx.json", ("clew", "MIT"), comps)], (), {"MIT": 600}, 44344)
    assert "<th>digest</th>" not in html and "<th>source</th>" in html
    assert '<p class="stat"><b>600 of 44,944</b> indexed files declare a licence (1%).</p>' in html

Activity · 6 steps
lines 145–145from clew.wiki.sbom import Component, _cdx_licence, sbom_htmllines 147–157assert ( _cdx_licence( { "licenses": [ {"license": {"id": "Apache-2.0"}}, {"license": {"name": "License :: OSI Approved :: Apache Software License"}}, ] } ) == "Apache-2.0" )lines 158–161comps = [ Component("a", "1", "MIT", "library", "pkg:pypi/a", ""), Component("b", "2", "MIT", "library", "pkg:pypi/b", ""), ]lines 162–162html = sbom_html([("bom.cdx.json", ("clew", "MIT"), comps)], (), {"MIT": 600}, 44344)lines 163–163assert "<th>digest</th>" not in html and "<th>source</th>" in htmllines 164–164assert '<p class="stat"><b>600 of 44,944</b> indexed files declare a licence (1%).</p>' in html

test_the_test_card_keeps_three_columns_and_code_in_mono

None test_wiki_ux_small.test_the_test_card_keeps_three_columns_and_code_in_mono()

Card layout.

tests/test_wiki_ux_small.py:49

Show on the map →

Called by none

Calls test_card

Checks

  • assert 'class="tc-given"' in html and '<li class="none">—</li>' in html
  • assert "tc-strip no-given" not in html
  • assert "<details" in given and "2 more" in given
  • assert (".tc-then li.ck{" in (_STATIC / "clew.css").read_text() and "font-family:var(--mono)" in (_STATIC / "clew.css").read_text().split(".tc-then li.ck{", 1)[1].split("}", 1)[0] )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-026measuredtest_the_test_card_keeps_three_columns_and_code_in_mono → test_card
Source · 25 lines
def test_the_test_card_keeps_three_columns_and_code_in_mono() -> None:
    """E-16 (owner-approved review): a fixed Given / When / Then (Given "—" when empty, not a reflow);
    Given folds past two statements; checks read in monospace like the code they describe.
    SPEC CHANGED: test_a_call_inside_the_assertion… required the empty Given to disappear.

    @brief Card layout.
    """
    from clew.wiki.testcard import test_card

    d = SimpleNamespace(name="test_s", file="tests/test_s.py", start=1)
    html = test_card(["def test_s():", "    assert f(1) == 2"], d, {"f"}, None)
    assert 'class="tc-given"' in html and '<li class="none">—</li>' in html
    assert "tc-strip no-given" not in html
    src = ["def test_g():"] + [f"    v{i} = {i}" for i in range(4)] + ["    assert f(v0) == 1"]
    given = test_card(src, SimpleNamespace(name="test_g", file="t.py", start=1), {"f"}, None).split(
        'class="tc-given"', 1
    )[1]
    assert "<details" in given and "2 more" in given
    assert (
        ".tc-then li.ck{" in (_STATIC / "clew.css").read_text()
        and "font-family:var(--mono)"
        in (_STATIC / "clew.css").read_text().split(".tc-then li.ck{", 1)[1].split("}", 1)[0]
    )

Activity · 9 steps
lines 56–56from clew.wiki.testcard import test_cardlines 58–58d = SimpleNamespace(name="test_s", file="tests/test_s.py", start=1)lines 59–59html = test_card(["def test_s():", " assert f(1) == 2"], d, {"f"}, None)lines 60–60assert 'class="tc-given"' in html and '<li class="none">—</li>' in htmllines 61–61assert "tc-strip no-given" not in htmllines 62–62src = ["def test_g():"] + [f" v{i} = {i}" for i in range(4)] + [" assert f(v0) == 1"]lines 63–65given = test_card(src, SimpleNamespace(name="test_g", file="t.py", start=1), {"f"}, None).split( 'class="tc-given"', 1 )[1]lines 66–66assert "<details" in given and "2 more" in givenlines 67–71assert ( ".tc-then li.ck{" in (_STATIC / "clew.css").read_text() and "font-family:var(--mono)" in (_STATIC / "clew.css").read_text().split(".tc-then li.ck{", 1)[1].split("}", 1)[0] )