Skip to content

Test coverage: ExtractVotesJob and Topics::AutoTriageJob #56

@AndreRobitaille

Description

@AndreRobitaille

Summary

Two core pipeline jobs remain untested: ExtractVotesJob (vote extraction from minutes) and Topics::AutoTriageJob (the job wrapper around TriageTool).

What's already covered

  • ExtractTopicsJob — 8 tests in test/jobs/extract_topics_job_test.rb (skip non-topic-worthy, skip Routine, create topics, document text inclusion, packet context, catch-all refinement)
  • Topics::TriageTool — 3 tests in test/services/topics/triage_tool_test.rb (automated events, tiered thresholds, community context)
  • Topics::TriageTool descriptions — 1 test in test/services/topics/triage_tool_description_test.rb (enqueues GenerateDescriptionJob on approval)

Jobs still needing tests

ExtractVotesJob (app/jobs/extract_votes_job.rb)

  • Extracts motions and voting records from minutes documents
  • Creates Motion and Vote records
  • Links votes to Member records via Member.resolve

Test scenarios:

  • Stub AI response with vote data → creates Motion + Vote records
  • Correctly maps member names to existing Member records via Member.resolve
  • Handles unanimous votes, split votes, abstentions, absences
  • Idempotent re-run clears and rebuilds
  • Updates Topic.last_activity_at via Motion callback
  • Handles AI service errors gracefully

Topics::AutoTriageJob (app/jobs/topics/auto_triage_job.rb)

  • Job wrapper that runs Topics::TriageTool on proposed topics

Test scenarios:

  • Enqueues and runs without error when proposed topics exist
  • Handles empty proposed topic queue
  • Handles AI service errors gracefully

Approach

  • Stub Ai::OpenAiService responses with realistic JSON fixtures
  • Follow patterns from existing extract_topics_job_test.rb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions