feat(3 U3): YunoHost-style PR comment (🌻 + level badge + summary card images, linked) updated in place per PR; text fallback; bridge tests + dashboard do_HEAD
This commit is contained in:
@ -39,3 +39,48 @@ def test_non_trigger_forms_rejected():
|
||||
None,
|
||||
):
|
||||
assert bridge.parse_trigger(body) == (False, False), body
|
||||
|
||||
|
||||
# --- Phase 3 U3: YunoHost-style PR comment builders (R2) -----------------------------------------
|
||||
|
||||
def test_start_comment_is_yunohost_shaped():
|
||||
b = bridge.start_comment_body("uptime-kuma", "dfed87a39f8a", "https://drone.x/cc-ci/42")
|
||||
assert bridge.COMMENT_MARKER in b # re-!testme updates the same comment
|
||||
assert "🌻" in b and "⏳" in b # marker + in-progress
|
||||
assert "uptime-kuma" in b and "dfed87a3" in b
|
||||
assert "https://drone.x/cc-ci/42" in b
|
||||
|
||||
|
||||
def test_result_comment_image_forward_when_card_available(monkeypatch):
|
||||
monkeypatch.setattr(bridge, "artifact_available", lambda url: True)
|
||||
monkeypatch.setattr(bridge, "DASH_URL", "https://ci.example")
|
||||
b = bridge.result_comment_body("uptime-kuma", "dfed87a39f8a", "42", "https://drone.x/cc-ci/42", "success")
|
||||
assert bridge.COMMENT_MARKER in b
|
||||
assert "✅" in b and "passed" in b
|
||||
# the card + badge are embedded as linked images at the stable /runs/<num>/ URLs
|
||||
assert "" in b
|
||||
assert "https://ci.example/runs/42/badge.svg" in b
|
||||
assert "(https://drone.x/cc-ci/42)" in b # links to the run
|
||||
|
||||
|
||||
def test_result_comment_text_fallback_when_card_missing(monkeypatch):
|
||||
# Render failed / not served → MUST degrade to text, never a broken image (R7).
|
||||
monkeypatch.setattr(bridge, "artifact_available", lambda url: False)
|
||||
b = bridge.result_comment_body("hedgedoc", "abc1234def", "9", "https://drone.x/cc-ci/9", "failure")
|
||||
assert "summary.png" not in b # no image embed
|
||||
assert "![" not in b # no markdown image at all
|
||||
assert "❌" in b and "failure" in b
|
||||
assert "https://drone.x/cc-ci/9" in b
|
||||
|
||||
|
||||
def test_find_existing_comment_matches_marker(monkeypatch):
|
||||
monkeypatch.setattr(bridge, "list_comments", lambda fn, n: [
|
||||
{"id": 1, "body": "just a normal comment"},
|
||||
{"id": 2, "body": bridge.COMMENT_MARKER + "\n🌻 old run"},
|
||||
])
|
||||
assert bridge.find_existing_comment("org/repo", 5) == 2
|
||||
|
||||
|
||||
def test_find_existing_comment_none_when_absent(monkeypatch):
|
||||
monkeypatch.setattr(bridge, "list_comments", lambda fn, n: [{"id": 1, "body": "hello"}])
|
||||
assert bridge.find_existing_comment("org/repo", 5) is None
|
||||
|
||||
Reference in New Issue
Block a user