fix(frontend): #37 punti 1,4,5,6 - 502 backend giù, barcode quotato, apici Alpine, paginazione ricette
1. api_client.py: ConnectionError/Timeout restituisce status_code=502 invece
di 0 (nessuna route confrontava == 0, verificato); i proxy che inoltrano
resp.get("status_code", 500) ereditano il fix senza altre modifiche.
4. measure.py lookup_barcode: code non stringa -> 400 (prima 500 su
code.strip()); urllib.parse.quote(code, safe="") prima di comporre l'URL
verso il backend - un barcode con '/' o '../' non spezza più il path né
raggiunge altri GET con i permessi dell'utente.
5. Ogni "'{{ _(...) }}'" dentro un attributo Alpine (x-text, :title,
:placeholder, @click) sostituito con "{{ _(...)|tojson_attr }}": la
traduzione EN di admin/stations.html:105 ("Clear the station's recipes")
ha un apostrofo che l'IT non ha, e rompeva quel binding e basta - non è
un XSS, ma stessa classe di difetto di #10. File toccati: admin/stations,
admin/users, maker/recipe_list, maker/recipe_editor, maker/task_editor,
maker/task_drawing, components/caliper_status, measure/select_recipe.
Le occorrenze dentro <script>...</script> (non attributi) sono fuori
perimetro per questo punto.
6. statistics.py dashboard(): ciclo sulle pagine (per_page=100, il massimo
del backend) invece di un'unica chiamata che troncava la tendina ricette
alla centesima.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -197,6 +197,39 @@ def test_admin_stations_inline_js_is_valid(logged_in_client, mock_admin_api):
|
||||
_check_alpine_attributes(html, "/admin/stations")
|
||||
|
||||
|
||||
def test_admin_stations_inline_js_is_valid_in_english(logged_in_client, mock_admin_api):
|
||||
"""gitea#37.5: the EN catalog is where this page's apostrophe actually is.
|
||||
|
||||
translations/en/LC_MESSAGES/messages.po: msgid "Azzera le ricette della
|
||||
stazione" -> msgstr "Clear the station's recipes" (admin/stations.html:105).
|
||||
The IT source string has no apostrophe, so test_admin_stations_inline_js_is_valid
|
||||
(IT-only) would never have caught this - #37.5's own TEST note calls out
|
||||
the EN render specifically.
|
||||
"""
|
||||
mock_admin_api.get.side_effect = [
|
||||
[{
|
||||
"id": 1, "code": "ST-DEFAULT", "name": "Default Station",
|
||||
"location": None, "notes": None, "active": True,
|
||||
"created_by": 1, "created_at": "2026-04-25T10:00:00",
|
||||
}],
|
||||
[{"id": 1, "code": "DEMO-001", "name": "Demo Recipe", "active": True}],
|
||||
]
|
||||
|
||||
with logged_in_client.session_transaction() as sess:
|
||||
sess["language"] = "en"
|
||||
resp = logged_in_client.get("/admin/stations")
|
||||
assert resp.status_code == 200, resp.data[:300]
|
||||
|
||||
html = resp.data.decode("utf-8")
|
||||
assert "station" in html.lower(), "sanity check: the EN string did render"
|
||||
|
||||
scripts = _INLINE_SCRIPT_RX.findall(html)
|
||||
for i, body in enumerate(scripts):
|
||||
_node_check(body, f"/admin/stations (en) script[{i}]")
|
||||
|
||||
_check_alpine_attributes(html, "/admin/stations (en)")
|
||||
|
||||
|
||||
def test_admin_users_inline_js_is_valid(logged_in_client, mock_admin_api):
|
||||
"""Same guard for /admin/users (reuses the userManagement Alpine pattern)."""
|
||||
mock_admin_api.get.return_value = [{
|
||||
|
||||
Reference in New Issue
Block a user