fix(ui): stop the pages being cached, and the labels duplicating
Firefox served a cached copy of the brewing page after the advice became a button and a pop-out, so the phone kept showing the old inline advice - a long paragraph in the table cell, with the button label reading "Read the adviceAdvice". Two separate causes: The pages had no cache headers, so Firefox was free to reuse them. They now send Cache-Control: no-store, must-revalidate. The rule that hides the short label was scoped to `table.data .short`, so it did not apply to the advice button's label. A stale stylesheet then showed both forms at once. The rule is now on `.short` alone, so it applies wherever the pattern is used - a table heading, the advice button, the Active Beers page - and only ever one form can show. Verified at 390px and 1280px: the phone shows "Advice", the desktop shows "Read the advice" and "BREWING ADVICE", and no element ever shows both. 192 tests pass.
This commit is contained in:
@@ -714,3 +714,15 @@ def test_the_api_exposes_the_attenuation_and_curve(logged_in, repo):
|
||||
assert len(entry["curve"]) == 2
|
||||
assert entry["curve"][0]["progress"] == 0.0
|
||||
assert entry["curve"][1]["progress"] == 1.0
|
||||
|
||||
|
||||
def test_the_pages_are_not_cached(client):
|
||||
"""The HTML pages must not be cached by the browser.
|
||||
|
||||
A phone held on to a cached copy of the brewing page and kept
|
||||
showing the old inline advice after the button and the pop-out had
|
||||
been deployed, so the change was invisible until the cache was
|
||||
cleared by hand.
|
||||
"""
|
||||
response = client.get("/login")
|
||||
assert "no-store" in response.headers.get("Cache-Control", "")
|
||||
|
||||
@@ -1049,6 +1049,36 @@ def test_the_tables_keep_their_columns_on_a_phone(client, repo):
|
||||
assert "Cider raspberry elderberry" in body
|
||||
|
||||
|
||||
def test_the_long_and_short_labels_are_both_in_the_page(client, repo):
|
||||
"""The long and the short label are both in the markup.
|
||||
|
||||
CSS picks which one shows - the long form on a desktop, the short
|
||||
form on a phone. If only one is in the markup the other cannot be
|
||||
shown at all, and if the CSS rule misses one of them the page shows
|
||||
"Read the adviceAdvice".
|
||||
|
||||
This is a markup assertion, not a CSS assertion: it makes sure
|
||||
both forms exist for the stylesheet to choose between.
|
||||
"""
|
||||
repo.users.insert_one({"username": "beer", "password": "beer_pass"})
|
||||
client.post("/login", data={"username": "beer", "password": "beer_pass"},
|
||||
follow_redirects=True)
|
||||
|
||||
seed_readings(repo, [("1", "Ale", "1042", "2026-01-01", False, "")])
|
||||
doc = repo.readings.find_one({"beer_run_id": "1"})
|
||||
repo.set_reading_advice(str(doc["_id"]), "Warm it to 21C and wait.", ok=True)
|
||||
|
||||
body = client.get("/brews").get_data(as_text=True)
|
||||
|
||||
# The heading has both forms.
|
||||
assert '<span class="long">Brewing advice</span>' in body
|
||||
assert '<span class="short">Advice</span>' in body
|
||||
|
||||
# The button has both forms.
|
||||
assert '<span class="long">Read the advice</span>' in body
|
||||
assert '<span class="short">Advice</span>' in body
|
||||
|
||||
|
||||
def test_a_failed_advice_is_marked_as_such(client, repo):
|
||||
"""A generation failure reads differently from real advice."""
|
||||
repo.users.insert_one({"username": "beer", "password": "beer_pass"})
|
||||
|
||||
Reference in New Issue
Block a user