@microsoft/omnichannel-chat-widget 1.5.1-main.c3533cf → 1.5.1-main.ee4453c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/Constants.js +15 -8
- package/lib/cjs/common/telemetry/TelemetryConstants.js +1 -2
- package/lib/cjs/common/utils.js +2 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +16 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +8 -82
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +205 -0
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.spec.js +282 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +12 -13
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +68 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.js +15 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
- package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
- package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -11
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/cjs/contexts/common/ConversationState.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +1 -0
- package/lib/cjs/controller/componentController.js +5 -1
- package/lib/esm/common/Constants.js +11 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -2
- package/lib/esm/common/utils.js +3 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +14 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +9 -83
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +198 -0
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.spec.js +280 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +14 -15
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +57 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.js +8 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
- package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
- package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -11
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/esm/contexts/common/ConversationState.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +1 -0
- package/lib/esm/controller/componentController.js +3 -0
- package/lib/types/common/Constants.d.ts +13 -4
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.spec.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -1
- package/lib/types/components/startchaterrorpanestateful/StartChatErrorPaneStateful.d.ts +3 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.d.ts +5 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.d.ts +6 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +10 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +8 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.d.ts +10 -0
- package/lib/types/contexts/common/ConversationState.d.ts +2 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/controller/componentController.d.ts +1 -0
- package/package.json +3 -3
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +0 -4
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +0 -4
- /package/lib/cjs/components/{loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.js} +0 -0
- /package/lib/cjs/components/{loadingpanestateful/interfaces/IStartChatErrorPaneProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.js} +0 -0
- /package/lib/esm/components/{loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.js} +0 -0
- /package/lib/esm/components/{loadingpanestateful/interfaces/IStartChatErrorPaneProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.js} +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
4
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
5
|
+
var _startChatErrorHandler = require("./startChatErrorHandler");
|
|
6
|
+
var _Constants = require("../../../common/Constants");
|
|
7
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
|
+
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
9
|
+
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
10
|
+
describe("startChatErrorHandler unit test", () => {
|
|
11
|
+
it("handleStartChatError should log failed event and return if exception is undefined", () => {
|
|
12
|
+
const dispatch = jest.fn();
|
|
13
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
14
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
15
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, undefined, false);
|
|
16
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
17
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
18
|
+
ExceptionDetails: expect.objectContaining({
|
|
19
|
+
Exception: "Widget load complete with error: undefined"
|
|
20
|
+
})
|
|
21
|
+
}));
|
|
22
|
+
expect(dispatch).not.toHaveBeenCalled();
|
|
23
|
+
});
|
|
24
|
+
it("handleStartChatError should log failed with error event for AuthenticationFailedErrorString", () => {
|
|
25
|
+
const dispatch = jest.fn();
|
|
26
|
+
const mockEx = new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
27
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
28
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
29
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
30
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
31
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
32
|
+
ExceptionDetails: expect.objectContaining({
|
|
33
|
+
Exception: `Widget load complete with error: Error: ${_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString}`
|
|
34
|
+
})
|
|
35
|
+
}));
|
|
36
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
37
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
38
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
it("handleStartChatError should log failed with error event for NetworkErrorString", () => {
|
|
42
|
+
const dispatch = jest.fn();
|
|
43
|
+
const mockEx = new Error(_Constants.WidgetLoadCustomErrorString.NetworkErrorString);
|
|
44
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
45
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
46
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
47
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
48
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
49
|
+
ExceptionDetails: expect.objectContaining({
|
|
50
|
+
Exception: `Widget load complete with error: Error: ${_Constants.WidgetLoadCustomErrorString.NetworkErrorString}`
|
|
51
|
+
})
|
|
52
|
+
}));
|
|
53
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
54
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
55
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
56
|
+
}));
|
|
57
|
+
});
|
|
58
|
+
it("handleStartChatError should log complete event for WidgetUseOutsideOperatingHour", () => {
|
|
59
|
+
const dispatch = jest.fn();
|
|
60
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.WidgetUseOutsideOperatingHour);
|
|
61
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
62
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
63
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
64
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
65
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("INFO", expect.objectContaining({
|
|
66
|
+
Description: `Widget load complete. ${_Constants.WidgetLoadTelemetryMessage.OOOHMessage}`
|
|
67
|
+
}));
|
|
68
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
69
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
70
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
71
|
+
}));
|
|
72
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
73
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
it("handleStartChatError should log failed with error event for PersistentChatConversationRetrievalFailure for non-400 status", () => {
|
|
77
|
+
const dispatch = jest.fn();
|
|
78
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure, 429);
|
|
79
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
80
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
81
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
82
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
83
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
84
|
+
Description: "Widget load complete with error",
|
|
85
|
+
ExceptionDetails: expect.objectContaining({
|
|
86
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure}`,
|
|
87
|
+
HttpResponseStatusCode: 429
|
|
88
|
+
})
|
|
89
|
+
}));
|
|
90
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
91
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
92
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
93
|
+
}));
|
|
94
|
+
});
|
|
95
|
+
it("handleStartChatError should log failed event for PersistentChatConversationRetrievalFailure for 400 status", () => {
|
|
96
|
+
const dispatch = jest.fn();
|
|
97
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure, 400);
|
|
98
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
99
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
100
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
101
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
102
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
103
|
+
ExceptionDetails: expect.objectContaining({
|
|
104
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure}`,
|
|
105
|
+
HttpResponseStatusCode: 400
|
|
106
|
+
})
|
|
107
|
+
}));
|
|
108
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
109
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
110
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
111
|
+
}));
|
|
112
|
+
});
|
|
113
|
+
it("handleStartChatError should log failed with error event for ConversationInitializationFailure for non-400 status", () => {
|
|
114
|
+
const dispatch = jest.fn();
|
|
115
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure, 429);
|
|
116
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
117
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
118
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
119
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
120
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
121
|
+
Description: "Widget load complete with error",
|
|
122
|
+
ExceptionDetails: expect.objectContaining({
|
|
123
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure}`,
|
|
124
|
+
HttpResponseStatusCode: 429
|
|
125
|
+
})
|
|
126
|
+
}));
|
|
127
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
128
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
129
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
130
|
+
}));
|
|
131
|
+
});
|
|
132
|
+
it("handleStartChatError should log failed event for ConversationInitializationFailure for 400 status", () => {
|
|
133
|
+
const dispatch = jest.fn();
|
|
134
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure, 400);
|
|
135
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
136
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
137
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
138
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
139
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
140
|
+
ExceptionDetails: expect.objectContaining({
|
|
141
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure}`,
|
|
142
|
+
HttpResponseStatusCode: 400
|
|
143
|
+
})
|
|
144
|
+
}));
|
|
145
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
146
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
147
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
148
|
+
}));
|
|
149
|
+
});
|
|
150
|
+
it("handleStartChatError should log failed with error event for ChatTokenRetrievalFailure for non-400 status", () => {
|
|
151
|
+
const dispatch = jest.fn();
|
|
152
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure, 429);
|
|
153
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
154
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
155
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
156
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
157
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
158
|
+
Description: "Widget load complete with error",
|
|
159
|
+
ExceptionDetails: expect.objectContaining({
|
|
160
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure}`,
|
|
161
|
+
HttpResponseStatusCode: 429
|
|
162
|
+
})
|
|
163
|
+
}));
|
|
164
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
165
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
166
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
167
|
+
}));
|
|
168
|
+
});
|
|
169
|
+
it("handleStartChatError should log failed event for ChatTokenRetrievalFailure for 400 status", () => {
|
|
170
|
+
const dispatch = jest.fn();
|
|
171
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure, 400);
|
|
172
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
173
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
174
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
175
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
176
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
177
|
+
ExceptionDetails: expect.objectContaining({
|
|
178
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure}`,
|
|
179
|
+
HttpResponseStatusCode: 400
|
|
180
|
+
})
|
|
181
|
+
}));
|
|
182
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
183
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
184
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
185
|
+
}));
|
|
186
|
+
});
|
|
187
|
+
it("handleStartChatError should log failed with error event for UninitializedChatSDK", () => {
|
|
188
|
+
const dispatch = jest.fn();
|
|
189
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK);
|
|
190
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
191
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
192
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
193
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
194
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
195
|
+
Description: "Widget load complete with error",
|
|
196
|
+
ExceptionDetails: expect.objectContaining({
|
|
197
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK}`
|
|
198
|
+
})
|
|
199
|
+
}));
|
|
200
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
201
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
202
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
203
|
+
}));
|
|
204
|
+
});
|
|
205
|
+
it("handleStartChatError should log failed with error event for InvalidConversation", () => {
|
|
206
|
+
const dispatch = jest.fn();
|
|
207
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.InvalidConversation);
|
|
208
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
209
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
210
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
211
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
212
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
213
|
+
Description: "Widget load complete with error",
|
|
214
|
+
ExceptionDetails: expect.objectContaining({
|
|
215
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.InvalidConversation}`
|
|
216
|
+
})
|
|
217
|
+
}));
|
|
218
|
+
expect(dispatch).toHaveBeenCalledTimes(16);
|
|
219
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
220
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
221
|
+
payload: _ConversationState.ConversationState.Closed
|
|
222
|
+
}));
|
|
223
|
+
});
|
|
224
|
+
it("handleStartChatError should log failed with error event for ClosedConversation", () => {
|
|
225
|
+
const dispatch = jest.fn();
|
|
226
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ClosedConversation);
|
|
227
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
228
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
229
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
230
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
231
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
232
|
+
Description: "Widget load complete with error",
|
|
233
|
+
ExceptionDetails: expect.objectContaining({
|
|
234
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ClosedConversation}`
|
|
235
|
+
})
|
|
236
|
+
}));
|
|
237
|
+
expect(dispatch).toHaveBeenCalledTimes(16);
|
|
238
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
239
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
240
|
+
payload: _ConversationState.ConversationState.Closed
|
|
241
|
+
}));
|
|
242
|
+
});
|
|
243
|
+
it("handleStartChatError should log failed event for any other errors", () => {
|
|
244
|
+
const dispatch = jest.fn();
|
|
245
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure, 405);
|
|
246
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
247
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
248
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
249
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
250
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
251
|
+
ExceptionDetails: expect.objectContaining({
|
|
252
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure}`,
|
|
253
|
+
HttpResponseStatusCode: 405
|
|
254
|
+
})
|
|
255
|
+
}));
|
|
256
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
257
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
258
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
259
|
+
}));
|
|
260
|
+
});
|
|
261
|
+
it("handleStartChatError should force end chat if isStartChatSuccessful is true", () => {
|
|
262
|
+
const dispatch = jest.fn();
|
|
263
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure, 405);
|
|
264
|
+
const mockSDK = {
|
|
265
|
+
endChat: jest.fn()
|
|
266
|
+
};
|
|
267
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
268
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
269
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, mockSDK, {}, mockEx, true);
|
|
270
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(3);
|
|
271
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
272
|
+
ExceptionDetails: expect.objectContaining({
|
|
273
|
+
Exception: "SessionInit was successful, but widget load failed."
|
|
274
|
+
})
|
|
275
|
+
}));
|
|
276
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
277
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
278
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
279
|
+
}));
|
|
280
|
+
expect(mockSDK.endChat).toHaveBeenCalled();
|
|
281
|
+
});
|
|
282
|
+
});
|
|
@@ -55,13 +55,13 @@ var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useCha
|
|
|
55
55
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
56
56
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
57
57
|
var _defaultAdaptiveCardStyles = require("../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles");
|
|
58
|
-
var
|
|
58
|
+
var _StartChatErrorPaneStateful = _interopRequireDefault(require("../../startchaterrorpanestateful/StartChatErrorPaneStateful"));
|
|
59
59
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
60
60
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
61
61
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
62
62
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
63
63
|
const LiveChatWidgetStateful = props => {
|
|
64
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$
|
|
64
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
65
65
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
66
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
67
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -194,6 +194,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
194
194
|
};
|
|
195
195
|
(0, _react2.useEffect)(() => {
|
|
196
196
|
var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch, _state$appStates5;
|
|
197
|
+
dispatch({
|
|
198
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
199
|
+
payload: false
|
|
200
|
+
});
|
|
197
201
|
state.domainStates.confirmationPaneConfirmedOptionClicked = false;
|
|
198
202
|
state.domainStates.confirmationState = _Constants.ConfirmationState.NotSet;
|
|
199
203
|
setupClientDataStore();
|
|
@@ -433,12 +437,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
433
437
|
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
434
438
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
435
439
|
(0, _endChat.endChatStateCleanUp)(dispatch);
|
|
436
|
-
|
|
437
|
-
chatSDK.requestId = (0, _omnichannelChatSdk.uuidv4)();
|
|
438
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
439
|
-
chatSDK.chatToken = {};
|
|
440
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
441
|
-
chatSDK.reconnectId = null;
|
|
440
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
442
441
|
return;
|
|
443
442
|
}
|
|
444
443
|
});
|
|
@@ -713,18 +712,18 @@ const LiveChatWidgetStateful = props => {
|
|
|
713
712
|
}, headerDraggableConfig))), !((_livechatProps$contro5 = livechatProps.controlProps) !== null && _livechatProps$contro5 !== void 0 && _livechatProps$contro5.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon4 = livechatProps.componentOverrides) === null || _livechatProps$compon4 === void 0 ? void 0 : _livechatProps$compon4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, {
|
|
714
713
|
loadingPaneProps: livechatProps.loadingPaneProps,
|
|
715
714
|
startChatErrorPaneProps: livechatProps.startChatErrorPaneProps
|
|
716
|
-
})), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.
|
|
715
|
+
})), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.hideErrorUIPane) && (0, _componentController.shouldShowStartChatErrorPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon5 = livechatProps.componentOverrides) === null || _livechatProps$compon5 === void 0 ? void 0 : _livechatProps$compon5.startChatErrorPane) || /*#__PURE__*/_react2.default.createElement(_StartChatErrorPaneStateful.default, livechatProps.startChatErrorPaneProps)), !((_livechatProps$contro7 = livechatProps.controlProps) !== null && _livechatProps$contro7 !== void 0 && _livechatProps$contro7.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon6 = livechatProps.componentOverrides) === null || _livechatProps$compon6 === void 0 ? void 0 : _livechatProps$compon6.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, livechatProps.outOfOfficeHoursPaneProps)), !((_livechatProps$contro8 = livechatProps.controlProps) !== null && _livechatProps$contro8 !== void 0 && _livechatProps$contro8.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon7 = livechatProps.componentOverrides) === null || _livechatProps$compon7 === void 0 ? void 0 : _livechatProps$compon7.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
|
|
717
716
|
reconnectChatProps: livechatProps.reconnectChatPaneProps,
|
|
718
717
|
initStartChat: initStartChatRelay
|
|
719
|
-
})), !((_livechatProps$
|
|
718
|
+
})), !((_livechatProps$contro9 = livechatProps.controlProps) !== null && _livechatProps$contro9 !== void 0 && _livechatProps$contro9.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon8 = livechatProps.componentOverrides) === null || _livechatProps$compon8 === void 0 ? void 0 : _livechatProps$compon8.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
|
|
720
719
|
surveyProps: livechatProps.preChatSurveyPaneProps,
|
|
721
720
|
initStartChat: initStartChatRelay
|
|
722
|
-
})), !((_livechatProps$
|
|
721
|
+
})), !((_livechatProps$contro10 = livechatProps.controlProps) !== null && _livechatProps$contro10 !== void 0 && _livechatProps$contro10.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
723
722
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
724
|
-
}, livechatProps.callingContainerProps)), !((_livechatProps$
|
|
723
|
+
}, livechatProps.callingContainerProps)), !((_livechatProps$contro11 = livechatProps.controlProps) !== null && _livechatProps$contro11 !== void 0 && _livechatProps$contro11.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon9 = livechatProps.componentOverrides) === null || _livechatProps$compon9 === void 0 ? void 0 : _livechatProps$compon9.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, livechatProps)), !((_livechatProps$contro12 = livechatProps.controlProps) !== null && _livechatProps$contro12 !== void 0 && _livechatProps$contro12.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon10 = livechatProps.componentOverrides) === null || _livechatProps$compon10 === void 0 ? void 0 : _livechatProps$compon10.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
|
|
725
724
|
setPostChatContext: setPostChatContextRelay,
|
|
726
725
|
prepareEndChat: prepareEndChatRelay
|
|
727
|
-
}))), !((_livechatProps$
|
|
726
|
+
}))), !((_livechatProps$contro13 = livechatProps.controlProps) !== null && _livechatProps$contro13 !== void 0 && _livechatProps$contro13.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, livechatProps.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK))), (0, _createFooter.createFooter)(livechatProps, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon13 = livechatProps.componentOverrides) === null || _livechatProps$compon13 === void 0 ? void 0 : _livechatProps$compon13.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, livechatProps.emailTranscriptPane))))));
|
|
728
727
|
};
|
|
729
728
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
730
729
|
var _default = LiveChatWidgetStateful;
|
|
@@ -9,10 +9,10 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
10
10
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
11
11
|
var _defaultgeneralLoadingPaneStyleProps = require("./common/defaultStyleProps/defaultgeneralLoadingPaneStyleProps");
|
|
12
|
-
var _errorUILoadingPaneStyleProps = require("./common/errorUIStyleProps/errorUILoadingPaneStyleProps");
|
|
13
12
|
var _utils = require("../../common/utils");
|
|
14
13
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
15
14
|
var _useWindowDimensions = _interopRequireDefault(require("../../hooks/useWindowDimensions"));
|
|
15
|
+
var _errorUILoadingPaneStyleProps = require("./common/errorUIStyleProps/errorUILoadingPaneStyleProps");
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.StartChatErrorPaneStateful = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
+
var _utils = require("../../common/utils");
|
|
10
|
+
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
11
|
+
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
12
|
+
var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
13
|
+
var _defaultStartChatErrorPaneGeneralStyleProps = require("./common/defaultStartChatErrorPaneGeneralStyleProps");
|
|
14
|
+
var _defaultStartChatErrorPaneTitleStyleProps = require("./common/defaultStartChatErrorPaneTitleStyleProps");
|
|
15
|
+
var _defaultStartChatErrorPaneSubtitleStyleProps = require("./common/defaultStartChatErrorPaneSubtitleStyleProps");
|
|
16
|
+
var _defaultStartChatErrorPaneIconStyleProps = require("./common/defaultStartChatErrorPaneIconStyleProps");
|
|
17
|
+
var _defaultStartChatErrorPaneIconImageProps = require("./common/defaultStartChatErrorPaneIconImageProps");
|
|
18
|
+
var _Constants = require("../../common/Constants");
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
const StartChatErrorPaneStateful = startChatErrorPaneProps => {
|
|
23
|
+
var _startChatErrorPanePr, _startChatErrorPanePr2, _startChatErrorPanePr3, _startChatErrorPanePr4, _startChatErrorPanePr5, _startChatErrorPanePr6, _startChatErrorPanePr7;
|
|
24
|
+
const [state] = (0, _useChatContextStore.default)();
|
|
25
|
+
const generalStyleProps = Object.assign({}, _defaultStartChatErrorPaneGeneralStyleProps.defaultStartChatErrorPaneGeneralStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr === void 0 ? void 0 : _startChatErrorPanePr.generalStyleProps);
|
|
26
|
+
const titleStyleProps = Object.assign({}, _defaultStartChatErrorPaneTitleStyleProps.defaultStartChatErrorPaneTitleStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr2 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr2 === void 0 ? void 0 : _startChatErrorPanePr2.titleStyleProps);
|
|
27
|
+
const subtitleStyleProps = Object.assign({}, _defaultStartChatErrorPaneSubtitleStyleProps.defaultStartChatErrorPaneSubtitleStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr3 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr3 === void 0 ? void 0 : _startChatErrorPanePr3.subtitleStyleProps);
|
|
28
|
+
const iconStyleProps = Object.assign({}, _defaultStartChatErrorPaneIconStyleProps.defaultStartChatErrorPaneIconStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr4 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr4 === void 0 ? void 0 : _startChatErrorPanePr4.iconStyleProps);
|
|
29
|
+
const iconImageProps = Object.assign({}, _defaultStartChatErrorPaneIconImageProps.defaultStartChatErrorPaneIconImageStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr5 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr5 === void 0 ? void 0 : _startChatErrorPanePr5.iconImageProps);
|
|
30
|
+
const errorUIStyleProps = {
|
|
31
|
+
generalStyleProps: generalStyleProps,
|
|
32
|
+
titleStyleProps: titleStyleProps,
|
|
33
|
+
subtitleStyleProps: subtitleStyleProps,
|
|
34
|
+
iconStyleProps: iconStyleProps,
|
|
35
|
+
iconImageProps: iconImageProps
|
|
36
|
+
};
|
|
37
|
+
const errorPaneTitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr6 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr6 === void 0 ? void 0 : _startChatErrorPanePr6.titleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorTitleText;
|
|
38
|
+
const errorPaneSubtitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr7 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr7 === void 0 ? void 0 : _startChatErrorPanePr7.subtitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorSubtitleText;
|
|
39
|
+
const errorUIControlProps = {
|
|
40
|
+
id: _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorPaneId,
|
|
41
|
+
dir: state.domainStates.globalDir,
|
|
42
|
+
titleText: errorPaneTitleText,
|
|
43
|
+
subtitleText: errorPaneSubtitleText,
|
|
44
|
+
hideSpinner: true,
|
|
45
|
+
hideSpinnerText: true,
|
|
46
|
+
...(startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : startChatErrorPaneProps.controlProps)
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Move focus to the first button
|
|
50
|
+
(0, _react.useEffect)(() => {
|
|
51
|
+
const firstElement = (0, _utils.findAllFocusableElement)(`#${state.domainStates.widgetElementId}`);
|
|
52
|
+
if (firstElement && firstElement[0]) {
|
|
53
|
+
firstElement[0].focus();
|
|
54
|
+
}
|
|
55
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
56
|
+
Event: _TelemetryConstants.TelemetryEvent.StartChatErrorPaneLoaded,
|
|
57
|
+
Description: "Start chat error pane loaded."
|
|
58
|
+
});
|
|
59
|
+
}, []);
|
|
60
|
+
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.LoadingPane, {
|
|
61
|
+
componentOverrides: startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : startChatErrorPaneProps.componentOverrides,
|
|
62
|
+
controlProps: errorUIControlProps,
|
|
63
|
+
styleProps: errorUIStyleProps
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
exports.StartChatErrorPaneStateful = StartChatErrorPaneStateful;
|
|
67
|
+
var _default = StartChatErrorPaneStateful;
|
|
68
|
+
exports.default = _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneGeneralStyleProps = void 0;
|
|
7
|
+
const defaultStartChatErrorPaneGeneralStyleProps = {
|
|
8
|
+
position: "initial",
|
|
9
|
+
width: "100%",
|
|
10
|
+
height: "100%",
|
|
11
|
+
left: "0%",
|
|
12
|
+
top: "0%",
|
|
13
|
+
borderRadius: "0 0 4px 4px",
|
|
14
|
+
borderWidth: "0px",
|
|
15
|
+
backgroundColor: "#FFFFFF"
|
|
16
|
+
};
|
|
17
|
+
exports.defaultStartChatErrorPaneGeneralStyleProps = defaultStartChatErrorPaneGeneralStyleProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneIconImageStyleProps = void 0;
|
|
7
|
+
var _react = require("@fluentui/react");
|
|
8
|
+
var _Icons = require("../../../assets/Icons");
|
|
9
|
+
const defaultStartChatErrorPaneIconImageStyleProps = {
|
|
10
|
+
src: _Icons.AlertIcon,
|
|
11
|
+
imageFit: _react.ImageFit.centerContain,
|
|
12
|
+
width: "86px",
|
|
13
|
+
height: "86px",
|
|
14
|
+
shouldFadeIn: false,
|
|
15
|
+
shouldStartVisible: true
|
|
16
|
+
};
|
|
17
|
+
exports.defaultStartChatErrorPaneIconImageStyleProps = defaultStartChatErrorPaneIconImageStyleProps;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneIconStyleProps = void 0;
|
|
7
|
+
const defaultStartChatErrorPaneIconStyleProps = {
|
|
8
|
+
display: "flex",
|
|
9
|
+
order: 1,
|
|
10
|
+
alignSelf: "auto",
|
|
11
|
+
backgroundColor: "#FFFFFF",
|
|
12
|
+
boxShadow: "#FFFFFF 0px 0px 0px 0px",
|
|
13
|
+
margin: "0px 0px 0px 0px"
|
|
14
|
+
};
|
|
15
|
+
exports.defaultStartChatErrorPaneIconStyleProps = defaultStartChatErrorPaneIconStyleProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneSubtitleStyleProps = void 0;
|
|
7
|
+
const defaultStartChatErrorPaneSubtitleStyleProps = {
|
|
8
|
+
fontFamily: "'Segoe UI',Arial,sans-serif",
|
|
9
|
+
fontWeight: "normal",
|
|
10
|
+
fontSize: "18px",
|
|
11
|
+
color: "#36454F",
|
|
12
|
+
textAlign: "center",
|
|
13
|
+
display: "flex",
|
|
14
|
+
order: 3,
|
|
15
|
+
alignSelf: "auto"
|
|
16
|
+
};
|
|
17
|
+
exports.defaultStartChatErrorPaneSubtitleStyleProps = defaultStartChatErrorPaneSubtitleStyleProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneTitleStyleProps = void 0;
|
|
7
|
+
const defaultStartChatErrorPaneTitleStyleProps = {
|
|
8
|
+
fontFamily: "'Segoe UI',Arial,sans-serif",
|
|
9
|
+
fontWeight: "normal",
|
|
10
|
+
fontSize: "18px",
|
|
11
|
+
color: "#36454F",
|
|
12
|
+
textAlign: "center",
|
|
13
|
+
display: "flex",
|
|
14
|
+
order: 2,
|
|
15
|
+
alignSelf: "auto"
|
|
16
|
+
};
|
|
17
|
+
exports.defaultStartChatErrorPaneTitleStyleProps = defaultStartChatErrorPaneTitleStyleProps;
|
package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -8,7 +8,6 @@ var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryCons
|
|
|
8
8
|
var _Constants = require("../../../../../common/Constants");
|
|
9
9
|
var _DirectLineActivityType = require("../../enums/DirectLineActivityType");
|
|
10
10
|
var _DirectLineSenderRole = require("../../enums/DirectLineSenderRole");
|
|
11
|
-
var _MessageType = require("../../enums/MessageType");
|
|
12
11
|
var _react = _interopRequireDefault(require("react"));
|
|
13
12
|
var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
|
|
14
13
|
var _defaultSystemMessageStyles = require("./defaultStyles/defaultSystemMessageStyles");
|
|
@@ -55,7 +54,7 @@ const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
|
55
54
|
return () => /*#__PURE__*/_react.default.createElement("div", {
|
|
56
55
|
key: card.activity.id,
|
|
57
56
|
style: systemMessageStyles,
|
|
58
|
-
"aria-hidden": "
|
|
57
|
+
"aria-hidden": "false",
|
|
59
58
|
dangerouslySetInnerHTML: {
|
|
60
59
|
__html: (0, _utils.escapeHtml)(card.activity.text)
|
|
61
60
|
}
|
|
@@ -81,13 +80,6 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
81
80
|
if (card.activity) {
|
|
82
81
|
var _card$activity$from;
|
|
83
82
|
if (((_card$activity$from = card.activity.from) === null || _card$activity$from === void 0 ? void 0 : _card$activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel) {
|
|
84
|
-
var _card$activity$channe3;
|
|
85
|
-
if (((_card$activity$channe3 = card.activity.channelData) === null || _card$activity$channe3 === void 0 ? void 0 : _card$activity$channe3.type) === _MessageType.MessageTypes.Thread) {
|
|
86
|
-
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
87
|
-
Event: _TelemetryConstants.TelemetryEvent.IC3ThreadUpdateEventReceived,
|
|
88
|
-
Description: "IC3 ThreadUpdateEvent Received"
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
83
|
return () => false;
|
|
92
84
|
}
|
|
93
85
|
if (isTagIncluded(card, _Constants.Constants.hiddenTag)) {
|
|
@@ -108,8 +100,7 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
108
100
|
return function () {
|
|
109
101
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
110
102
|
className: card.activity.from.role === _DirectLineSenderRole.DirectLineSenderRole.User ? _Constants.Constants.sentMessageClassName : _Constants.Constants.receivedMessageClassName,
|
|
111
|
-
style: userMessageStyles
|
|
112
|
-
"aria-hidden": "true"
|
|
103
|
+
style: userMessageStyles
|
|
113
104
|
}, next(...args)(...arguments));
|
|
114
105
|
};
|
|
115
106
|
}
|
|
@@ -22,7 +22,7 @@ describe("activityMiddleware test", () => {
|
|
|
22
22
|
};
|
|
23
23
|
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
24
24
|
expect(results()).toEqual(false);
|
|
25
|
-
expect(_TelemetryHelper.TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(
|
|
25
|
+
expect(_TelemetryHelper.TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(0);
|
|
26
26
|
});
|
|
27
27
|
it("createActivityMiddleware() with Hidden tag should return nothing", () => {
|
|
28
28
|
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
@@ -17,4 +17,5 @@ exports.ConversationState = ConversationState;
|
|
|
17
17
|
ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
|
|
18
18
|
ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
|
|
19
19
|
ConversationState[ConversationState["Closed"] = 9] = "Closed";
|
|
20
|
+
ConversationState[ConversationState["Error"] = 10] = "Error";
|
|
20
21
|
})(ConversationState || (exports.ConversationState = ConversationState = {}));
|