Skip to content

Add test coverage for pending-pr-scenarios.ts's null-login and case-insensitive matching branches #8329

Description

@JSONbored

Context

src/scoring/pending-pr-scenarios.ts defines two small helpers used to filter a contributor's open PRs:

function sameRepoFullName(left: string, right: string): boolean {
  return left.toLowerCase() === right.toLowerCase();
}

function sameLogin(value: string | null | undefined, login: string): boolean {
  return Boolean(value && value.toLowerCase() === login.toLowerCase());
}

sameLogin's value && short-circuit exists specifically to handle PullRequestRecord.authorLogin, which is typed string | null | undefined in src/types.ts — a real case for ghost/deleted GitHub accounts whose author login can't be resolved. sameRepoFullName's .toLowerCase() normalization exists to handle repo full names that may differ only in case (e.g. GitHub is case-insensitive for owner/repo but stored values aren't guaranteed to be consistently cased).

Every test in test/unit/pending-pr-scenarios.test.ts that exercises loadContributorRepoOpenPrSignalRecords (which calls both helpers) sets authorLogin to a concrete string that either matches or differs from the target login only in content, never null/undefined, and never varies the case of repoFullName or login between the PR record and the query args. So:

  • The value && null/undefined-login short-circuit in sameLogin has no test proving a PR from a ghost/deleted account (authorLogin: null or undefined) is correctly excluded rather than throwing or matching by accident.
  • The case-insensitive matching in both helpers has no test proving e.g. "Entrius/allways-ui" matches "entrius/allways-ui", or a login differing only in case still matches.

Requirements

  • Add a test case to test/unit/pending-pr-scenarios.test.ts where one PullRequestRecord passed to loadContributorRepoOpenPrSignalRecords has authorLogin: null and another has authorLogin: undefined (if the type/fixture allows), both for the target login being searched for — assert neither is included in the result (i.e. sameLogin's short-circuit excludes them rather than matching or throwing).
  • Add a test case with a repoFullName on the PullRequestRecord that differs from the query's repoFullName argument only in letter case (e.g. record has "Acme/Widgets", query passes "acme/widgets") — assert it still matches and is included.
  • Add a test case with an authorLogin on the record that differs from the query's login argument only in letter case — assert it still matches and is included.

Deliverables

  • New test cases in test/unit/pending-pr-scenarios.test.ts covering: null authorLogin, undefined authorLogin, case-differing repoFullName, and case-differing login, each asserting the correct include/exclude outcome.

Test Coverage Requirements

This repo's Codecov patch gate requires 99%+ coverage of changed lines and branches. This issue is pure test-addition — cover both operands of sameLogin's value && short-circuit (truthy and falsy value) and the case-normalization behavior of both helpers.

Expected Outcome

sameRepoFullName's case-insensitive matching and sameLogin's null/undefined-login handling (including the ghost/deleted-account case) are backed by explicit tests, closing a real branch-coverage gap on logic that determines which of a contributor's open PRs are counted toward their pending-PR scenario signals.

Links & Resources

  • src/scoring/pending-pr-scenarios.tssameRepoFullName/sameLogin, end of file; loadContributorRepoOpenPrSignalRecords, top of file
  • src/types.tsPullRequestRecord.authorLogin: string | null | undefined
  • test/unit/pending-pr-scenarios.test.ts — existing coverage

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions