feat(5.8): reguli mapare pe text (substring/cont) + UX tabel trimiteri (detaliu inline, fara scroll, cod RAR)
Reguli text per cont (operation_text_rules), resolve_prestatii cu param aditiv text_rules + precedenta stricta, threadat pe toate cele 6 callsite-uri + valid_codes + seam classify_prezentare. UI Mapari: sectiune reguli + preview pre-salvare + overlap + telemetrie text_rule_hit. UX tabel: cod_rar sub operatie, pill eticheta scurta, fara scroll orizontal (scopat .tabel-trimiteri + carduri <768px), detaliu inline expandabil (a11y + pauza poll). code-review: reparat regula auto_send=0 care trimitea automat la RAR in loc sa tina randul pentru review. 814 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
63
tests/test_labels.py
Normal file
63
tests/test_labels.py
Normal file
@@ -0,0 +1,63 @@
|
||||
"""
|
||||
Teste pentru eticheta_scurta (US-006, PRD 5.8).
|
||||
|
||||
RED intai: scrise inainte de implementarea functiei.
|
||||
Fisiere atinse: app/web/labels.py, tests/test_labels.py.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from app.web.labels import eticheta_scurta, eticheta_stare
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# test_eticheta_scurta_pentru_fiecare_stare
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_eticheta_scurta_pentru_fiecare_stare():
|
||||
"""Fiecare stare cunoscuta intoarce eticheta scurta corecta (pill)."""
|
||||
cazuri = {
|
||||
"queued": "In coada",
|
||||
"sending": "Se trimite",
|
||||
"sent": "Finalizat",
|
||||
"needs_mapping": "De mapat",
|
||||
"needs_data": "Date lipsa",
|
||||
"error": "Eroare",
|
||||
}
|
||||
for status, eticheta_asteptata in cazuri.items():
|
||||
rezultat = eticheta_scurta(status)
|
||||
assert rezultat == eticheta_asteptata, (
|
||||
f"Status {status!r}: asteptam {eticheta_asteptata!r}, got {rezultat!r}"
|
||||
)
|
||||
|
||||
|
||||
def test_eticheta_scurta_stare_necunoscuta_ridica_keyerror():
|
||||
"""Stare neacoperita ridica KeyError (ca sa prinda stari noi adaugate in schema)."""
|
||||
with pytest.raises(KeyError):
|
||||
eticheta_scurta("stare_inexistenta")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# test_eticheta_lunga_ramane_pentru_subtext
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_eticheta_lunga_ramane_pentru_subtext():
|
||||
"""eticheta_stare inca intoarce textele lungi neschimbate (compat cu template-uri)."""
|
||||
# Verificam fragmentele de text lung care existau inainte de US-006
|
||||
cazuri_lungi = {
|
||||
"queued": "In asteptare",
|
||||
"sending": "Se trimite acum",
|
||||
"sent": "Declarate la RAR",
|
||||
"needs_mapping": "Lipseste codul",
|
||||
"needs_data": "Date incomplete",
|
||||
"error": "Eroare la trimitere",
|
||||
}
|
||||
for status, fragment in cazuri_lungi.items():
|
||||
text, subtext, css_class = eticheta_stare(status)
|
||||
assert fragment.lower() in text.lower(), (
|
||||
f"eticheta_stare({status!r}) text lung modificat — asteptam {fragment!r} in {text!r}"
|
||||
)
|
||||
# Verifica ca tuple-ul are exact 3 elemente (invariant arhitectura C1)
|
||||
assert isinstance(css_class, str) and css_class, (
|
||||
f"eticheta_stare({status!r}) trebuie sa aiba css_class non-vida la pozitia 3"
|
||||
)
|
||||
Reference in New Issue
Block a user