Skip to content

Rebuild seminar/transport test steps on two generic primitives - #140

Merged
buzz-code merged 1 commit into
mainfrom
claude/year-start-august-s6zrjt
Aug 18, 2026
Merged

buzz-code merged 1 commit into
mainfrom
claude/year-start-august-s6zrjt

Conversation

@buzz-code

Copy link
Copy Markdown
Owner

Summary

Full from-scratch redesign of the scenario-step helpers in yemot-handler.service.test.ts, requested as a follow-up to #138/#139.

Every step in the file (transport TZ/transport/departure, seminar klass/student prompts) is one of two shapes: a single ask+respond exchange, or that same exchange followed by an error systemSends. Collapsed the whole helper section onto:

  • 2 primitives — ask(builder, prompt, response) and askThenReject(builder, prompt, response, errorMessage) — the only two functions that call the YemotScenarioBuilder directly.
  • 6 named prompt-regex constants (TZ_PROMPT, TRANSPORT_PROMPT, DEPARTURE_PROMPT, KLASS_PROMPT, ABSENT_STUDENT_PROMPT, CONFIRM_STUDENT_PROMPT) replacing the regex literals that used to be duplicated inline across 2-3 functions each.
  • Every domain-named step (respondToTz, rejectTz, respondToTransport, rejectTransport, confirmDeparture, askForKlass, rejectKlass, rejectStudentNumber, finishAbsentStudentEntry) is now a 1-line call into a primitive + its prompt constant.
  • reportAbsentStudent/rejectAbsentStudentName (7 and 8 lines) merged into one confirmsStudentName(builder, studentNumber, accept) (4 lines) — same two-step "enter number, then confirm yes/no" shape, previously duplicated.
  • welcomesTeacher, entersKlass, startsSeminarCall unchanged — genuinely multi-step composites reused 2+ times, kept as named functions on top of the primitives.

Function tree:

ask / askThenReject                          (primitives)
├─ respondToTz / rejectTz
├─ respondToTransport / rejectTransport
├─ confirmDeparture
├─ askForKlass / rejectKlass
├─ confirmsStudentName
├─ rejectStudentNumber
└─ finishAbsentStudentEntry
welcomesTeacher
└─ entersKlass
   └─ startsSeminarCall

Net +7 lines (40 insertions / 33 deletions) — more small named functions, but every one is now a single line with no duplicated regex or builder-call sequence; every step traces to exactly one of the two primitives.

Testing

Full server suite: 100 suites / 941 tests passing.


🤖 Generated with Claude Code


Generated by Claude Code

Copilot AI lite review requested due to automatic review settings August 18, 2026 06:14
Replaces the ad-hoc per-flow helpers with a small tree:
- ask()/askThenReject() are the only two functions that touch the
  YemotScenarioBuilder directly
- every named step (respondToTz, askForKlass, confirmDeparture, etc.)
  is now a 1-line call into one of those two, parameterized by a
  named prompt-regex constant
- reportAbsentStudent/rejectAbsentStudentName merged into a single
  confirmsStudentName(builder, num, accept)

Net +7 lines (40 insertions / 33 deletions) — trades a few more small
named functions for eliminating all regex/builder-call duplication;
every step is now traceable to one of two primitives.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MX2QnzzPvash7UmemgUPL9
@buzz-code
buzz-code force-pushed the claude/year-start-august-s6zrjt branch from 19b9601 to a07edce Compare August 18, 2026 06:15
@buzz-code
buzz-code merged commit a0f1c20 into main Aug 18, 2026
1 check passed

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 Yemot scenario-step helpers in server/src/yemot-handler.service.test.ts into 2 generic primitives plus shared prompt-regex constants, shrinking duplicated builder-call sequences in transport + seminar-attendance tests.

Changes:

  • Add prompt-regex constants (TZ/transport/departure/klass/absent-student/confirm-student).
  • Add ask() + askThenReject() primitives, rewrite step helpers to delegate.
  • Merge absent-student “enter number + confirm name” helpers into confirmsStudentName().

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

const ABSENT_STUDENT_PROMPT = /enter absent student number/i;
const CONFIRM_STUDENT_PROMPT = /confirm student/i;

// ---- Generic scenario-step primitives — every step below is one of these ----
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