Skip to content

Add comprehensive test coverage for new keepalive and agent loop scripts #92

Description

@github-actions

Topic GUID: 64f8e823-8464-57a9-be8d-114e41d5bd34

Why

Context / problem:

  • The recently added agent scripts have no unit test coverage:
    • keepalive_loop.js (435 lines) - core loop evaluation logic
    • keepalive_state.js (209 lines) - state persistence and comment formatting
    • agents_verifier_context.js (207 lines) - post-merge verification context builder
  • These scripts contain critical logic for checkbox parsing, iteration counting, stop condition evaluation, and PR state management.
  • Without tests, regressions can silently break the keepalive and autofix functionality.
  • The existing test patterns in tests/ provide a template but these new scripts are not covered.
    Goal:
  • Add comprehensive Jest test suites for all new agent scripts.
  • Achieve >80% code coverage for the critical path functions.
  • Include edge case testing for malformed inputs, API failures, and boundary conditions.

Tasks

  • Create .github/scripts/tests/keepalive-loop.test.js:
  • Test countCheckboxes() with various markdown formats
  • Test evaluateKeepaliveLoop() with mocked GitHub API responses
  • Test stop condition logic (tasks-complete, max-iterations, repeated-failure)
  • Test PR body parsing and config extraction
  • Test concurrency group name generation
  • Create .github/scripts/tests/keepalive-state.test.js:
  • Test loadKeepaliveState() with various comment formats
  • Test formatStateComment() output structure
  • Test state persistence round-trip (save → load → verify)
  • Test edge cases: missing comments, malformed JSON, empty PRs
  • Create .github/scripts/tests/agents-verifier-context.test.js:
  • Test buildVerifierContext() with mocked PR and issue data
  • Test extractScopeTasksAcceptanceSections() integration
  • Test linked issue resolution via GraphQL mock
  • Test skip conditions (non-merged PR, missing SHA, fork detection)
  • Update package.json test configuration if needed for coverage thresholds
  • Add test fixtures for realistic PR bodies and issue content

Acceptance criteria

  • All three test files exist and pass in CI.
    • Combined coverage for keepalive_loop.js, keepalive_state.js, and agents_verifier_context.js exceeds 80%.
    • Tests catch at least one real bug or edge case during development.
    • Test output is integrated into the existing Jest test run (npm test).

Implementation notes

Not provided.


Synced by workflow run.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions