Skip to content

🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!

Carry expiry_change_count through the Status page warranty mapping (#209)

Omega (QA)3b5316e99035
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5b1b9f1..25c45fd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,9 @@
- **Warranty expiration change history (#209):** editing a warranty's expiration date, duration, or lifetime status now records the transition (previous value, new value, timestamp, editor, and an optional reason up to 255 characters) in a new `warranty_expiry_history` table without automatically mutating dates from claims. Warranties with recorded changes show a subtle clickable history badge next to the expiration date across the dashboard and Status page, opening an Expiry History modal; the Status page detail row and the Edit Warranty modal also display the change history, and the Edit Warranty modal dynamically reveals the optional reason field only when expiration inputs are modified.
- _Files: `backend/migrations/057_create_warranty_expiry_history.sql`, `backend/warranties_routes.py`, `backend/statistics_routes.py`, `frontend/js/components/expiryHistory.js`, `frontend/js/components/editModal.js`, `frontend/js/components/warrantyRenderer.js`, `frontend/js/components/ui.js`, `frontend/js/controllers/warrantyListController.js`, `frontend/js/index.js`, `frontend/index.html`, `frontend/status.html`, `frontend/script.js`, `frontend/status.js`, `frontend/style.css`, `frontend/sw.js`, `locales/*/translation.json`, `tests/test_warranty_expiry_history.py`_
+- **Status page expiry-history badge now shows (#209):** the Status page rebuilt each warranty into a new object without carrying `expiry_change_count` through, so the history badge never rendered on a row and the expanded-row history section never appeared, even though the API returned the count. The count is now carried through.
+ - _Files: `frontend/status.js`, `tests/test_status_expiry_history_badge.py`_
+
- **Security and Python dependency updates (#295):** Apprise moves from 2.2.0 to 2.3.0, carrying upstream security fix GHSA-rmjg-h4cf-m74j along with OAuth token redaction in debug logs, slow-attachment timeout protection, and new notification services. Authlib moves from 1.9.5 to 1.9.10 (five patch releases for the OIDC client stack), and `email-validator` moves from 2.3.0 to 2.4.0 (enforcing IDNA Bidi rules, rejecting overlong IDN domains before encoding, and fixing quoted local-part normalization).
- _Files: `backend/requirements.txt`_
- **Docker base image and BuildKit syntax refreshed (#290, #296):** the pinned `python:3.15-slim-trixie` base image digest was refreshed in both Dockerfile stages to pick up upstream Python and Debian Trixie security updates, and the BuildKit Dockerfile syntax moves from 1.28.0 to 1.29.0.
diff --git a/frontend/status.js b/frontend/status.js
index 621c221..8e3fecf 100644
--- a/frontend/status.js
+++ b/frontend/status.js
@@ -603,6 +603,7 @@
currency: warranty.currency || '',
warranty_type: warranty.warranty_type || '',
notes: warranty.notes,
+ expiry_change_count: warranty.expiry_change_count || 0,
manual_path: warranty.manual_path || null,
other_document_path: warranty.other_document_path || null,
is_archived: !!warranty.is_archived,
diff --git a/tests/test_status_expiry_history_badge.py b/tests/test_status_expiry_history_badge.py
new file mode 100644
index 0000000..9479916
--- /dev/null
+++ b/tests/test_status_expiry_history_badge.py
@@ -0,0 +1,36 @@
+"""Status page expiry-history badge (issue #209 follow-up).
+
+Pins for the one-line fix: updateRecentExpirations in status.js
+rebuilds each warranty into a new object with an explicit field
+list, and expiry_change_count was not in it. The row builder and
+the expanded-row renderer both read the count off that cached
+object, so the badge never rendered and the history section never
+appeared on the Status page, even though the API returns the count.
+The live probe probe_expiry_history_main.py checks the rendered
+page in the browser (T3b).
+"""
+import re
+from pathlib import Path
+
+REPO = Path(__file__).resolve().parent.parent
+
+
+def _status_js():
+ return (REPO / "frontend" / "status.js").read_text()
+
+
+def test_status_mapping_carries_expiry_change_count():
+ js = _status_js()
+ match = re.search(
+ r"allWarranties = recentWarrantiesData\.map\(warranty => \(\{(.*?)\}\)\);",
+ js,
+ re.DOTALL,
+ )
+ assert match is not None
+ assert "expiry_change_count" in match.group(1)
+
+
+def test_status_row_and_detail_read_the_count():
+ js = _status_js()
+ assert "Number(warranty.expiry_change_count)" in js
+ assert "Number(warrantyDetails.expiry_change_count)" in js