diff --git a/tests/conftest.py b/tests/conftest.py index 4abbf2c..9742982 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,9 +55,10 @@ def _issue(number: int, title: str, state: str = "open", pr: bool = False) -> di "created_at": "2026-09-01T09:00:00Z", "updated_at": "2026-09-02T09:00:00Z", "html_url": f"http://gitea.test/Projets/demo/issues/{number}", + # Faithful to real Gitea 1.27 payloads: the key is ALWAYS + # present — null for a plain issue, an object for a PR. + "pull_request": {"url": "http://gitea.test/pr"} if pr else None, } - if pr: - issue["pull_request"] = {"url": "http://gitea.test/pr"} return issue diff --git a/tests/test_regression_gitea_payload.py b/tests/test_regression_gitea_payload.py new file mode 100644 index 0000000..c513366 --- /dev/null +++ b/tests/test_regression_gitea_payload.py @@ -0,0 +1,34 @@ +"""Regression: real Gitea returns "pull_request": null on plain issues. + +The 0.2.0–0.5.0 filter tested key *presence* ("pull_request" not in +item), which classified every real issue as a PR and silently emptied +every board against a real Gitea — while the test fake omitted the +key entirely, so the suite stayed green. Found 2026-10-11 after a +user report ("new issue does not appear on the board"): the live +flowdeck board rendered 0 cards for 6 open issues. +""" + +from app.main import _is_issue + + +def test_plain_issue_with_null_pull_request_is_an_issue(): + assert _is_issue({"number": 1, "pull_request": None}) is True + + +def test_pull_request_object_is_not_an_issue(): + assert _is_issue({"number": 2, "pull_request": {"url": "http://x/pr/2"}}) is False + + +def test_missing_key_is_an_issue(): + assert _is_issue({"number": 3}) is True + + +def test_board_renders_cards_from_realistic_payload(client): + # The shared fake now mirrors the real payload (key always + # present, null on plain issues): if the filter regresses to a + # presence test, these cards vanish and this test goes red. + r = client.get("/board/Projets/demo") + assert r.status_code == 200 + assert "Tâche un" in r.text + assert "Tâche focus" in r.text + assert "PR déguisée" not in r.text