Skip to content

Commit

Permalink
fix(elation): find future appointment output
Browse files Browse the repository at this point in the history
  • Loading branch information
nckhell committed Feb 6, 2025
1 parent 765126c commit 08b63b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ jest.mock('../../../../src/lib/llm/openai/createOpenAIModel', () => ({
pipe: jest.fn().mockReturnValue({
invoke: jest.fn().mockResolvedValue({
appointmentId: appointmentsMock[0].id,
explanation: 'Test explanation'
})
})
explanation: 'Test explanation',
}),
}),
},
metadata: {
care_flow_definition_id: 'whatever',
care_flow_id: 'test-flow-id',
activity_id: 'test-activity-id'
}
})
activity_id: 'test-activity-id',
},
}),
}))

describe('Elation - Find future appointment', () => {
const { extensionAction, onComplete, onError, helpers, clearMocks } =
const { extensionAction, onComplete, onError, helpers, clearMocks } =
TestHelpers.fromAction(action)

beforeEach(() => {
Expand All @@ -35,7 +35,7 @@ describe('Elation - Find future appointment', () => {

const mockAPIClient = makeAPIClient as jest.Mock
mockAPIClient.mockImplementation(() => ({
findAppointments: jest.fn().mockResolvedValue(appointmentsMock)
findAppointments: jest.fn().mockResolvedValue(appointmentsMock),
}))
})

Expand All @@ -59,14 +59,14 @@ describe('Elation - Find future appointment', () => {
definition_id: '123',
tenant_id: '123',
org_slug: 'test-org-slug',
org_id: 'test-org-id'
org_id: 'test-org-id',
},
activity: {
id: 'test-activity-id'
id: 'test-activity-id',
},
patient: {
id: 'test-patient-id'
}
id: 'test-patient-id',
},
},
onComplete,
onError,
Expand All @@ -82,9 +82,9 @@ describe('Elation - Find future appointment', () => {
events: [
expect.objectContaining({
text: expect.objectContaining({
en: expect.stringContaining('Found appointment: 123')
})
})
en: expect.stringContaining('Found appointment: 123'),
}),
}),
],
})
expect(onError).not.toHaveBeenCalled()
Expand All @@ -93,7 +93,7 @@ describe('Elation - Find future appointment', () => {
test('Should handle no appointments', async () => {
const mockAPIClient = makeAPIClient as jest.Mock
mockAPIClient.mockImplementation(() => ({
findAppointments: jest.fn().mockResolvedValue([])
findAppointments: jest.fn().mockResolvedValue([]),
}))

await extensionAction.onEvent({
Expand All @@ -115,14 +115,14 @@ describe('Elation - Find future appointment', () => {
definition_id: '123',
tenant_id: '123',
org_slug: 'test-org-slug',
org_id: 'test-org-id'
org_id: 'test-org-id',
},
activity: {
id: 'test-activity-id'
id: 'test-activity-id',
},
patient: {
id: 'test-patient-id'
}
id: 'test-patient-id',
},
},
onComplete,
onError,
Expand All @@ -131,8 +131,10 @@ describe('Elation - Find future appointment', () => {

expect(onComplete).toHaveBeenCalledWith({
data_points: {
appointment: undefined,
appointmentExists: 'false',
}
explanation: 'No future appointments found',
},
})
expect(onError).not.toHaveBeenCalled()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export const findFutureAppointment: Action<
if (appointments.length === 0) {
await onComplete({
data_points: {
appointment: undefined,
appointmentExists: 'false',
explanation: 'No future appointments found',
},
})
return
Expand Down

0 comments on commit 08b63b3

Please sign in to comment.