Просмотр исходного кода

fix: hide the review block's duplicate body preview while the review section shows it (same pattern as the plan-review fix)

clanker 1 месяц назад
Родитель
Сommit
e51bad5de4
2 измененных файлов с 27 добавлено и 4 удалено
  1. 6 4
      src/entrypoints/TaskDetailEntrypoint.vala
  2. 21 0
      test/web_stack_test.py

+ 6 - 4
src/entrypoints/TaskDetailEntrypoint.vala

@@ -237,10 +237,12 @@ namespace ClankerSaddle {
                     pub.review_summary = view.body.length > 0 ? view.body : view.question;
                     pub.review_diff_url = yield tasks.diff_url_for_task(task.id);
                 }
-                // The pending plan-review section renders task.plan, so
-                // the block body (the same markdown) stays hidden until
-                // the review is answered.
-                view.show_body = !view.is_plan_review || view.answered;
+                // The pending plan-review and review sections each render
+                // the markdown themselves (task.plan / the review summary),
+                // so the block's own body preview — the same text — stays
+                // hidden until the block is answered.
+                view.show_body = (!view.is_plan_review && view.block_type != BLOCK_REVIEW)
+                    || view.answered;
                 blocks.add(view);
             }
 

+ 21 - 0
test/web_stack_test.py

@@ -439,6 +439,27 @@ def main():
         check(status == 200 and "quote-comment-dialog" in page,
               "terminal page keeps its quote dialog")
 
+        print("== B3: review section hides the duplicate body ==")
+        status, body = saddle_api("POST", "/api/saddle/%d/update" % fake_id, fake_token,
+                                  {"type": "block", "session_id": session_id, "data": {
+                                      "question": "Review the diff",
+                                      "type": "review",
+                                      "body": "# The change\n\nReworks the flange module."}})
+        check(status == 200 and body.get("block_id"), "review block raised")
+        detail = task_state(auth, plan_task)
+        review_block = [b for b in detail["blocks"] if b["block_type"] == "review"][0]
+        check(detail.get("review_pending") is True,
+              "review section shows while the review is unanswered")
+        check(review_block.get("show_body") is False,
+              "pending review block hides its duplicate body preview")
+        check(review_block.get("body", "").startswith("# The change"),
+              "review body itself still arrives in state (B2 counterpart)")
+        act(auth, review_block["answer_action"], {"answer": "Human approved the review"})
+        detail = task_state(auth, plan_task)
+        review_block = [b for b in detail["blocks"] if b["block_type"] == "review"][0]
+        check(review_block.get("show_body") is True,
+              "answered review shows the body again (banner gone)")
+
         print("== feature 5: rules ==")
         rules_state = slot_public(auth, "/rules", "rules")
         for name, body in [