Skip to content

test(bundle): drive the approve plugin's evaluation arms through dist/index.js - #333

Merged
mrbobbytables merged 5 commits into
mainfrom
quality/test-approve-evaluation-arms
Oct 9, 2026
Merged

mrbobbytables merged 5 commits into
mainfrom
quality/test-approve-evaluation-arms

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds __tests__/bundle/approveEvaluationArms.test.ts (new file only; bundle.test.ts and helpers.ts, which #246 edits, are untouched), driving the arms of src/plugins/approve.ts that the bundle suite never reached through dist/index.js against fakeGithub.ts:

  • approveOnPullRequest skipping an unsupported action (closed); approveOnReview skipping the mirrored approval review itself (reviewMarker in the payload); a pull_request_review payload without a pull request failing the run
  • evaluateApproval leaving the pull request alone when the branch tip read for the evaluation has no OWNERS files although the probe did
  • the notifier for a pull request changing no files; for files no OWNERS file covers (listed after the OWNERS entries, sorted, nobody to suggest); and the up-to-date notifier that is neither re-posted nor edited
  • the updateComment, listComments and listReviews failures (label synced first for the edit; nothing written for the reads)
  • approve.lgtm_acts_as_approve (/lgtm adds, /remove-lgtm withdraws) and the default where /lgtm is ignored; approve.require_self_approval (the author's /approve ignored and the author excluded from the suggestion; the issue_comment refusal in src/issueComment/approve.ts)

15 tests, ~5 s against the committed dist/index.js.

Evidence (main @ 3fc21f2)

suite plugins/approve.ts lines branches
unit (npx vitest run --coverage) 193/193 —
e2e before (npm run test:coverage:e2e) 164/193 (84.97 %) 126/168
e2e with this PR 191/193 (98.96 %) 156/168

The two lines left are effectiveKind's exhaustive-switch default (236) and the if (!hasOwners) statement (505) whose body is already reached. src/ e2e lines overall: 77.9 % → 79.16 %.

Local runs; test.yml has had no push run on main since a270568 (#329), so there is no CI artifact to cite.

Related Issue

Closes #332


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-fable-5.1

…/index.js

__tests__/bundle only reaches src/plugins/approve.ts' happy paths: on
main @ 3fc21f2 the e2e run (npm run test:coverage:e2e) covers 164/193 of
its lines while the unit suite covers all of them. Add
approveEvaluationArms.test.ts to run the remaining arms against the
fake api through the shipped bundle:

- approveOnPullRequest skipping an unsupported action, approveOnReview
  skipping the mirrored approval review itself, and a payload without a
  pull request failing the run
- evaluateApproval leaving a pull request alone when the branch tip has
  no OWNERS files although the probe did
- the notifier for a pull request changing no files, for files no OWNERS
  file covers (listed last, sorted, nobody to suggest), and the
  up-to-date notifier that is neither re-posted nor edited
- the updateComment, listComments and listReviews failures
- approve.lgtm_acts_as_approve (/lgtm adds, /remove-lgtm withdraws) and
  approve.require_self_approval (the author's /approve ignored and the
  author excluded from the suggestion; the issue_comment refusal)

plugins/approve.ts e2e lines go to 191/193; the two left are the
exhaustive-switch default of effectiveKind and the `if (!hasOwners)`
statement whose body is reached.

Closes #332

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive
hivecommons-hive Bot requested a review from jpmcb as a code owner October 5, 2026 19:57
@hivecommons-hive hivecommons-hive Bot added the hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 5, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

build-test on this PR (run 37366768906) is the shared baseline failure tracked in #294, not this diff: all 81 files / 1654 tests pass and the job exits 1 on the single vitest unhandled ERR_TLS_CERT_ALTNAME_INVALID assertion originating in __tests__/issueCommentTest/meow.test.ts, which this PR does not touch. Deferring until #287 lands and #294 closes; no retrigger or push for this failure.


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: d25517c

— hive: agent=quality backend=copilot model=claude-fable-5.1

@jeefy jeefy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 of the 15 cases add coverage.

  • approveEvaluationArms.test.ts:41–43 declares its own calls(). Use const { calls, routeOwners } = helpersFor(() => gh) instead.
  • :300: expect(result.errors).toContain(wantErr) compares the whole ::error:: line. Use result.errors.some(e => e.includes('you cannot approve your own PR')).
  • Drop the "/lgtm approves" row at :253. The :254 row reaches every line and branch it does (approve.ts:111–112, 231–232).

quality added 2 commits October 7, 2026 21:50
…and drop the duplicated lgtm_acts_as_approve row

Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Addressed all three: calls comes from helpersFor(() => gh), the self-approval refusal checks the you cannot approve your own PR fragment, and the /lgtm approves row is dropped (only the /remove-lgtm withdrawal remains). Merged main.


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: unknown

— hive: agent=quality backend=copilot model=claude-fable-5.1

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Addressed in 2ba9d37: calls comes from helpersFor, the self-approval error is checked by fragment, and the /lgtm approves row is dropped (only the /remove-lgtm withdraw case remains).

CI is green on the new head.


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 1f7d33c

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

@jeefy jeefy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three asks are done. On current main one case adds nothing:

  • Drop approveEvaluationArms.test.ts:134 ("a pull request changing no files is not approved and says so…"). #363 merged just after the first review, and approveReviewShortCircuits.test.ts:105 now reaches the same notifier path (approve.ts:289–291) and every branch it takes.

…its already reaches

Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Addressed in 12fd915: dropped the "changing no files" notifier case; approveReviewShortCircuits.test.ts:105 (#363) reaches approve.ts:289–291 on main. 13 cases remain.


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 12fd915

— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88

@mrbobbytables

Copy link
Copy Markdown
Member

/kind cleanup

@github-actions github-actions Bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed needs-kind labels Oct 9, 2026
@mrbobbytables
mrbobbytables merged commit bbe18b7 into main Oct 9, 2026
5 checks passed
@mrbobbytables
mrbobbytables deleted the quality/test-approve-evaluation-arms branch October 9, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Indicates that a PR should not merge because someone has issued a /hold command. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] plugins/approve.ts' evaluation arms are unit-covered but never driven end-to-end through dist/index.js (84.97 % e2e lines)

2 participants