@microsoft/omnichannel-chat-widget 1.5.1-main.132e1c6 → 1.5.1-main.6b98130
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 +19 -8
- package/lib/cjs/common/telemetry/TelemetryConstants.js +1 -2
- package/lib/cjs/common/utils.js +2 -1
- package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +31 -16
- package/lib/cjs/components/livechatwidget/common/endChat.js +16 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +19 -80
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +219 -0
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.spec.js +300 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +18 -16
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +82 -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/LiveChatWidgetActionType.js +37 -36
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +4 -1
- package/lib/cjs/contexts/common/StartChatFailureType.js +13 -0
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/cjs/controller/componentController.js +5 -1
- package/lib/esm/common/Constants.js +15 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -2
- package/lib/esm/common/utils.js +3 -2
- package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +31 -16
- package/lib/esm/components/livechatwidget/common/endChat.js +14 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +20 -81
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +212 -0
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.spec.js +298 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +20 -18
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +71 -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/LiveChatWidgetActionType.js +37 -36
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +4 -1
- package/lib/esm/contexts/common/StartChatFailureType.js +6 -0
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/esm/controller/componentController.js +3 -0
- package/lib/types/common/Constants.d.ts +17 -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 +14 -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 +3 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +37 -36
- package/lib/types/contexts/common/StartChatFailureType.d.ts +5 -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,300 @@
|
|
|
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(3);
|
|
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 ChatTokenRetrievalFailure for 401 status", () => {
|
|
188
|
+
const dispatch = jest.fn();
|
|
189
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure, 401);
|
|
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
|
+
ExceptionDetails: expect.objectContaining({
|
|
196
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure}`,
|
|
197
|
+
HttpResponseStatusCode: 401
|
|
198
|
+
})
|
|
199
|
+
}));
|
|
200
|
+
expect(dispatch).toHaveBeenCalledTimes(3);
|
|
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 UninitializedChatSDK", () => {
|
|
206
|
+
const dispatch = jest.fn();
|
|
207
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK);
|
|
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(2);
|
|
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.UninitializedChatSDK}`
|
|
216
|
+
})
|
|
217
|
+
}));
|
|
218
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
219
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
220
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
221
|
+
}));
|
|
222
|
+
});
|
|
223
|
+
it("handleStartChatError should log failed with error event for InvalidConversation", () => {
|
|
224
|
+
const dispatch = jest.fn();
|
|
225
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.InvalidConversation);
|
|
226
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
227
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
228
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
229
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
230
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
231
|
+
Description: "Widget load complete with error",
|
|
232
|
+
ExceptionDetails: expect.objectContaining({
|
|
233
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.InvalidConversation}`
|
|
234
|
+
})
|
|
235
|
+
}));
|
|
236
|
+
expect(dispatch).toHaveBeenCalledTimes(16);
|
|
237
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
238
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
239
|
+
payload: _ConversationState.ConversationState.Closed
|
|
240
|
+
}));
|
|
241
|
+
});
|
|
242
|
+
it("handleStartChatError should log failed with error event for ClosedConversation", () => {
|
|
243
|
+
const dispatch = jest.fn();
|
|
244
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ClosedConversation);
|
|
245
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
246
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
247
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
248
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
249
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
250
|
+
Description: "Widget load complete with error",
|
|
251
|
+
ExceptionDetails: expect.objectContaining({
|
|
252
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ClosedConversation}`
|
|
253
|
+
})
|
|
254
|
+
}));
|
|
255
|
+
expect(dispatch).toHaveBeenCalledTimes(16);
|
|
256
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
257
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
258
|
+
payload: _ConversationState.ConversationState.Closed
|
|
259
|
+
}));
|
|
260
|
+
});
|
|
261
|
+
it("handleStartChatError should log failed event for any other errors", () => {
|
|
262
|
+
const dispatch = jest.fn();
|
|
263
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure, 405);
|
|
264
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
265
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
266
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
267
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
268
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
269
|
+
ExceptionDetails: expect.objectContaining({
|
|
270
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure}`,
|
|
271
|
+
HttpResponseStatusCode: 405
|
|
272
|
+
})
|
|
273
|
+
}));
|
|
274
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
275
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
276
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
277
|
+
}));
|
|
278
|
+
});
|
|
279
|
+
it("handleStartChatError should force end chat if isStartChatSuccessful is true", () => {
|
|
280
|
+
const dispatch = jest.fn();
|
|
281
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure, 405);
|
|
282
|
+
const mockSDK = {
|
|
283
|
+
endChat: jest.fn()
|
|
284
|
+
};
|
|
285
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
286
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
287
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, mockSDK, {}, mockEx, true);
|
|
288
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(3);
|
|
289
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
290
|
+
ExceptionDetails: expect.objectContaining({
|
|
291
|
+
Exception: "SessionInit was successful, but widget load failed."
|
|
292
|
+
})
|
|
293
|
+
}));
|
|
294
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
295
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
296
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
297
|
+
}));
|
|
298
|
+
expect(mockSDK.endChat).toHaveBeenCalled();
|
|
299
|
+
});
|
|
300
|
+
});
|
|
@@ -55,13 +55,14 @@ 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
|
+
var _StartChatFailureType = require("../../../contexts/common/StartChatFailureType");
|
|
59
60
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
60
61
|
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
62
|
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
63
|
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
64
|
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$
|
|
65
|
+
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
66
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
66
67
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
68
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -194,6 +195,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
194
195
|
};
|
|
195
196
|
(0, _react2.useEffect)(() => {
|
|
196
197
|
var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch, _state$appStates5;
|
|
198
|
+
dispatch({
|
|
199
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
200
|
+
payload: false
|
|
201
|
+
});
|
|
202
|
+
dispatch({
|
|
203
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
204
|
+
payload: _StartChatFailureType.StartChatFailureType.Generic
|
|
205
|
+
});
|
|
197
206
|
state.domainStates.confirmationPaneConfirmedOptionClicked = false;
|
|
198
207
|
state.domainStates.confirmationState = _Constants.ConfirmationState.NotSet;
|
|
199
208
|
setupClientDataStore();
|
|
@@ -433,12 +442,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
433
442
|
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
443
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
435
444
|
(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;
|
|
445
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
442
446
|
return;
|
|
443
447
|
}
|
|
444
448
|
});
|
|
@@ -616,9 +620,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
616
620
|
|
|
617
621
|
// Handle Chat disconnect cases
|
|
618
622
|
(0, _react2.useEffect)(() => {
|
|
619
|
-
|
|
620
|
-
(0, _chatDisconnectHelper.handleChatDisconnect)(props, state, setWebChatStyles);
|
|
621
|
-
}
|
|
623
|
+
(0, _chatDisconnectHelper.handleChatDisconnect)(props, state, setWebChatStyles);
|
|
622
624
|
}, [state.appStates.chatDisconnectEventReceived]);
|
|
623
625
|
const initiateEndChatOnBrowserUnload = () => {
|
|
624
626
|
var _DataStoreManager$cli;
|
|
@@ -715,18 +717,18 @@ const LiveChatWidgetStateful = props => {
|
|
|
715
717
|
}, 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, {
|
|
716
718
|
loadingPaneProps: livechatProps.loadingPaneProps,
|
|
717
719
|
startChatErrorPaneProps: livechatProps.startChatErrorPaneProps
|
|
718
|
-
})), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.
|
|
720
|
+
})), !((_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, {
|
|
719
721
|
reconnectChatProps: livechatProps.reconnectChatPaneProps,
|
|
720
722
|
initStartChat: initStartChatRelay
|
|
721
|
-
})), !((_livechatProps$
|
|
723
|
+
})), !((_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, {
|
|
722
724
|
surveyProps: livechatProps.preChatSurveyPaneProps,
|
|
723
725
|
initStartChat: initStartChatRelay
|
|
724
|
-
})), !((_livechatProps$
|
|
726
|
+
})), !((_livechatProps$contro10 = livechatProps.controlProps) !== null && _livechatProps$contro10 !== void 0 && _livechatProps$contro10.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
725
727
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
726
|
-
}, livechatProps.callingContainerProps)), !((_livechatProps$
|
|
728
|
+
}, 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, {
|
|
727
729
|
setPostChatContext: setPostChatContextRelay,
|
|
728
730
|
prepareEndChat: prepareEndChatRelay
|
|
729
|
-
}))), !((_livechatProps$
|
|
731
|
+
}))), !((_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))))));
|
|
730
732
|
};
|
|
731
733
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
732
734
|
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,82 @@
|
|
|
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
|
+
var _StartChatFailureType = require("../../contexts/common/StartChatFailureType");
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
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); }
|
|
22
|
+
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; }
|
|
23
|
+
const StartChatErrorPaneStateful = startChatErrorPaneProps => {
|
|
24
|
+
var _startChatErrorPanePr, _startChatErrorPanePr2, _startChatErrorPanePr3, _startChatErrorPanePr4, _startChatErrorPanePr5, _startChatErrorPanePr6, _startChatErrorPanePr7, _startChatErrorPanePr8, _startChatErrorPanePr9, _startChatErrorPanePr10, _startChatErrorPanePr11;
|
|
25
|
+
const [state] = (0, _useChatContextStore.default)();
|
|
26
|
+
const generalStyleProps = Object.assign({}, _defaultStartChatErrorPaneGeneralStyleProps.defaultStartChatErrorPaneGeneralStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr === void 0 ? void 0 : _startChatErrorPanePr.generalStyleProps);
|
|
27
|
+
const titleStyleProps = Object.assign({}, _defaultStartChatErrorPaneTitleStyleProps.defaultStartChatErrorPaneTitleStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr2 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr2 === void 0 ? void 0 : _startChatErrorPanePr2.titleStyleProps);
|
|
28
|
+
const subtitleStyleProps = Object.assign({}, _defaultStartChatErrorPaneSubtitleStyleProps.defaultStartChatErrorPaneSubtitleStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr3 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr3 === void 0 ? void 0 : _startChatErrorPanePr3.subtitleStyleProps);
|
|
29
|
+
const iconStyleProps = Object.assign({}, _defaultStartChatErrorPaneIconStyleProps.defaultStartChatErrorPaneIconStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr4 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr4 === void 0 ? void 0 : _startChatErrorPanePr4.iconStyleProps);
|
|
30
|
+
const iconImageProps = Object.assign({}, _defaultStartChatErrorPaneIconImageProps.defaultStartChatErrorPaneIconImageStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr5 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr5 === void 0 ? void 0 : _startChatErrorPanePr5.iconImageProps);
|
|
31
|
+
const errorUIStyleProps = {
|
|
32
|
+
generalStyleProps: generalStyleProps,
|
|
33
|
+
titleStyleProps: titleStyleProps,
|
|
34
|
+
subtitleStyleProps: subtitleStyleProps,
|
|
35
|
+
iconStyleProps: iconStyleProps,
|
|
36
|
+
iconImageProps: iconImageProps
|
|
37
|
+
};
|
|
38
|
+
let errorPaneTitleText;
|
|
39
|
+
let errorPaneSubtitleText;
|
|
40
|
+
switch (state.domainStates.startChatFailureType) {
|
|
41
|
+
case _StartChatFailureType.StartChatFailureType.Unauthorized:
|
|
42
|
+
errorPaneTitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr6 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr6 === void 0 ? void 0 : _startChatErrorPanePr6.unauthorizedTitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorUnauthorizedTitleText;
|
|
43
|
+
errorPaneSubtitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr7 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr7 === void 0 ? void 0 : _startChatErrorPanePr7.unauthorizedSubtitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorUnauthorizedSubtitleText;
|
|
44
|
+
break;
|
|
45
|
+
case _StartChatFailureType.StartChatFailureType.AuthSetupError:
|
|
46
|
+
errorPaneTitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr8 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr8 === void 0 ? void 0 : _startChatErrorPanePr8.authSetupErrorTitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorAuthSetupErrorTitleText;
|
|
47
|
+
errorPaneSubtitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr9 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr9 === void 0 ? void 0 : _startChatErrorPanePr9.authSetupErrorSubtitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorAuthSetupErrorSubtitleText;
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
errorPaneTitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr10 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr10 === void 0 ? void 0 : _startChatErrorPanePr10.titleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorTitleText;
|
|
51
|
+
errorPaneSubtitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr11 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr11 === void 0 ? void 0 : _startChatErrorPanePr11.subtitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorSubtitleText;
|
|
52
|
+
}
|
|
53
|
+
const errorUIControlProps = {
|
|
54
|
+
id: _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorPaneId,
|
|
55
|
+
dir: state.domainStates.globalDir,
|
|
56
|
+
hideSpinner: true,
|
|
57
|
+
hideSpinnerText: true,
|
|
58
|
+
...(startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : startChatErrorPaneProps.controlProps),
|
|
59
|
+
titleText: errorPaneTitleText,
|
|
60
|
+
subtitleText: errorPaneSubtitleText
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Move focus to the first button
|
|
64
|
+
(0, _react.useEffect)(() => {
|
|
65
|
+
const firstElement = (0, _utils.findAllFocusableElement)(`#${state.domainStates.widgetElementId}`);
|
|
66
|
+
if (firstElement && firstElement[0]) {
|
|
67
|
+
firstElement[0].focus();
|
|
68
|
+
}
|
|
69
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
70
|
+
Event: _TelemetryConstants.TelemetryEvent.StartChatErrorPaneLoaded,
|
|
71
|
+
Description: "Start chat error pane loaded."
|
|
72
|
+
});
|
|
73
|
+
}, []);
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.LoadingPane, {
|
|
75
|
+
componentOverrides: startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : startChatErrorPaneProps.componentOverrides,
|
|
76
|
+
controlProps: errorUIControlProps,
|
|
77
|
+
styleProps: errorUIStyleProps
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
exports.StartChatErrorPaneStateful = StartChatErrorPaneStateful;
|
|
81
|
+
var _default = StartChatErrorPaneStateful;
|
|
82
|
+
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";
|