Show the search box and filters on every park, range and wilderness page, however few trails it has

The bar was written only for a set of ten trails or more (home.FILTER_MIN, added with the list
and place filters on 2026-11-17), which left the Wind River Range (7 trails), Yosemite (9) and
the Ansel Adams Wilderness (5) with neither a search box nor Filters. Place pages now always
get it, and a set that nothing can narrow gets the search box alone, with no Filters button
and no empty panel. State and province pages keep the ten-trail threshold for now.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-20 12:29:05 -07:00
1 parent 30d03b8069
commit d90fa49df5
4 files changed
+57 -10

No files matched your search

+32
View File
@@ -150,6 +150,38 @@ class LabelPrepositionAndTitleTest(unittest.TestCase):
"Long Hikes in the Vancouver Island Ranges: 18 Trails")
class SmallPlaceHasTheBarTest(unittest.TestCase):
"""The owner's rule: every set of trails gets the search box and the filters, at any size."""
def test_a_place_with_three_trails_has_the_search_box_and_the_finder(self):
built = built_with([entry_of("range", "wind-river-range", "Wind River Range", ["WY"])], n=3)
body = str(built["/ranges/wind-river-range/"].body)
self.assertIn('class="finder__bar"', body)
self.assertIn('id="q"', body)
self.assertIn("data-finder", body)
self.assertLess(body.index('class="finder__bar"'), body.index('<li class="entry"'))
def test_only_filters_that_have_something_to_offer_are_written(self):
# three identical trails: nothing narrows them, so the bar is the search box alone
built = built_with([entry_of("range", "wind-river-range", "Wind River Range", ["WY"])], n=3)
body = str(built["/ranges/wind-river-range/"].body)
form = body[body.index('<form class="filters"'):body.index("</form>")]
self.assertNotIn("data-facet", form)
self.assertNotIn("filters__toggle", form)
self.assertNotIn("Nothing here narrows", form)
def test_a_place_whose_trails_differ_offers_those_filters_with_a_button(self):
entries = [entry_of("range", "wind-river-range", "Wind River Range", ["WY", "CO"])]
records = [rec(400 + i, f"Differ {i}", [("range", "wind-river-range")], km=50 + i * 120,
regs=("WY",) if i % 2 else ("CO",)) for i in range(1, 4)]
with tempfile.TemporaryDirectory() as d:
write_registry(d, entries)
body = str(placepages.build(records, S, d)[0].body)
form = body[body.index('<form class="filters"'):body.index("</form>")]
self.assertIn('data-facet="where"', form)
self.assertIn("filters__toggle", form)
class PlacePageTest(unittest.TestCase):
@classmethod
def setUpClass(cls):