Repository navigation
Factor out shared scenario setup in yemot handler tests - #142
Merged
Merged
Conversation
- 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.
There was a problem hiding this comment.
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 commonUser+Textseeding, plus optionalTeacher+ arbitrary extra seeds. - Add
transportSetup(),teacherSetup(),managerSetup()built onbaseSetup(); rewire existing tests to use them. - Remove single-use wrapper helpers (
rejectTz,rejectTransport,rejectKlass,rejectStudentNumber,askForKlass,seminarUser) and callask()/askThenReject()directly.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Refactors
server/src/yemot-handler.service.test.tsso scenario setup is defined once and reused, instead of eachdescribeblock (or individual test) hand-rolling its own seed calls.baseSetup()primitive — seedsUser+ optionalTeacher(s) +Text+ extra entities.transportSetup,teacherSetup, andmanagerSetupall build on it now.baseSetuptoo.rejectTz/rejectTransport/rejectKlass/rejectStudentNumberandaskForKlass— these were single-use passthrough wrappers aroundaskThenReject()/ask()with no logic of their own. Call sites now callaskThenReject()/ask()directly.seminarUser— folded intoteacherSetup, 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.
All 21 tests pass.
Generated by Claude Code