From 1b217489b21fe5c9c889315892f2dff9a9fdb5d2 Mon Sep 17 00:00:00 2001 From: Hadasa Schechter <72219643+buzz-code@users.noreply.github.com> Date: Tue, 23 Jun 2026 07:24:32 +0000 Subject: [PATCH] Implement skipped Yemot handler tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement the three it.skip stub tests in yemot-handler.service.test.ts: 1. 'no class found' — seeds Student and Transportation without StudentKlass, verifies hangup with STUDENT.NO_CLASS message. 2. 'past deadline at 8:50' — sets time to exactly 8:50, verifies the boundary condition triggers hangup with SYSTEM.CLOSED. 3. 'before deadline at 8:49' — sets time to 8:49, verifies the deadline check passes and the call continues to student input and completes the happy path. --- server/src/yemot-handler.service.test.ts | 60 ++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/server/src/yemot-handler.service.test.ts b/server/src/yemot-handler.service.test.ts index 6b9db2d4..14807a18 100644 --- a/server/src/yemot-handler.service.test.ts +++ b/server/src/yemot-handler.service.test.ts @@ -178,11 +178,63 @@ describe('YemotHandlerService — react-admin-nestjs', () => { expect(result.hungup).toBe(true); }); - // ---- Stub tests for uncovered branches ---- + // ---- Previously skipped tests for uncovered branches ---- - it.skip('no class found — hangup with STUDENT.NO_CLASS', () => { }); + it('no class found — hangup with STUDENT.NO_CLASS', async () => { + jest.setSystemTime(israelTimeAt(7, 0)); + + const scenario = new YemotScenarioBuilder('No class found') + .seed('User', [baseUser]) + .seed('Student', [{ id: 100, userId: 1, tz: '123456789', name: 'Test Student' }]) + .seed('Transportation', [{ id: 10, userId: 1, key: 5, departureTime: '07:30' }]) + .seed('Text', baseTexts) + .systemAsks(/enter.*id/i) + .userResponds('123456789') + .systemAsks(/transport/i) + .userResponds('5') + .systemAsks(/departure.*07:30/i) + .userResponds('1') + .systemHangsUp(/no class/i) + .build(); + + const result = await runner.run(scenario); + expect(result.passed).toBe(true); + expect(result.hungup).toBe(true); + }); + + it('past deadline — exactly at 8:50, hangup with CLOSED', async () => { + jest.setSystemTime(israelTimeAt(8, 50)); + + const scenario = new YemotScenarioBuilder('Past deadline at 8:50') + .seed('User', [baseUser]) + .seed('Text', baseTexts) + .systemHangsUp(/closed/i) + .build(); + + const result = await runner.run(scenario); + expect(result.passed).toBe(true); + expect(result.hungup).toBe(true); + }); - it.skip('past deadline — exactly at 8:50, hangup with CLOSED', () => { }); + it('before deadline — at 8:49, continues to student input', async () => { + jest.setSystemTime(israelTimeAt(8, 49)); - it.skip('before deadline — at 8:49, continues to student input', () => { }); + const scenario = new YemotScenarioBuilder('Before deadline at 8:49') + .seed('User', [baseUser]) + .seed('Student', [{ id: 100, userId: 1, tz: '123456789', name: 'Test Student' }]) + .seed('Transportation', [{ id: 10, userId: 1, key: 5, departureTime: '07:30' }]) + .seed('StudentKlass', [{ id: 50, userId: 1, studentReferenceId: 100, klassReferenceId: 200 }]) + .seed('Text', baseTexts) + .systemAsks(/enter.*id/i) + .userResponds('123456789') + .systemAsks(/transport/i) + .userResponds('5') + .systemAsks(/departure.*07:30/i) + .userResponds('1') + .systemHangsUp(/success/i) + .build(); + + const result = await runner.run(scenario); + expect(result.passed).toBe(true); + }); });