fix(web): Started toggle survives the Executions card's 5s poll

The card's own htmx poll re-renders the whole table from the server every
5s, always starting fresh at "relative" -- so a toggled-to-absolute cell
snapped back on the next poll. Each button now has a stable id
(started-{run_id}-{attempt}, or started-vm-{vmx} on an unmatched-VM row);
app.js remembers which format was showing per id and re-applies it to the
fresh button after every swap, rather than freezing the node itself (which
would also freeze its relative-time text, badge, duration, everything else
in that row).
This commit is contained in:
2026-07-26 00:25:33 +02:00
parent 0d9c5ab353
commit bfa90190ea
4 changed files with 60 additions and 20 deletions
+10 -3
View File
@@ -346,11 +346,17 @@ def test_started_cell_is_a_click_to_toggle_button(
"""Both the relative and absolute renderings are pre-rendered into the
button's data attributes -- app.js swaps textContent/title on click, no
round trip. Server-side, this test can only pin the markup the toggle
depends on, not the click itself."""
depends on, not the click itself.
The id must be stable across the card's own 5s poll (run_id/attempt, not
anything generated fresh per render) -- app.js keys its client-side
"which format is showing" memory off it to survive the next poll's
server-rendered reset back to relative.
"""
_stub_view(
monkeypatch,
ExecutionsView(
runs=[_execution(started="2026-07-25T11:50:00Z")],
runs=[_execution(run_id=412, attempt=1, started="2026-07-25T11:50:00Z")],
unmatched_vms=[],
source="admin",
error=None,
@@ -362,7 +368,8 @@ def test_started_cell_is_a_click_to_toggle_button(
resp = client.get("/executions")
assert '<button type="button" class="time-toggle text-dim"' in resp.text
assert 'id="started-412-1"' in resp.text
assert 'class="time-toggle text-dim"' in resp.text
assert 'data-showing="relative"' in resp.text
assert 'data-relative="' in resp.text
assert 'data-absolute="' in resp.text