Skip to content

Factor out shared scenario setup in yemot handler tests - #142

Merged
buzz-code merged 1 commit into
mainfrom
claude/yemot-test-refactor-3vyt1n
Aug 19, 2026
Merged

buzz-code merged 1 commit into
mainfrom
claude/yemot-test-refactor-3vyt1n

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

What

Refactors server/src/yemot-handler.service.test.ts so scenario setup is defined once and reused, instead of each describe block (or individual test) hand-rolling its own seed calls.

  • Added one baseSetup() primitive — seeds User + optional Teacher(s) + Text + extra entities. transportSetup, teacherSetup, and managerSetup all build on it now.
    • The manager-report tests and the top-level transport tests previously bypassed any shared builder entirely — some seed blocks were byte-identical across 4 different tests. Now routed through baseSetup too.
  • Dropped rejectTz/rejectTransport/rejectKlass/rejectStudentNumber and askForKlass — these were single-use passthrough wrappers around askThenReject()/ask() with no logic of their own. Call sites now call askThenReject()/ask() directly.
  • Dropped seminarUser — folded into teacherSetup, its only remaining caller.

Why

History showed that adding one new step to the seminar call (the teacher welcome greeting) required touching 8 separate test cases, because tests built their step sequences and seed data ad hoc instead of through a shared, composable setup. This factors the setup into one reusable layer so a future flow-wide change (a new step, a new required seed entity) lands in one place.

Testing

No test case bodies or assertions changed — same 21 tests, same expectations, just re-wired setup.

cd server && yarn test yemot-handler.service.test.ts

All 21 tests pass.


Generated by Claude Code

- One baseSetup() primitive (User + optional Teacher(s) + Text + extra
  seeds) that transportSetup, teacherSetup, and managerSetup all build
  on, instead of each describe block hand-rolling its own seed calls.
  Manager-report tests and the top-level transport tests previously
  bypassed any shared builder entirely (some seed blocks were
  byte-identical across 4 tests) - now routed through baseSetup too.
- Dropped rejectTz/rejectTransport/rejectKlass/rejectStudentNumber and
  askForKlass - single-use passthrough wrappers around askThenReject()/
  ask() with no logic of their own; call askThenReject()/ask() directly
  at their one call site instead.
- Dropped seminarUser - folded into teacherSetup, its only caller.

No test case bodies or assertions changed. All 21 tests still pass.
Copilot AI lite review requested due to automatic review settings August 19, 2026 18:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactor server/src/yemot-handler.service.test.ts test scaffolding so seed/setup logic shared across Yemot handler flows (transport, seminar/teacher, manager) lives in reusable helpers, reducing duplicate per-test seeding.

Changes:

  • Add baseSetup() primitive for common User + Text seeding, plus optional Teacher + arbitrary extra seeds.
  • Add transportSetup(), teacherSetup(), managerSetup() built on baseSetup(); rewire existing tests to use them.
  • Remove single-use wrapper helpers (rejectTz, rejectTransport, rejectKlass, rejectStudentNumber, askForKlass, seminarUser) and call ask() / askThenReject() directly.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@buzz-code
buzz-code merged commit 012af4e into main Aug 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants