43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import { DoorstepStallSkill } from '@/lib/assistant/skills/definitions/DoorstepStallSkill';
|
|
|
|
describe('DoorstepStallSkill', () => {
|
|
const fixedNow = '2026-08-31 12:00:00';
|
|
|
|
it('detects riders stalled at door past threshold', () => {
|
|
const rows = [
|
|
{
|
|
bookingid: 1,
|
|
bookingno: 'BK-1',
|
|
orderstatus: 'arrived',
|
|
reachedat: '2026-08-31 11:35:00', // 25 min waiting
|
|
ridername: 'Karthik Raja',
|
|
userid: 44,
|
|
},
|
|
{
|
|
bookingid: 2,
|
|
bookingno: 'BK-2',
|
|
orderstatus: 'arrived',
|
|
reachedat: '2026-08-31 11:55:00', // 5 min waiting
|
|
ridername: 'Praveen',
|
|
userid: 45,
|
|
},
|
|
];
|
|
|
|
const findings = DoorstepStallSkill.evaluate(rows, fixedNow, { arrivedStalledMin: 20 });
|
|
expect(findings.length).toBe(1);
|
|
expect(findings[0].id).toBe('stalled_at_door');
|
|
expect(findings[0].count).toBe(1);
|
|
expect(findings[0].rows[0].bookingid).toBe(1);
|
|
});
|
|
|
|
it('executes ping_stalled_rider tool handler', async () => {
|
|
const tool = DoorstepStallSkill.tools.find((t) => t.name === 'ping_stalled_rider');
|
|
expect(tool).toBeDefined();
|
|
|
|
const result = await tool.handler({ milerId: 44 });
|
|
expect(result.success).toBe(true);
|
|
expect(result.proposal.action).toBe('notify_miler');
|
|
expect(result.proposal.milerId).toBe(44);
|
|
});
|
|
});
|