Aduce toate suprafetele dashboard-ului la grila tabelului Trimiteri, muta
navigarea intr-un meniu de cont (hamburger) si da panoului admin actiuni
reale de ciclu de viata. 9 stories, 3 valuri. UI pur (reskin + reasezare)
cu O SINGURA exceptie backend: modelul de stare a contului.
- US-001 sectiunea "Ajutor" eliminata din Acasa (wayfinding redundant).
- US-002 Nomenclator la grila standard (_submissions.html ca referinta).
- US-003 macro autosend compact (Manual<->Auto). Semantica de PREZENTA
`auto_send` (bifat->true, absent->false) NEALTERATA — compatibil cu ambele
parsere (Form(bool) la /mapari, bool(form.get()) la import). Zero backend.
- US-004 accounts.status (pending/active/blocked/archived/deleted), migrare
defensiva idempotenta derivata din `active`, gate worker claim_one pe
status='active' (echivalenta active=1 <=> status='active' pastrata).
- US-005 tabel Mapari compact + panou Ajutor (<details>, proza o singura data),
coloana "In coada".
- US-006 meniu hamburger dropdown (Cont/Integrare/Nomenclator/Admin/logout) +
context is_authenticated/is_admin/csrf_token defensiv in base.html.
- US-007 tab-bar redus la Acasa+Mapari; rutele /_fragments/{cont,integrare,
nomenclator} + deep-link ?tab= raman valide.
- US-008 rute admin block/archive/delete + bulk pe lista account_id,
require_admin + CSRF + PRG, dev id=1 sarit in bulk.
- US-009 admin UI: selectie bife + master + bara bulk + kebab per-rand,
grupare pe stare (bloc nou blocate/arhivate), nota "cont dev implicit" scoasa.
Stergere = SOFT: tombstone (status='deleted'), dar PII purjata IMEDIAT
(rar_creds_enc + chei API revocate + CUI eliberat pentru re-inregistrare),
GDPR/L.142.
VERIFY: 671 teste pass (+40). E2E browser (Playwright) a prins 2 bug-uri
invizibile la TestClient: bara bulk cu display:flex inline invingea [hidden]
(mutat in CSS .bulk-bar[hidden]); conturi arhivate cadeau sub "in asteptare"
(grupare pe status). /code-review high a prins 2 bug-uri reale: soft delete
pastra creds RAR + CUI la nesfarsit fara purjare accounts (GDPR neonorat);
apostrof in numele firmei rupea confirm() inline din kebab — ambele reparate,
plus cleanup boilerplate rute (_lifecycle_route).
Backend trimitere (worker masina stari/idempotenta/mapping) neatins, cu
exceptia gate-ului de cont. Design: docs/design/5.5-uniformizare-ui.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
87 lines
2.8 KiB
Python
87 lines
2.8 KiB
Python
"""Teste US-006 (PRD 5.5): meniu hamburger in header (Cont/Integrare/Nomenclator/Admin/logout)
|
|
+ context de autentificare. base.html partajat: pe login/signup meniul nu expune cont/logout.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import re
|
|
import tempfile
|
|
|
|
import pytest
|
|
from starlette.testclient import TestClient
|
|
|
|
|
|
@pytest.fixture()
|
|
def client(monkeypatch):
|
|
tmp = tempfile.mkdtemp()
|
|
monkeypatch.setenv("AUTOPASS_DB_PATH", os.path.join(tmp, "menu_test.db"))
|
|
monkeypatch.setenv("AUTOPASS_WEB_AUTH_REQUIRED", "true")
|
|
from app.config import get_settings
|
|
get_settings.cache_clear()
|
|
from app.web import ratelimit
|
|
ratelimit._hits.clear()
|
|
from app.main import app
|
|
with TestClient(app, follow_redirects=False) as c:
|
|
yield c
|
|
ratelimit._hits.clear()
|
|
get_settings.cache_clear()
|
|
|
|
|
|
def _make_user(email="u@test.com", password="parolasecreta10", is_admin=False):
|
|
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, "Service Test", active=True)
|
|
create_user(conn, acct_id, email, password, is_admin=is_admin)
|
|
return acct_id
|
|
finally:
|
|
conn.close()
|
|
|
|
|
|
def _login(client, email="u@test.com", password="parolasecreta10"):
|
|
resp = client.get("/login")
|
|
csrf = re.search(r'name="csrf_token"\s+value="([^"]+)"', resp.text).group(1)
|
|
resp = client.post("/login", data={"email": email, "parola": password, "csrf_token": csrf})
|
|
assert resp.status_code == 303
|
|
|
|
|
|
def test_meniu_autentificat_are_linkuri_cont(client):
|
|
_make_user()
|
|
_login(client)
|
|
html = client.get("/").text
|
|
# butonul de meniu (hamburger) prezent
|
|
assert 'id="cont-menu-toggle"' in html
|
|
assert 'aria-controls="cont-menu"' in html
|
|
# linkurile mutate in meniu
|
|
assert 'href="/?tab=cont"' in html
|
|
assert 'href="/?tab=integrare"' in html
|
|
assert 'href="/?tab=nomenclator"' in html
|
|
# logout in meniu
|
|
assert 'action="/logout"' in html
|
|
assert "Iesi din cont" in html
|
|
|
|
|
|
def test_meniu_admin_link_doar_pentru_admin(client):
|
|
_make_user(email="admin@test.com", is_admin=True)
|
|
_login(client, email="admin@test.com")
|
|
html = client.get("/").text
|
|
assert 'href="/admin"' in html
|
|
|
|
|
|
def test_meniu_fara_admin_pentru_neadmin(client):
|
|
_make_user(email="plain@test.com", is_admin=False)
|
|
_login(client, email="plain@test.com")
|
|
html = client.get("/").text
|
|
assert 'href="/admin"' not in html
|
|
|
|
|
|
def test_meniu_neautentificat_fara_logout(client):
|
|
"""Pe /login (neautentificat) meniul nu expune cont/logout."""
|
|
html = client.get("/login").text
|
|
assert "Iesi din cont" not in html
|
|
assert 'action="/logout"' not in html
|
|
assert 'id="cont-menu-toggle"' not in html
|