feat: UI/UX cleanup V1 with header, import requisites, and status fixes
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
"""Layout tests for task 023-FIX3: project header composition + doc nav row."""
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from app.database.database import Base, DATABASE_PATH
|
||||
from app.main import app
|
||||
from app.models.project import Project
|
||||
from app.models.boq import BoqDocument
|
||||
from app.routers import (
|
||||
projects as project_router,
|
||||
boq as boq_router,
|
||||
agreements as agreement_router,
|
||||
daily_reports,
|
||||
ks2 as ks2_router,
|
||||
ks3 as ks3_router,
|
||||
payments as payments_router,
|
||||
)
|
||||
|
||||
|
||||
def _make_session(tmp_path):
|
||||
db_path = tmp_path / "t023fix3.db"
|
||||
shutil.copy2(DATABASE_PATH, db_path)
|
||||
engine = create_engine(f"sqlite:///{db_path.as_posix()}", connect_args={"check_same_thread": False})
|
||||
Base.metadata.create_all(bind=engine)
|
||||
return engine, sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
||||
|
||||
|
||||
DEPS = (
|
||||
project_router.get_db,
|
||||
boq_router.get_db,
|
||||
agreement_router.get_db,
|
||||
daily_reports.get_db,
|
||||
ks2_router.get_db,
|
||||
ks3_router.get_db,
|
||||
payments_router.get_db,
|
||||
)
|
||||
|
||||
|
||||
def _bind(Session):
|
||||
def override_db():
|
||||
s = Session()
|
||||
try:
|
||||
yield s
|
||||
finally:
|
||||
s.close()
|
||||
for dep in DEPS:
|
||||
app.dependency_overrides[dep] = override_db
|
||||
|
||||
|
||||
def _clear():
|
||||
for dep in DEPS:
|
||||
app.dependency_overrides.pop(dep, None)
|
||||
|
||||
|
||||
def _seed(Session):
|
||||
with Session() as s:
|
||||
p = Project(name="FIX3", status="active")
|
||||
s.add(p)
|
||||
s.flush()
|
||||
s.add(BoqDocument(project_id=p.id, name="Ведомость ОВ"))
|
||||
s.commit()
|
||||
return p.id
|
||||
|
||||
|
||||
NAV_HREFS = [
|
||||
"/boq/{pid}",
|
||||
"/projects/{pid}/agreements",
|
||||
"/projects/{pid}/daily-reports",
|
||||
"/projects/{pid}/ks2",
|
||||
"/projects/{pid}/ks3",
|
||||
"/projects/{pid}/ks6a",
|
||||
"/projects/{pid}/payments",
|
||||
]
|
||||
|
||||
|
||||
def test_doc_nav_has_all_seven_buttons_in_one_row(tmp_path):
|
||||
engine, Session = _make_session(tmp_path)
|
||||
_bind(Session)
|
||||
try:
|
||||
pid = _seed(Session)
|
||||
with TestClient(app) as client:
|
||||
html = client.get(f"/projects/{pid}").text
|
||||
nav = re.search(r'<nav class="doc-nav[^"]*"[^>]*>(.*?)</nav>', html, re.S)
|
||||
assert nav, "doc-nav block missing"
|
||||
block = nav.group(1)
|
||||
for href in NAV_HREFS:
|
||||
assert f'href="{href.format(pid=pid)}"' in block, href
|
||||
# Exactly 7 nav buttons in the block
|
||||
assert block.count('class="btn btn-outline-primary"') == 7
|
||||
finally:
|
||||
_clear()
|
||||
engine.dispose()
|
||||
|
||||
|
||||
def test_doc_nav_has_no_horizontal_scroll_wrapper(tmp_path):
|
||||
engine, Session = _make_session(tmp_path)
|
||||
_bind(Session)
|
||||
try:
|
||||
pid = _seed(Session)
|
||||
with TestClient(app) as client:
|
||||
html = client.get(f"/projects/{pid}").text
|
||||
nav = re.search(r'<nav class="doc-nav([^"]*)"', html)
|
||||
assert nav
|
||||
classes = nav.group(1)
|
||||
assert "overflow" not in classes
|
||||
assert "table-responsive" not in classes
|
||||
# CSS: nowrap flex, no overflow-x
|
||||
assert ".doc-nav" in html
|
||||
assert "flex-wrap: nowrap" in html
|
||||
assert "overflow-x" not in html
|
||||
finally:
|
||||
_clear()
|
||||
engine.dispose()
|
||||
|
||||
|
||||
def test_header_order_and_eye_toggle_separate(tmp_path):
|
||||
engine, Session = _make_session(tmp_path)
|
||||
_bind(Session)
|
||||
try:
|
||||
pid = _seed(Session)
|
||||
with TestClient(app) as client:
|
||||
html = client.get(f"/projects/{pid}").text
|
||||
# Actions under title, not in a justify-content-between top row
|
||||
assert "Дневной отчёт" in html
|
||||
assert "Редактировать" in html
|
||||
# Requisites remain separate blocks
|
||||
for label in ("Договор", "Заказчик", "Валюта", "Период", "Статус"):
|
||||
assert f'class="text-muted small mb-1">{label}</div>' in html
|
||||
# BOQ line
|
||||
assert "Ведомость проекта:" in html
|
||||
# Eye toggle is outside doc-nav and before План и выполнение
|
||||
nav_end = html.find("</nav>")
|
||||
plan_pos = html.find("План и выполнение")
|
||||
eye_pos = html.find('id="toggleMoney"')
|
||||
assert 0 < nav_end < eye_pos < plan_pos
|
||||
assert "Финансовые суммы" in html
|
||||
# Archive / delete still present
|
||||
assert "Архивировать" in html or "Проект архивирован" in html
|
||||
assert "delete-project-form" in html or "Проект архивирован" in html
|
||||
finally:
|
||||
_clear()
|
||||
engine.dispose()
|
||||
Reference in New Issue
Block a user