"""Palier 23 (0.34.0, issue #24): vue « En vol partout » — l'encours tous projets, regroupé par colonne, plus vieilles cartes d'abord.""" from datetime import datetime, timedelta, timezone from app import models def _days_ago(days: int) -> str: return (datetime.now(timezone.utc) - timedelta(days=days)).strftime( "%Y-%m-%d %H:%M:%S" ) def test_inflight_groups_by_column_with_project(client): models.move_issue("Projets/demo", 5, "in_progress") models.move_issue("Projets/demo", 1, "review") r = client.get("/inflight") assert r.status_code == 200 assert "2 cartes en vol" in r.text assert "Tâche focus" in r.text assert "Tâche un" in r.text # Le projet est indiqué sur la carte. assert "Projets/demo" in r.text # Groupes par colonne, pas par projet. assert "🚧 En cours" in r.text assert "🔍 Révision" in r.text # L'âge dans la colonne est affiché. assert "dans la colonne" in r.text def test_inflight_excludes_backlog_and_todo(client): models.move_issue("Projets/demo", 5, "todo") r = client.get("/inflight") assert r.status_code == 200 assert "Tâche focus" not in r.text assert "Rien en vol" in r.text def test_inflight_oldest_first(client): # Deux cartes en cours : entrée il y a 10 j et il y a 2 j. models.move_issue("Projets/demo", 5, "in_progress") models.move_issue("Projets/demo", 1, "in_progress") models.log_event( "Projets/demo", 5, "moved", to_column="in_progress", created_at=_days_ago(10), ) models.log_event( "Projets/demo", 1, "moved", to_column="in_progress", created_at=_days_ago(2), ) r = client.get("/inflight") assert r.status_code == 200 assert r.text.index("Tâche focus") < r.text.index("Tâche un") def test_inflight_closed_issue_disappears(client, fake_gitea): models.move_issue("Projets/demo", 5, "in_progress") issue = next( i for i in fake_gitea.issues["Projets/demo"] if i["number"] == 5 ) issue["state"] = "closed" r = client.get("/inflight") assert r.status_code == 200 assert "Tâche focus" not in r.text def test_inflight_nav_and_page_chrome(client): r = client.get("/inflight") assert 'href="/inflight"' in r.text # menu latéral Pilotage assert "En vol partout" in r.text