Guides answer the search box, and proofing catches what spellcheck cannot

A guide was invisible to global search. Core search has a hardcoded block per
domain rather than a hook, so a new plugin stays unreachable until someone adds
one - which is the same shape as the gap this test file already documents for
USB devices and printed parts: records with a list page, labels in the world,
and no way to find them from the search box.

Guides are searched by title, summary, tags AND body. The body matters more here
than elsewhere: people look for a procedure by something written halfway down it,
not by a title they never read. PUBLISHED ONLY - a draft is deliberately
invisible to readers, and search is exactly where that rule leaks if nobody
writes it down. The test proves it with a draft sharing a tag and a body word
with a published guide, so a missing filter would show up as a ride-along.

PROOFING catches what a spellchecker cannot, because none of these are spelling:
a smart quote in a command so it will not run, a checklist item with no text so
a step is silently missing, a heading left with nothing under it after a
reorganise, an image with no alt text, a TODO published by accident. Warnings,
never blocks - somebody publishing at 14:40 with one empty bullet should be
told, not stopped, and a procedure that exists imperfectly beats one nobody
wrote.

The smart-character issue reports once per block with a one-click fix, rather
than once per offending character: an opening and a closing quote are one
problem, and listing both makes the panel look like it is nagging.

The character table itself is written as escapes. The style gate forbids
non-ASCII in source, and a file whose job is detecting smart quotes cannot
contain any - which the gate caught, correctly.
This commit is contained in:
cproudlock
2026-08-26 11:27:10 -04:00
parent a52437b40b
commit 2c016de59e
5 changed files with 343 additions and 0 deletions

View File

@@ -266,3 +266,75 @@ def test_an_ip_search_links_to_the_matched_subnet(client, subnetrow):
assert len(rows) == 1
assert rows[0]['id'] == subnetrow
assert rows[0]['url'] == f'/networks/{subnetrow}'
# ---------------------------------------------------------------------------
# Guides. A guide is not an asset either, so the generic asset search cannot see
# one - and the draft rule makes the omission worse than invisibility: a
# half-written procedure reachable through the search box is one somebody
# follows.
# ---------------------------------------------------------------------------
@pytest.fixture
def guides(db):
"""One published guide and one draft, with distinctive text.
The published one carries its distinguishing words in the BODY, not the
title, because that is how people look for a procedure - by something
written halfway down it.
"""
from plugins.guides.models import Guide
from plugins.guides.services import authoring
published = Guide(title='Zzmarker controller swap', slug='zzmarker-swap',
status='draft')
draft = Guide(title='Zzdraft unfinished procedure', slug='zzdraft-unfinished',
status='draft')
db.session.add_all([published, draft])
db.session.flush()
authoring.save(published, title=published.title,
summary='Restoring after a swap', tags='zztelesis, zzbackups',
blocks=[{'id': 'g1', 'type': 'paragraph',
'text': 'Check the zzmappeddrive before starting.'}])
authoring.publish(published)
authoring.save(draft, title=draft.title, summary='', tags='zztelesis',
blocks=[{'id': 'g2', 'type': 'paragraph',
'text': 'Half written zzmappeddrive notes.'}])
db.session.commit()
return {'published': published.guideid, 'draft': draft.guideid}
def test_a_published_guide_is_found_by_title(client, guides):
rows = [r for r in search(client, 'Zzmarker') if r['type'] == 'guide']
assert len(rows) == 1
assert rows[0]['id'] == guides['published']
assert rows[0]['url'] == '/guides/zzmarker-swap'
def test_a_guide_is_found_by_tag(client, guides):
"""Tags are how a technician narrows to a family of procedures."""
assert 'Zzmarker controller swap' in titles(client, 'zzbackups', 'guide')
def test_a_guide_is_found_by_words_in_its_body(client, guides):
"""People search for what they remember reading, not for the title.
The body is stored as a JSON blob of blocks, so this is the check that the
blob is actually reachable rather than merely present.
"""
assert 'Zzmarker controller swap' in titles(client, 'zzmappeddrive', 'guide')
def test_a_draft_guide_is_never_returned(client, guides):
"""The draft rule has to hold on EVERY path that reaches the row.
A draft is deliberately invisible to readers, and search is where that rule
would otherwise leak: somebody finds a half-written procedure through the
search box and follows it. The draft here shares a tag and a body word with
the published guide, so it would ride along on both queries if the filter
were missing.
"""
assert 'Zzdraft unfinished procedure' not in titles(client, 'zzmappeddrive', 'guide')
assert 'Zzdraft unfinished procedure' not in titles(client, 'zztelesis', 'guide')
assert titles(client, 'Zzdraft', 'guide') == []