mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
fix(call-attribution): resolve Ozonetel chain AgentNames to agent.id
Inbound transferred calls arrive with AgentName like 'RamaiahAdmin -> GlobalHealthX'. The webhook was persisting the raw chain string and leaving agentId null; the CDR enrichment cron then silently skipped 100% of rows because the bulk CDR keys on caller-leg UCID while the webhook stores monitorUCID — the join never matched. - missed-call-webhook: split chain on ' -> ', take final handler, resolve via AgentLookupService (ozonetelAgentId + display name) - cdr-enrichment: index CDR rows by both UCID and monitorUCID so the cron actually patches historical rows - enrichment also parses chain in CDR AgentName as a second fallback - spec: add CallerResolutionService + AgentLookupService mocks
This commit is contained in:
@@ -11,6 +11,8 @@ import { Test } from '@nestjs/testing';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { MissedCallWebhookController } from './missed-call-webhook.controller';
|
||||
import { PlatformGraphqlService } from '../platform/platform-graphql.service';
|
||||
import { AgentLookupService } from '../platform/agent-lookup.service';
|
||||
import { CallerResolutionService } from '../caller/caller-resolution.service';
|
||||
import {
|
||||
WEBHOOK_INBOUND_ANSWERED,
|
||||
WEBHOOK_INBOUND_MISSED,
|
||||
@@ -48,11 +50,28 @@ describe('MissedCallWebhookController', () => {
|
||||
}),
|
||||
};
|
||||
|
||||
const mockCaller = {
|
||||
resolve: jest.fn().mockResolvedValue({
|
||||
leadId: '',
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
patientId: '',
|
||||
isNew: true,
|
||||
}),
|
||||
};
|
||||
|
||||
const mockAgentLookup = {
|
||||
resolveByOzonetelId: jest.fn().mockResolvedValue(null),
|
||||
resolveByDisplayName: jest.fn().mockResolvedValue(null),
|
||||
};
|
||||
|
||||
const module = await Test.createTestingModule({
|
||||
controllers: [MissedCallWebhookController],
|
||||
providers: [
|
||||
{ provide: PlatformGraphqlService, useValue: mockPlatformGql },
|
||||
{ provide: ConfigService, useValue: mockConfig },
|
||||
{ provide: CallerResolutionService, useValue: mockCaller },
|
||||
{ provide: AgentLookupService, useValue: mockAgentLookup },
|
||||
],
|
||||
}).compile();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user