feat(5.12): modal editare + cont obligatoriu la import; design.md + PRD 5.13 revizuit (/autoplan)
5.12 (livrat): editare in modal a randurilor de preview, cont obligatoriu inainte de import, formular editare extras (_form_editare, _editare_preview_modal), plus suita de teste aferenta (preview edit/compact, mapare op, form editare, signup, admin panel). Design + planificare: - docs/design.md: sistem de design (tokeni, breakpoints, scara control, componente, a11y). - docs/prd/prd-5.12-* si prd-5.13-* (5.13 cu raport /autoplan: CEO+Design+Eng, audit trail). Curatare: sterse PNG-urile de test/mockup temporare din radacina. Nota: implementarea CSS 5.13 (responsive compact + sistem butoane) NU e inca facuta — planul revizuit cere refactorul testelor fragile din test_web_responsive.py INAINTE de CSS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -230,3 +230,126 @@ def test_fragment_cont_nelogat_redirect(monkeypatch):
|
||||
assert resp.status_code == 303
|
||||
assert "/login" in resp.headers.get("location", "")
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
# ============================================================
|
||||
# US-002: sectiunea 'Date firma' + banner cont incomplet
|
||||
# ============================================================
|
||||
|
||||
def _create_complete_account(
|
||||
name: str = "Firma Test SRL",
|
||||
login_email: str = "firma_test@test.com",
|
||||
account_email: str = "contact@firma.com",
|
||||
cui: str = "RO12345678",
|
||||
password: str = "parolasecreta10",
|
||||
):
|
||||
"""Creeaza cont COMPLET (name+email+CUI) + user. Intoarce (acct_id, user_id)."""
|
||||
from app.accounts import create_account
|
||||
from app.users import create_user
|
||||
from app.db import get_connection
|
||||
|
||||
conn = get_connection()
|
||||
try:
|
||||
acct_id = create_account(conn, name, cui=cui, email=account_email, active=True)
|
||||
user_id = create_user(conn, acct_id, login_email, password)
|
||||
return acct_id, user_id
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def test_cont_afiseaza_companie_email_cui(client):
|
||||
"""Fragment /_fragments/cont contine sectiunea 'Date firma' cu companie, email, CUI prefilled."""
|
||||
_create_complete_account(
|
||||
name="Test Firma SRL",
|
||||
login_email="tfirma@test.com",
|
||||
account_email="contact_tf@test.com",
|
||||
cui="RO11111111",
|
||||
)
|
||||
_login(client, "tfirma@test.com", "parolasecreta10")
|
||||
|
||||
resp = client.get("/_fragments/cont")
|
||||
assert resp.status_code == 200
|
||||
assert "Date firma" in resp.text or "date-firma" in resp.text, \
|
||||
f"Sectiunea 'Date firma' lipseste: {resp.text[:500]}"
|
||||
assert "Test Firma SRL" in resp.text, f"Compania nu e prefilled: {resp.text[:500]}"
|
||||
assert "contact_tf@test.com" in resp.text, f"Email-ul nu e prefilled: {resp.text[:500]}"
|
||||
assert "RO11111111" in resp.text, f"CUI-ul nu e prefilled: {resp.text[:500]}"
|
||||
|
||||
|
||||
def test_post_date_firma_actualizeaza(client):
|
||||
"""POST /cont/date-firma actualizeaza accounts.name, accounts.email, accounts.cui in DB."""
|
||||
acct_id, user_id, _ = _create_account_user("update_df@test.com")
|
||||
_login(client, "update_df@test.com", "parolasecreta10")
|
||||
|
||||
csrf = _get_csrf_from_fragment(client)
|
||||
|
||||
resp = client.post("/cont/date-firma", data={
|
||||
"csrf_token": csrf,
|
||||
"companie": "Firma Actualizata SRL",
|
||||
"email": "contact@firma-act.com",
|
||||
"cui": "RO99887766",
|
||||
})
|
||||
assert resp.status_code == 200, f"POST /cont/date-firma a returnat {resp.status_code}"
|
||||
|
||||
# Verifica in DB ca datele au fost actualizate
|
||||
from app.db import get_connection
|
||||
conn = get_connection()
|
||||
try:
|
||||
row = conn.execute(
|
||||
"SELECT name, email, cui FROM accounts WHERE id=?", (acct_id,)
|
||||
).fetchone()
|
||||
assert row["name"] == "Firma Actualizata SRL", f"name neschimbat: {row['name']}"
|
||||
assert row["email"] == "contact@firma-act.com", f"email neschimbat: {row['email']}"
|
||||
assert row["cui"] == "RO99887766", f"cui neschimbat: {row['cui']}"
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def test_post_date_firma_cui_duplicat_eroare(client):
|
||||
"""POST /cont/date-firma cu CUI deja folosit de alt cont -> eroare in raspuns."""
|
||||
# Cont A cu CUI existent
|
||||
_create_complete_account(
|
||||
name="Firma A SRL",
|
||||
login_email="firma_a_dup@test.com",
|
||||
account_email="a_dup@test.com",
|
||||
cui="ROAAA11111",
|
||||
)
|
||||
# Cont B fara CUI
|
||||
acct_b, user_b, _ = _create_account_user("firma_b_dup@test.com")
|
||||
|
||||
_login(client, "firma_b_dup@test.com", "parolasecreta10")
|
||||
csrf = _get_csrf_from_fragment(client)
|
||||
|
||||
resp = client.post("/cont/date-firma", data={
|
||||
"csrf_token": csrf,
|
||||
"companie": "Firma B SRL",
|
||||
"email": "firma_b_dup@test.com",
|
||||
"cui": "ROAAA11111", # CUI-ul lui A — duplicat
|
||||
})
|
||||
assert resp.status_code == 200
|
||||
text = resp.text.lower()
|
||||
assert "deja" in text or "duplicat" in text or "folosit" in text or "eroare" in text, \
|
||||
f"Mesaj eroare CUI duplicat lipsa: {resp.text[:500]}"
|
||||
|
||||
# Contul B nu trebuie sa aiba CUI-ul lui A in DB
|
||||
from app.db import get_connection
|
||||
conn = get_connection()
|
||||
try:
|
||||
row = conn.execute("SELECT cui FROM accounts WHERE id=?", (acct_b,)).fetchone()
|
||||
assert row["cui"] != "ROAAA11111", "CUI-ul duplicat a fost totusi salvat in DB"
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def test_banner_cont_incomplet_pe_legacy(client):
|
||||
"""Acasa afiseaza banner 'Completeaza datele firmei' cand contul e incomplet (fara email/CUI)."""
|
||||
# Cont fara email/CUI (legacy: creat fara aceste campuri)
|
||||
_create_account_user("legacy_test@test.com")
|
||||
_login(client, "legacy_test@test.com", "parolasecreta10")
|
||||
|
||||
resp = client.get("/")
|
||||
assert resp.status_code == 200
|
||||
text = resp.text.lower()
|
||||
# Banner trebuie sa apara cand contul e incomplet
|
||||
assert "completeaza" in text or "date firm" in text or "incomplet" in text, \
|
||||
f"Banner 'Completeaza datele firmei' lipsa pe Acasa: {resp.text[:2000]}"
|
||||
|
||||
Reference in New Issue
Block a user