Extract shared base classes for brief_facts and dispatch model tests #674

Closed
opened 2026-09-24 15:39:21 +00:00 by jared · 2 comments
Owner

Problem

Two duplicated groups within plugins/os-sdlc tests: (a) init_test_project and run! are duplicated between plugins/os-sdlc/tests/pipeline/brief_facts_diff_facts_never_truncated_test.rb (lines 70, 81) and brief_facts_enrichment_facts_test.rb (lines 168, 179), mass 312. (b) setup is duplicated across plugins/os-sdlc/tests/model/dispatch_record_usage_test.rb:10, dispatch_step_summaries_test.rb:9, dispatch_test.rb:9; new_dispatch is duplicated across plugins/os-sdlc/tests/model/objection_test.rb:57, plugins/os-sdlc/tests/pipeline/objection_intake_test.rb:71, plugins/os-sdlc/tests/pipeline/objections_digest_test.rb:54; mass 288. No shared base classes exist.

Approach

Create two support base classes: (1) BriefFactsTestCase for brief_facts tests holding init_test_project and run! methods. (2) DispatchTestCase for dispatch and objection tests holding setup and new_dispatch methods. Callers subclass and delete their local copies.

Required work:

  1. Create BriefFactsTestCase base class under plugins/os-sdlc/tests/support/ — check: flay -m16 plugins/os-sdlc/tests/pipeline/brief_facts* | grep -E "init_test_project|run!"
  2. Create DispatchTestCase base class under plugins/os-sdlc/tests/support/ — check: flay -m16 plugins/os-sdlc/tests/model/dispatch* plugins/os-sdlc/tests/model/objection_test.rb plugins/os-sdlc/tests/pipeline/objection* | grep -E "setup|new_dispatch"

Acceptance criteria

  1. Given brief_facts tests with duplicated init_test_project and run! methods, when subclasses of BriefFactsTestCase replace them, then each test inherits those methods and local copies are deleted.
  2. Given dispatch and objection tests with duplicated setup and new_dispatch methods, when subclasses of DispatchTestCase replace them, then each test inherits those methods and local copies are deleted.
  3. Given a test suite run with ruby -I plugins/os-sdlc/lib:plugins/os-sdlc/tests plugins/os-sdlc/tests/**/*_test.rb, then all tests pass.
  4. Given a rubocop scan, then all offenses pass.
  5. Given flay -m16 over plugins/os-sdlc/tests/, then identical-mass for init_test_project, run!, setup, and new_dispatch drops by about 288.

Reproduce

n/a: refactor ticket, measured by flay

Origin

Session: e9385b96-96c4-4de0-9bc3-33573da7c95c
Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/e9385b96-96c4-4de0-9bc3-33573da7c95c.jsonl
Where: plugins/os-sdlc/tests/pipeline/ and plugins/os-sdlc/tests/model/

## Problem Two duplicated groups within plugins/os-sdlc tests: (a) init_test_project and run! are duplicated between plugins/os-sdlc/tests/pipeline/brief_facts_diff_facts_never_truncated_test.rb (lines 70, 81) and brief_facts_enrichment_facts_test.rb (lines 168, 179), mass 312. (b) setup is duplicated across plugins/os-sdlc/tests/model/dispatch_record_usage_test.rb:10, dispatch_step_summaries_test.rb:9, dispatch_test.rb:9; new_dispatch is duplicated across plugins/os-sdlc/tests/model/objection_test.rb:57, plugins/os-sdlc/tests/pipeline/objection_intake_test.rb:71, plugins/os-sdlc/tests/pipeline/objections_digest_test.rb:54; mass 288. No shared base classes exist. ## Approach Create two support base classes: (1) BriefFactsTestCase for brief_facts tests holding init_test_project and run! methods. (2) DispatchTestCase for dispatch and objection tests holding setup and new_dispatch methods. Callers subclass and delete their local copies. Required work: 1. Create BriefFactsTestCase base class under plugins/os-sdlc/tests/support/ — check: `flay -m16 plugins/os-sdlc/tests/pipeline/brief_facts* | grep -E "init_test_project|run!"` 2. Create DispatchTestCase base class under plugins/os-sdlc/tests/support/ — check: `flay -m16 plugins/os-sdlc/tests/model/dispatch* plugins/os-sdlc/tests/model/objection_test.rb plugins/os-sdlc/tests/pipeline/objection* | grep -E "setup|new_dispatch"` ## Acceptance criteria 1. Given brief_facts tests with duplicated init_test_project and run! methods, when subclasses of BriefFactsTestCase replace them, then each test inherits those methods and local copies are deleted. 2. Given dispatch and objection tests with duplicated setup and new_dispatch methods, when subclasses of DispatchTestCase replace them, then each test inherits those methods and local copies are deleted. 3. Given a test suite run with `ruby -I plugins/os-sdlc/lib:plugins/os-sdlc/tests plugins/os-sdlc/tests/**/*_test.rb`, then all tests pass. 4. Given a rubocop scan, then all offenses pass. 5. Given flay -m16 over plugins/os-sdlc/tests/, then identical-mass for init_test_project, run!, setup, and new_dispatch drops by about 288. ## Reproduce n/a: refactor ticket, measured by flay ## Origin Session: e9385b96-96c4-4de0-9bc3-33573da7c95c Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/e9385b96-96c4-4de0-9bc3-33573da7c95c.jsonl Where: plugins/os-sdlc/tests/pipeline/ and plugins/os-sdlc/tests/model/
Author
Owner

Work started on branch ticket-674 (worktree).

Work started on branch ticket-674 (worktree).
Author
Owner

Resolution

Done: DispatchTestCase holds the shared Db.connect setup for the three dispatch model tests; ObjectionTestCase holds new_dispatch for objection_test and objections_digest_test. The brief_facts half was dropped at merge: #657 deleted both brief_facts test files on main before this branch landed, so BriefFactsTestCase had no callers and was removed.

Evidence: merged main 321f0d02 (branch 48192eb5); os-sdlc suite 1383 runs 0 failures.

Follow-ups: none

## Resolution **Done:** DispatchTestCase holds the shared Db.connect setup for the three dispatch model tests; ObjectionTestCase holds new_dispatch for objection_test and objections_digest_test. The brief_facts half was dropped at merge: #657 deleted both brief_facts test files on main before this branch landed, so BriefFactsTestCase had no callers and was removed. **Evidence:** merged main 321f0d02 (branch 48192eb5); os-sdlc suite 1383 runs 0 failures. **Follow-ups:** none
jared closed this issue 2026-09-24 15:50:06 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#674
No description provided.