38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import { HighValueCodSkill } from '@/lib/assistant/skills/definitions/HighValueCodSkill';
|
|
|
|
describe('HighValueCodSkill', () => {
|
|
it('detects high value COD consignments at or above threshold', () => {
|
|
const rows = [
|
|
{
|
|
bookingid: 1,
|
|
bookingno: 'BK-COD-1',
|
|
orderstatus: 'active',
|
|
paymenttype: 'COD',
|
|
orderamount: 4500,
|
|
},
|
|
{
|
|
bookingid: 2,
|
|
bookingno: 'BK-COD-2',
|
|
orderstatus: 'active',
|
|
paymenttype: 'COD',
|
|
orderamount: 1500,
|
|
},
|
|
];
|
|
|
|
const findings = HighValueCodSkill.evaluate(rows, '2026-08-31 12:00:00', { codRiskThresholdAmount: 3000 });
|
|
expect(findings.length).toBe(1);
|
|
expect(findings[0].id).toBe('high_value_cod_alert');
|
|
expect(findings[0].count).toBe(1);
|
|
expect(findings[0].rows[0].bookingid).toBe(1);
|
|
});
|
|
|
|
it('executes enforce_otp_verification tool handler', async () => {
|
|
const tool = HighValueCodSkill.tools.find((t) => t.name === 'enforce_otp_verification');
|
|
expect(tool).toBeDefined();
|
|
|
|
const result = await tool.handler({ bookingId: 1 });
|
|
expect(result.success).toBe(true);
|
|
expect(result.proposal.action).toBe('require_otp');
|
|
});
|
|
});
|