fix(web): backup age in Templates card was frozen by hx-preserve

The backups <details> carried hx-preserve="true" to survive the card's
30s poll without collapsing if the operator had it open -- but hx-preserve
freezes the whole node, so "newest X ago" inside it never updated either,
same class of bug as the Started column before it got its own JS-side
toggle state. Drop hx-preserve; track open/closed the same way (stable id,
state re-applied after every swap) so the count/age text stays live.
This commit is contained in:
2026-07-26 03:04:22 +02:00
parent 3da992119b
commit 9ab760a64c
3 changed files with 62 additions and 1 deletions
+32
View File
@@ -180,6 +180,38 @@ def test_templates_route_degrades_on_probe_failure(
assert "unavailable" in resp.text.lower()
def test_templates_backups_details_is_not_frozen_by_hx_preserve(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""``hx-preserve`` freezes the *whole* node across the card's 30s poll --
including the "newest X ago" text inside it, which must keep updating.
Only the <details> open/closed state should persist (via app.js, the
same pattern already used for the Started column's click-to-toggle)."""
monkeypatch.setattr(app_module, "list_templates", lambda _config: [_TEMPLATE_ROW])
monkeypatch.setattr(
app_module,
"backups_by_template",
lambda _config: {
"LinuxBuild2404": [
FileEntry(
name="Template_LinuxBuild2404_20260101_000000.7z",
size_bytes=2048,
mtime=1_700_000_000.0,
)
]
},
)
app = create_app(_make_config(tmp_path))
client = TestClient(app)
resp = client.get("/templates")
assert resp.status_code == 200
assert 'id="backups-LinuxBuild2404"' in resp.text
assert "newest" in resp.text
assert "hx-preserve" not in resp.text
def test_templates_route_shows_running_ram_snapshot_warning(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None: