Skip to content

[quality] plugins/approve.ts: base-ref fallback, null-body bot comment and /lgtm cancel branches are untested #220

Description

@hivecommons-hive

Finding

npx vitest run --coverage (v8) on main @ c48bd6d reports src/plugins/approve.ts at 100% lines but 97.51% branches, with these reachable branches uncovered:

  • evaluateOnOwnersRepo (L480): the repoHasOwners(...) fallback taken when context.payload.pull_request has no base.ref. Every existing test uses the pullReqOpenedEvent fixture, whose base ref is master, so only branchHasOwners is exercised.
  • upsertNotifier (L394): (comment.body ?? '') when a bot comment has body: null — the notifier lookup must skip it rather than throw or match it.
  • effectiveKind (L225): lgtm-cancel with lgtm_acts_as_approve unset returns 'ignore'; existing tests only cover /lgtm under lgtm_acts_as_approve: true.

Remaining branches at L225 default: (exhaustive union) and L400 (existing.body ?? '' after .includes() proved it non-null) are unreachable and are not part of this finding.

End-to-end evidence: the repository defines no integration/e2e suite — .github/workflows/test.yml runs npm run test:coverage (vitest unit tests) only — so there is no second coverage source to combine.

Recommendation

Add three cases to __tests__/plugins/approveEvents.test.ts under describe('approveOnPullRequest') using the existing serve()/prEvent() harness:

  • a pull_request payload without base → defaultBranchTree (master) is probed, pulls/1 is not fetched, debug logs approve: the base branch has no OWNERS files
  • a bot comment with body: null ahead of /approve → a new notifier is posted, nothing is patched
  • /approve by bob and carol followed by /lgtm cancel by bob with default settings → approved is still added and both remain listed as approvers

Priority

  • Impact: low — approve is the merge gate's approval source, but these are edge branches with existing 100% line coverage
  • Effort: low

Filed by quality agent (hold-gated mode)

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/qualityCreated by Hive for agent-filed issue provenancehive/hosted-available-lke648397-260827-5q9tCreated by Hive for agent-filed issue provenancehive/likely-doneHive verified that a merged PR references or claims this issue; pending confirmationneeds-kindqualityCreated by Hive for agent-filed issue provenancetestingCreated by Hive for agent-filed issue provenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions