feat(5.15+5.14): CLOSE — fix-uri code-review + embeddings functional
5.15 (propagare design + dashboard editare) si 5.14 (mapare LLM distilata) inchise dupa /code-review high. 8 buguri reparate TDD: - HIGH modal nu se deschidea pe randul slim (base.html: trimitere-slim) - HIGH /repune trunchia prestatii (declaratie incompleta la RAR) -> iterare peste existing, codes pozitional - HIGH embeddings incarca model ~230MB degeaba pe corpus gol -> poarta has_corpus() - HIGH picker chips gol pe re-render eroare -> conn/account_id pe toate ramurile - MED obs re-derivat dupa stergere explicita -> _merge_override pastreaza obs='' - MED mapare salvata fara denumire poluă GOLD -> _record_gold_validation guard - MED typo nome_prestatie -> nume_prestatie in select /repune - MED bucketare timp +3h gresita iarna -> SQLite localtime + TZ=Europe/Bucharest Embeddings WIRE-uit functional (PRD #15, decizie user): ensure_embeddings_corpus construieste corpus din nomenclator, gated pe AUTOPASS_EMBEDDINGS_ENABLED (default off). Marime model corectata ~50MB->~230MB (estimare PRD gresita). Cleanup: hoist load_* din bucla bulk-fix; import re la top. Regresie: 1256 passed, 1 deselected (live), 0 failed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -78,7 +78,11 @@ def client(monkeypatch):
|
||||
|
||||
|
||||
def test_submissions_coloane_umane(client):
|
||||
"""Antete RO; stare umana (nu 'sent'); vehicul/operatie din payload; fara 'HTTP RAR' ca antet."""
|
||||
"""US-004 (PRD 5.15): layout slim — informatia umana vizibila, cod brut ascuns.
|
||||
Anterior (pana la US-004): tabel cu antete <th>; dupa US-004: lista slim.
|
||||
Informatia ramane accesibila: vehicul/operatie din payload, stare umana,
|
||||
nr. prezentare RAR pe linia meta discreta.
|
||||
"""
|
||||
acct = _create_account_user("col@test.com")
|
||||
_insert_submission(acct, "sent", id_prezentare=68516)
|
||||
_login(client, "col@test.com")
|
||||
@@ -86,17 +90,25 @@ def test_submissions_coloane_umane(client):
|
||||
resp = client.get("/_fragments/submissions")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
# Antete romanesti (Motiv a iesit din tabel in PRD 5.8 US-007 -> traieste in detaliu)
|
||||
for antet in ("Stare", "Vehicul", "Operatie", "Data prestatie", "Nr. prezentare RAR"):
|
||||
assert antet in html, f"Lipseste antetul '{antet}'"
|
||||
# "HTTP RAR" NU mai e antet principal de coloana
|
||||
|
||||
# Layout slim prezent (US-004 PRD 5.15)
|
||||
assert "lista-trimiteri-slim" in html, "lista slim lipseste"
|
||||
assert "trimitere-slim" in html, "rand slim lipseste"
|
||||
|
||||
# "HTTP RAR" NU e antet / eticheta vizibila
|
||||
assert "<th>HTTP RAR</th>" not in html
|
||||
# Starea afisata e text uman, nu 'sent' brut intr-un pill
|
||||
assert ">sent<" not in html, "Starea bruta 'sent' nu ar trebui afisata"
|
||||
assert "Declarate la RAR" in html, "Starea umana lipseste"
|
||||
# Vehicul + operatie din payload, nu doar idPrezentare
|
||||
assert "B777ZZZ" in html
|
||||
assert "Reparatie frane" in html
|
||||
assert "HTTP RAR" not in html
|
||||
|
||||
# Starea afisata e text uman, nu 'sent' brut
|
||||
assert ">sent<" not in html, "Starea bruta 'sent' nu ar trebui afisata direct"
|
||||
assert "Declarate la RAR" in html, "Starea umana (titlu pill) lipseste"
|
||||
|
||||
# Vehicul + operatie din payload vizibile pe rand slim
|
||||
assert "B777ZZZ" in html, "Nr inmatriculare din payload lipseste"
|
||||
assert "Reparatie frane" in html, "Operatia din payload lipseste"
|
||||
|
||||
# Nr. prezentare RAR accesibil pe linia meta discreta
|
||||
assert "68516" in html, "Nr. prezentare RAR lipseste din linia meta"
|
||||
|
||||
|
||||
def test_tab_eticheta_trimiteri(client):
|
||||
@@ -405,3 +417,128 @@ def test_detaliu_trimitere_404_cross_account(client):
|
||||
# acelasi 404 pentru un id inexistent
|
||||
resp2 = client.get("/_fragments/trimitere/999999")
|
||||
assert resp2.status_code == 404
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# US-004 (PRD 5.15): lista trimiteri rand slim
|
||||
# RED (inainte de implementare): testele de mai jos ESUEAZA pe tabelul vechi.
|
||||
# GREEN (dupa implementare): lista slim cu .trimitere-slim / .lista-trimiteri-slim.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_rand_slim_vin_operatie_pill(client):
|
||||
"""US-004: fiecare rand slim afiseaza VIN scurt in .slim-vin, operatie+ora in
|
||||
.slim-meta si un pill de stare cu clasa stare_css si eticheta stare_scurt.
|
||||
Lista e inconjurata de .lista-trimiteri-slim.
|
||||
"""
|
||||
acct = _create_account_user("slim1@test.com")
|
||||
_insert_submission(acct, "sent", id_prezentare=80001)
|
||||
_login(client, "slim1@test.com")
|
||||
|
||||
resp = client.get("/_fragments/submissions")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
|
||||
# Structura slim prezenta
|
||||
assert "lista-trimiteri-slim" in html, "lista-trimiteri-slim lipseste din raspuns"
|
||||
assert "trimitere-slim" in html, "trimitere-slim lipseste din raspuns"
|
||||
|
||||
# VIN scurt in clasa slim-vin (mono, linia 1)
|
||||
assert "slim-vin" in html, "slim-vin lipseste — linia 1 VIN mono"
|
||||
|
||||
# Linia 2 muted (operatie + ora/data)
|
||||
assert "slim-meta" in html, "slim-meta lipseste — linia 2 muted"
|
||||
|
||||
# VIN scurt randat (WVWZZZ1JZXW000777 -> …000777)
|
||||
assert "000777" in html, "VIN scurt (ultimele 6 cifre) lipseste"
|
||||
|
||||
# Pill de stare: clasa CSS + eticheta scurta
|
||||
assert "s-sent" in html, "clasa pill s-sent lipseste"
|
||||
assert "Finalizat" in html, "eticheta scurta stare_scurt lipseste"
|
||||
|
||||
|
||||
def test_filtre_paginare_pastrate(client):
|
||||
"""US-004 lock: filtrele si paginarea raman functionale dupa redesign slim.
|
||||
Lista slim afiseaza rezultatele filtrate corect.
|
||||
"""
|
||||
acct = _create_account_user("filtrepag@test.com")
|
||||
_insert_submission(acct, "sent")
|
||||
_insert_submission(acct, "needs_data")
|
||||
_login(client, "filtrepag@test.com")
|
||||
|
||||
# Fara filtru: ambele randuri, layout slim
|
||||
resp = client.get("/_fragments/submissions")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
assert "lista-trimiteri-slim" in html, "lista slim lipseste din randare nefiltered"
|
||||
|
||||
# OOB f-page exista (mecanismul de paginare intact)
|
||||
assert 'id="f-page"' in html, "OOB input f-page lipseste — paginarea e rupta"
|
||||
|
||||
# Filtrare dupa status=sent: contul trebuie sa arate DOAR trimis
|
||||
resp_sent = client.get("/_fragments/submissions?status=sent")
|
||||
assert resp_sent.status_code == 200
|
||||
html_sent = resp_sent.text
|
||||
assert "lista-trimiteri-slim" in html_sent, "lista slim lipseste din randare filtrata"
|
||||
# Randul needs_data dispare la filtru=sent
|
||||
assert "s-needs_data" not in html_sent, "randul needs_data apare la filtru status=sent"
|
||||
# Randul sent apare
|
||||
assert "s-sent" in html_sent, "randul sent lipseste la filtru status=sent"
|
||||
|
||||
|
||||
def test_bulk_doar_blocate(client):
|
||||
"""US-004 lock: form bulk-trimiteri exista; checkbox DOAR pe randuri gestionabile
|
||||
(needs_data/needs_mapping/error); randurile read-only (sent) nu au checkbox.
|
||||
"""
|
||||
acct = _create_account_user("bulk5@test.com")
|
||||
sid_blocked = _insert_submission(acct, "needs_data") # gestionabil -> checkbox
|
||||
_insert_submission(acct, "sent") # read-only -> fara checkbox
|
||||
_login(client, "bulk5@test.com")
|
||||
|
||||
resp = client.get("/_fragments/submissions")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
|
||||
# Layout slim prezent
|
||||
assert "lista-trimiteri-slim" in html, "lista slim lipseste — test nu acopera US-004"
|
||||
|
||||
# Form bulk exista cu actiunea corecta
|
||||
assert 'id="bulk-trimiteri"' in html, "form#bulk-trimiteri lipseste"
|
||||
assert 'hx-post="/trimiteri/sterge-bulk"' in html, "actiunea bulk-delete lipseste"
|
||||
|
||||
# Checkbox prezent pe randul blocat
|
||||
assert f'name="submission_id" value="{sid_blocked}"' in html, \
|
||||
f"Checkbox lipseste pe randul blocat #{sid_blocked}"
|
||||
|
||||
# Exact 1 checkbox (randul sent nu are)
|
||||
checkboxes = re.findall(r'name="submission_id"', html)
|
||||
assert len(checkboxes) == 1, \
|
||||
f"Trebuie exact 1 checkbox (doar randul blocat), gasit {len(checkboxes)}"
|
||||
|
||||
|
||||
def test_click_deschide_detaliu(client):
|
||||
"""US-004: click pe randul slim deschide /_fragments/trimitere/{id} in modalul global.
|
||||
Randul are atributele HTMX si a11y necesare (role=button, aria-haspopup=dialog).
|
||||
"""
|
||||
acct = _create_account_user("clickdet@test.com")
|
||||
sid = _insert_submission(acct, "sent")
|
||||
_login(client, "clickdet@test.com")
|
||||
|
||||
resp = client.get("/_fragments/submissions")
|
||||
assert resp.status_code == 200
|
||||
html = resp.text
|
||||
|
||||
# Layout slim ca premisa (confirma ca testul acopera noul design)
|
||||
assert "lista-trimiteri-slim" in html, "lista slim lipseste — test nu acopera US-004"
|
||||
|
||||
# Randul are hx-get catre fragmentul de detaliu
|
||||
assert f'hx-get="/_fragments/trimitere/{sid}"' in html, \
|
||||
f"hx-get spre /_fragments/trimitere/{sid} lipseste"
|
||||
|
||||
# Target = corpul modalului global (neschimbat fata de implementarea anterioara)
|
||||
assert 'hx-target="#detaliu-modal-body"' in html, \
|
||||
"hx-target #detaliu-modal-body lipseste"
|
||||
|
||||
# Atribute a11y: role=button, tabindex=0, aria-haspopup=dialog
|
||||
assert 'role="button"' in html, "role=button lipseste pe randul slim"
|
||||
assert 'tabindex="0"' in html, "tabindex=0 lipseste pe randul slim"
|
||||
assert 'aria-haspopup="dialog"' in html, "aria-haspopup=dialog lipseste pe randul slim"
|
||||
|
||||
Reference in New Issue
Block a user