"""BUG C: analyst "artifacts ready" comment under the status-only model. The comment must ask for the **Approved** status (not the obsolete ":approved:" reaction, not moving back to "In Progress") and link only the docs that actually exist in the worktree. """ import os import tempfile os.environ.setdefault("ORCH_GITEA_TOKEN", "test-token") os.environ.setdefault("ORCH_PLANE_API_TOKEN", "test-token") def test_analyst_comment_asks_approved_with_links(monkeypatch, tmp_path): from src import stage_engine as SE # Worktree with only SOME of the candidate docs present. wt = tmp_path / "wt" docs = wt / "docs" / "work-items" / "ET-011" docs.mkdir(parents=True) for fname in ("00-business-request.md", "01-brd.md", "02-trz.md", "03-acceptance-criteria.md", "04-test-plan.yaml"): (docs / fname).write_text("x") # 04b-ui-test-cases.md intentionally absent -> must NOT be linked monkeypatch.setattr(SE, "get_worktree_path", lambda repo, branch: str(wt)) # public URL set -> links must be built from it (not gitea_url) monkeypatch.setattr(SE.settings, "gitea_url", "http://localhost:3000") monkeypatch.setattr(SE.settings, "gitea_public_url", "https://git.mva154.duckdns.org") monkeypatch.setattr(SE.settings, "gitea_owner", "admin") html = SE._build_analyst_ready_comment( "enduro-trails", "ET-011", "feature/ET-011-gpx-upload-feature" ) # text asks for the Approved STATUS, not the obsolete mechanisms assert "Approved" in html assert ":approved:" not in html assert "In Progress" not in html assert "Rejected" in html # clickable links to docs that ACTUALLY exist assert "