|
8 | 8 | renderReviewCommentFromReport, |
9 | 9 | reviewAutomationMarkersFromReport, |
10 | 10 | } from "../dist/clawsweeper.js"; |
| 11 | +import { restoreVerifiedMaintainerPullRequestAuthorAssociation } from "../dist/clawsweeper-review-command-workflow.js"; |
11 | 12 | import { |
12 | 13 | changelogReviewDecision, |
13 | 14 | item, |
@@ -304,6 +305,94 @@ Full review comments: |
304 | 305 | assert.doesNotMatch(markers, /clawsweeper-verdict:needs-human/, scenario.author); |
305 | 306 | } |
306 | 307 |
|
| 308 | + for (const permission of ["admin", "maintain"]) { |
| 309 | + const canary = item({ |
| 310 | + kind: "pull_request", |
| 311 | + number: 113345, |
| 312 | + author: "steipete", |
| 313 | + authorAssociation: "CONTRIBUTOR", |
| 314 | + labels: ["maintainer", "size: XS", "status: 📣 needs proof"], |
| 315 | + }); |
| 316 | + const redactedReport = reportFor({ |
| 317 | + author: canary.author, |
| 318 | + association: canary.authorAssociation, |
| 319 | + status: "mock_only", |
| 320 | + }); |
| 321 | + assert.match( |
| 322 | + renderReviewCommentFromReport(redactedReport, "none"), |
| 323 | + /blocked until real behavior proof from a real setup is added/i, |
| 324 | + ); |
| 325 | + let lookups = 0; |
| 326 | + assert.equal( |
| 327 | + restoreVerifiedMaintainerPullRequestAuthorAssociation(canary, (author) => { |
| 328 | + lookups += 1; |
| 329 | + assert.equal(author, "steipete"); |
| 330 | + return permission; |
| 331 | + }), |
| 332 | + true, |
| 333 | + ); |
| 334 | + assert.equal(lookups, 1); |
| 335 | + assert.equal(canary.authorAssociation, "MEMBER"); |
| 336 | + |
| 337 | + const correctedReport = reportFor({ |
| 338 | + author: canary.author, |
| 339 | + association: canary.authorAssociation, |
| 340 | + status: "mock_only", |
| 341 | + }); |
| 342 | + assert.match( |
| 343 | + renderReviewCommentFromReport(correctedReport, "none"), |
| 344 | + /✅ \*\*Ready for maintainer review\*\*/, |
| 345 | + ); |
| 346 | + assert.match(reviewAutomationMarkersFromReport(correctedReport), /clawsweeper-verdict:pass/); |
| 347 | + } |
| 348 | + |
| 349 | + for (const permission of ["write", "read", null]) { |
| 350 | + const unverified = item({ |
| 351 | + kind: "pull_request", |
| 352 | + author: "external", |
| 353 | + authorAssociation: "CONTRIBUTOR", |
| 354 | + labels: ["maintainer"], |
| 355 | + }); |
| 356 | + assert.equal( |
| 357 | + restoreVerifiedMaintainerPullRequestAuthorAssociation(unverified, () => permission), |
| 358 | + false, |
| 359 | + String(permission), |
| 360 | + ); |
| 361 | + assert.equal(unverified.authorAssociation, "CONTRIBUTOR"); |
| 362 | + } |
| 363 | + |
| 364 | + const unavailable = item({ |
| 365 | + kind: "pull_request", |
| 366 | + authorAssociation: "CONTRIBUTOR", |
| 367 | + labels: ["maintainer"], |
| 368 | + }); |
| 369 | + assert.equal( |
| 370 | + restoreVerifiedMaintainerPullRequestAuthorAssociation(unavailable, () => { |
| 371 | + throw new Error("GitHub permission lookup failed"); |
| 372 | + }), |
| 373 | + false, |
| 374 | + ); |
| 375 | + assert.equal(unavailable.authorAssociation, "CONTRIBUTOR"); |
| 376 | + |
| 377 | + for (const ineligible of [ |
| 378 | + item({ kind: "issue", authorAssociation: "CONTRIBUTOR", labels: ["maintainer"] }), |
| 379 | + item({ kind: "pull_request", authorAssociation: "CONTRIBUTOR", labels: [] }), |
| 380 | + item({ kind: "pull_request", authorAssociation: "OWNER", labels: ["maintainer"] }), |
| 381 | + item({ kind: "pull_request", authorAssociation: "MEMBER", labels: ["maintainer"] }), |
| 382 | + item({ kind: "pull_request", authorAssociation: "COLLABORATOR", labels: ["maintainer"] }), |
| 383 | + item({ kind: "pull_request", author: "", labels: ["maintainer"] }), |
| 384 | + ]) { |
| 385 | + let lookups = 0; |
| 386 | + assert.equal( |
| 387 | + restoreVerifiedMaintainerPullRequestAuthorAssociation(ineligible, () => { |
| 388 | + lookups += 1; |
| 389 | + return "admin"; |
| 390 | + }), |
| 391 | + false, |
| 392 | + ); |
| 393 | + assert.equal(lookups, 0); |
| 394 | + } |
| 395 | + |
307 | 396 | const suppliedComment = renderReviewCommentFromReport( |
308 | 397 | reportFor({ author: "maintainer", association: "MEMBER", status: "sufficient" }), |
309 | 398 | "none", |
|
0 commit comments