fix(ui): make the advice pop-out fail-safe against a stale stylesheet
The screenshot from Firefox showed the advice expanded inline in the
table cell, running down the column and off the screen, with the long
and short labels both showing ("BREWING ADVICEADVICE"). The page had
the new markup and Firefox was serving a stale stylesheet.
Two fixes.
The static files now send Cache-Control: no-store. They sent
no-cache, which means "revalidate" - and Firefox was reusing them
without revalidating. no-store is the only one that means "do not
keep this". The HTML pages already sent no-store.
The pop-out carries the hidden attribute, and the script removes it
when the panel opens and puts it back when it closes. That makes the
MARKUP fail-safe rather than the stylesheet: a stylesheet that does
not know about .advice-pop at all still leaves the panel hidden, so
the advice can never appear expanded inside the cell.
Verified by removing all eight .advice-pop rules from the live
stylesheet - the panel stays hidden, 0x0, and the advice is not
rendered. Before this it would have rendered inline.
The button still opens it on tap and on hover, and the close button
still closes it. The desktop is unchanged: the same full headings and
the same hover pop-out.
195 tests pass.
This commit is contained in:
@@ -1162,6 +1162,29 @@ def test_stale_advice_cannot_overwrite_a_comment_edited_outside_the_app(repo):
|
||||
assert doc["comment"] == "edited outside the app"
|
||||
|
||||
|
||||
def test_the_advice_pop_out_is_hidden_in_the_markup(client, repo):
|
||||
"""The pop-out carries the `hidden` attribute.
|
||||
|
||||
A stale stylesheet - one that does not know about `.advice-pop` at
|
||||
all - would otherwise leave the advice expanded inline in the table
|
||||
cell, running down the column and off the screen. The `hidden`
|
||||
attribute makes the markup fail-safe: the panel stays hidden until
|
||||
the script opens it.
|
||||
"""
|
||||
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)
|
||||
|
||||
assert 'class="advice-pop"' in body
|
||||
assert 'hidden' in body.split('class="advice-pop"')[1][:60]
|
||||
|
||||
|
||||
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