From 5216369e7ed71eb4ce8e24f16b20161ebe4d4ea3 Mon Sep 17 00:00:00 2001 From: codex-bot-andresmgsl <304681515+codex-bot-andresmgsl@users.noreply.github.com> Date: Thu, 23 Jul 2026 13:19:11 +0000 Subject: [PATCH] test: cover offsite nudge integration --- test/issueflow-reconcile.test.sh | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/test/issueflow-reconcile.test.sh b/test/issueflow-reconcile.test.sh index a45cfe5..52e65a5 100644 --- a/test/issueflow-reconcile.test.sh +++ b/test/issueflow-reconcile.test.sh @@ -208,6 +208,8 @@ issue_stub_gh() { shift done file="$TMP/$(printf '%s' "$endpoint" | tr '/' '_').json" + printf '%s\n' "$endpoint" >>"$TMP/api-calls" + [ ! -f "$file.error" ] || return 1 [ -f "$file" ] || { printf '[]\n'; return 0; } if [ -n "$jqexpr" ]; then jq -r "$jqexpr" "$file"; else cat "$file"; fi elif [ "$1" = issue ] && [ "$2" = comment ]; then @@ -289,6 +291,59 @@ check "an offsite claim with an open PR stays claimed" 1 "" \ offsite_both="$(issue_probe 28 $'claimed\noffsite\nneeds-ruling')" check "offsite plus needs-ruling stays claimed" 1 "" \ grep -q 'reclaimed' <<<"$offsite_both" + +# -- resolved offsite work nudges once and only from complete evidence ------- +jq -n --arg at "$(iso_at $((INOW - 3600)))" \ + '[{"event":"assigned","created_at":$at}, + {"event":"cross-referenced","source":{"issue":{"number":112,"repository":{"full_name":"heavy-duty/rig"},"pull_request":{"url":"x"}}}}]' \ + >"$(tfix 29)" +printf '{"state":"closed"}\n' >"$TMP/repos_heavy-duty_rig_pulls_112.json" +printf '[]\n' >"$(cfix 29)" +resolved="$(issue_probe 29 $'claimed\noffsite')" +check "a closed cross-referenced PR nudges and names the PR" 0 "" \ + grep -q 'heavy-duty/rig#112 is closed' "$TMP/posted-29" +check "the resolved nudge leaves the claim untouched" 1 "" \ + grep -q 'reclaimed' <<<"$resolved" +issue_probe 29 $'claimed\noffsite' >/dev/null +check "the resolved nudge is idempotent across sweeps" 0 "1" \ + grep -cF '' "$TMP/posted-29" + +jq -n --arg at "$(iso_at $((INOW - 3600)))" \ + '[{"event":"assigned","created_at":$at}, + {"event":"cross-referenced","source":{"issue":{"number":112,"repository":{"full_name":"heavy-duty/rig"},"pull_request":{"url":"x"}}}}, + {"event":"cross-referenced","source":{"issue":{"number":9,"repository":{"full_name":"heavy-duty/box"},"pull_request":{"url":"x"}}}}]' \ + >"$(tfix 30)" +printf '{"state":"open"}\n' >"$TMP/repos_heavy-duty_box_pulls_9.json" +printf '[]\n' >"$(cfix 30)" +issue_probe 30 $'claimed\noffsite' >/dev/null +check "one open cross-referenced PR suppresses the nudge" 1 "" \ + test -f "$TMP/posted-30" + +printf '[]\n' >"$(tfix 31)" +printf '[]\n' >"$(cfix 31)" +issue_probe 31 $'claimed\noffsite' >/dev/null +check "no visible cross-referenced PR stays silent" 1 "" test -f "$TMP/posted-31" + +: >"$(tfix 32).error" +printf '[]\n' >"$(cfix 32)" +unreadable="$(issue_probe 32 $'claimed\noffsite')" +check "an unreadable timeline stays silent" 1 "" test -f "$TMP/posted-32" +check "...and leaves the sweep running without an alarming log" 1 "" \ + grep -qiE 'error|failed' <<<"$unreadable" + +: >"$TMP/api-calls" +printf '[]\n' >"$(tfix 33)" +printf '[]\n' >"$(cfix 33)" +issue_probe 33 claimed >/dev/null +check "a non-offsite claim performs only the ordinary timeline read" 0 "1" \ + grep -cF 'repos/owner/repo/issues/33/timeline' "$TMP/api-calls" +: >"$TMP/api-calls" +printf '[]\n' >"$(tfix 34)" +printf '[]\n' >"$(cfix 34)" +issue_probe 34 $'claimed\noffsite' >/dev/null +check "an offsite claim performs the one guarded verification read" 0 "2" \ + grep -cF 'repos/owner/repo/issues/34/timeline' "$TMP/api-calls" + check "a one-hour claim stays claimed for the ordinary age reason" 0 "KEEP" \ claim_decision 1 false 3600 check "no reconciler mutation names offsite (#68 D4)" 1 "" \