diff --git a/src/embed/hostEventClient/host-event-client.spec.ts b/src/embed/hostEventClient/host-event-client.spec.ts index 509670cb..2eda0e95 100644 --- a/src/embed/hostEventClient/host-event-client.spec.ts +++ b/src/embed/hostEventClient/host-event-client.spec.ts @@ -155,17 +155,33 @@ describe('HostEventClient', () => { description: 'Test Description', vizId: 'testVizId', }; - const mockResponse = { answerId: 'testAnswerId' }; - jest.spyOn(client, 'handleUiPassthroughForHostEvent').mockResolvedValue(mockResponse); - + const mockResponse = [{ + value: { + saveResponse: { + data: { + Answer__save: { + answer: { + id: 'newAnswer', + }, + }, + }, + }, + }, + refId: 'testVizId', + }]; + mockProcessTrigger.mockResolvedValue(mockResponse); const result = await client.executeHostEvent(getIFrameEl(), hostEvent, payload); - expect(client.handleUiPassthroughForHostEvent).toHaveBeenCalledWith( + expect(mockProcessTrigger).toHaveBeenCalledWith( null, - UiPassthroughEvent.saveAnswer, - payload, + 'UiPassthrough', + 'http://localhost', + { + parameters: payload, + type: 'saveAnswer', + }, ); - expect(result).toEqual(mockResponse); + expect(result).toEqual({ answerId: 'newAnswer', ...mockResponse[0].value }); }); it('should call hostEventFallback for unmapped events', async () => { diff --git a/src/embed/hostEventClient/host-event-client.ts b/src/embed/hostEventClient/host-event-client.ts index 0dcf2d4d..c7334503 100644 --- a/src/embed/hostEventClient/host-event-client.ts +++ b/src/embed/hostEventClient/host-event-client.ts @@ -72,7 +72,7 @@ export class HostEventClient { ); return { ...data, - answerId: data?.saveResponse?.Answer__save?.answer?.id, + answerId: data?.saveResponse?.data?.Answer__save?.answer?.id, }; } // fallback for save answer is Save