@microsoft/omnichannel-chat-widget 1.5.1-main.76c6a71 → 1.5.1-main.7897747
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 +31 -8
- package/lib/cjs/common/telemetry/TelemetryConstants.js +3 -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 +41 -7
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +16 -84
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +220 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +52 -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/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 +26 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +3 -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 +40 -7
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +17 -85
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +213 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +55 -19
- 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/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 +29 -4
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -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/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 +5 -5
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +0 -71
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +0 -56
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +0 -190
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +0 -82
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.spec.js +0 -342
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +0 -69
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +0 -54
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +0 -188
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +0 -80
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.spec.js +0 -338
- package/lib/types/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.d.ts +0 -1
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.d.ts +0 -1
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +0 -4
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +0 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.spec.d.ts +0 -1
- /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
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Constants = require("../../../../../common/Constants");
|
|
4
|
-
var _WebChatActionType = require("../../enums/WebChatActionType");
|
|
5
|
-
var _messageSequenceIdOverrideMiddleware = _interopRequireDefault(require("./messageSequenceIdOverrideMiddleware"));
|
|
6
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
|
|
9
|
-
describe("messageSequenceIdOverrideMiddleware", () => {
|
|
10
|
-
it("sequenceId is overrided", () => {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
const next = args => args;
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
const dispatch = () => {
|
|
15
|
-
return 1;
|
|
16
|
-
};
|
|
17
|
-
const action = {
|
|
18
|
-
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY,
|
|
19
|
-
payload: {
|
|
20
|
-
text: "test-text",
|
|
21
|
-
activity: {
|
|
22
|
-
channelId: "ACS_CHANNEL",
|
|
23
|
-
from: {
|
|
24
|
-
role: "user"
|
|
25
|
-
},
|
|
26
|
-
channelData: {
|
|
27
|
-
metadata: {
|
|
28
|
-
"OriginalMessageId": "1683742135918"
|
|
29
|
-
},
|
|
30
|
-
"webchat:sequence-id": 12345
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
36
|
-
let resultValue;
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
38
|
-
const channelData = middleware.payload.activity.channelData;
|
|
39
|
-
Object.keys(channelData).forEach(function (key) {
|
|
40
|
-
if (key === _Constants.Constants.WebchatSequenceIdAttribute) {
|
|
41
|
-
resultValue = channelData[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
expect(resultValue).toEqual(1683742135918);
|
|
45
|
-
});
|
|
46
|
-
it("sequenceId is not overrided due to empty string for originalID", () => {
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
-
const next = args => args;
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
-
const dispatch = () => {
|
|
51
|
-
return 1;
|
|
52
|
-
};
|
|
53
|
-
const action = {
|
|
54
|
-
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY,
|
|
55
|
-
payload: {
|
|
56
|
-
text: "test-text",
|
|
57
|
-
activity: {
|
|
58
|
-
channelId: "ACS_CHANNEL",
|
|
59
|
-
from: {
|
|
60
|
-
role: "user"
|
|
61
|
-
},
|
|
62
|
-
channelData: {
|
|
63
|
-
metadata: {
|
|
64
|
-
"OriginalMessageId": ""
|
|
65
|
-
},
|
|
66
|
-
"webchat:sequence-id": 12345
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
72
|
-
let resultValue;
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
74
|
-
const channelData = middleware.payload.activity.channelData;
|
|
75
|
-
Object.keys(channelData).forEach(function (key) {
|
|
76
|
-
if (key === _Constants.Constants.WebchatSequenceIdAttribute) {
|
|
77
|
-
resultValue = channelData[key];
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
expect(resultValue).toEqual(12345);
|
|
81
|
-
});
|
|
82
|
-
it("sequenceId is not overrided, due to OriginalMessageId being not a string of numbers ", () => {
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
-
const next = args => args;
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
const dispatch = () => {
|
|
87
|
-
return 1;
|
|
88
|
-
};
|
|
89
|
-
const action = {
|
|
90
|
-
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY,
|
|
91
|
-
payload: {
|
|
92
|
-
text: "test-text",
|
|
93
|
-
activity: {
|
|
94
|
-
channelId: "ACS_CHANNEL",
|
|
95
|
-
from: {
|
|
96
|
-
role: "user"
|
|
97
|
-
},
|
|
98
|
-
channelData: {
|
|
99
|
-
metadata: {
|
|
100
|
-
"OriginalMessageId": "abcdf"
|
|
101
|
-
},
|
|
102
|
-
"webchat:sequence-id": 12345
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
108
|
-
let resultValue;
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
110
|
-
const channelData = middleware.payload.activity.channelData;
|
|
111
|
-
Object.keys(channelData).forEach(function (key) {
|
|
112
|
-
if (key === _Constants.Constants.WebchatSequenceIdAttribute) {
|
|
113
|
-
resultValue = channelData[key];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
expect(resultValue).toEqual(12345);
|
|
117
|
-
});
|
|
118
|
-
it("no changes since webchat id is not present", () => {
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
-
const next = args => args;
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
|
-
const dispatch = () => {
|
|
123
|
-
return 1;
|
|
124
|
-
};
|
|
125
|
-
const payloadExpected = {
|
|
126
|
-
payload: {
|
|
127
|
-
text: "test-text",
|
|
128
|
-
activity: {
|
|
129
|
-
channelId: "ACS_CHANNEL",
|
|
130
|
-
from: {
|
|
131
|
-
role: "user"
|
|
132
|
-
},
|
|
133
|
-
channelData: {
|
|
134
|
-
metadata: {
|
|
135
|
-
"OriginalMessageId": "123456789"
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
const action = {
|
|
142
|
-
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY,
|
|
143
|
-
payload: {
|
|
144
|
-
text: "test-text",
|
|
145
|
-
activity: {
|
|
146
|
-
channelId: "ACS_CHANNEL",
|
|
147
|
-
from: {
|
|
148
|
-
role: "user"
|
|
149
|
-
},
|
|
150
|
-
channelData: {
|
|
151
|
-
metadata: {
|
|
152
|
-
"OriginalMessageId": "123456789"
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
159
|
-
expect(middleware.payload).toEqual(payloadExpected.payload);
|
|
160
|
-
});
|
|
161
|
-
it("no changes since OriginalMessageId is not present", () => {
|
|
162
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
|
-
const next = args => args;
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
165
|
-
const dispatch = () => {
|
|
166
|
-
return 1;
|
|
167
|
-
};
|
|
168
|
-
const payloadExpected = {
|
|
169
|
-
payload: {
|
|
170
|
-
text: "test-text",
|
|
171
|
-
activity: {
|
|
172
|
-
channelId: "ACS_CHANNEL",
|
|
173
|
-
from: {
|
|
174
|
-
role: "user"
|
|
175
|
-
},
|
|
176
|
-
channelData: {
|
|
177
|
-
metadata: {},
|
|
178
|
-
"webchat:sequence-id": 12345
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
const action = {
|
|
184
|
-
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY,
|
|
185
|
-
payload: {
|
|
186
|
-
text: "test-text",
|
|
187
|
-
activity: {
|
|
188
|
-
channelId: "ACS_CHANNEL",
|
|
189
|
-
from: {
|
|
190
|
-
role: "user"
|
|
191
|
-
},
|
|
192
|
-
channelData: {
|
|
193
|
-
metadata: {},
|
|
194
|
-
"webchat:sequence-id": 12345
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
200
|
-
expect(middleware.payload).toEqual(payloadExpected.payload);
|
|
201
|
-
});
|
|
202
|
-
it("no override, since the type of message is not incoming activity", () => {
|
|
203
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
204
|
-
const next = args => args;
|
|
205
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
|
-
const dispatch = () => {
|
|
207
|
-
return 1;
|
|
208
|
-
};
|
|
209
|
-
const action = {
|
|
210
|
-
type: "something else",
|
|
211
|
-
payload: {
|
|
212
|
-
text: "test-text",
|
|
213
|
-
activity: {
|
|
214
|
-
channelId: "ACS_CHANNEL",
|
|
215
|
-
from: {
|
|
216
|
-
role: "user"
|
|
217
|
-
},
|
|
218
|
-
channelData: {
|
|
219
|
-
metadata: {
|
|
220
|
-
"OriginalMessageId": "1683742135918"
|
|
221
|
-
},
|
|
222
|
-
"webchat:sequence-id": 12345
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
228
|
-
let resultValue;
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
230
|
-
const channelData = middleware.payload.activity.channelData;
|
|
231
|
-
Object.keys(channelData).forEach(function (key) {
|
|
232
|
-
if (key === _Constants.Constants.WebchatSequenceIdAttribute) {
|
|
233
|
-
resultValue = channelData[key];
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
expect(resultValue).toEqual(12345);
|
|
237
|
-
});
|
|
238
|
-
it("no override, since the channel is not ACS", () => {
|
|
239
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
|
-
const next = args => args;
|
|
241
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
-
const dispatch = () => {
|
|
243
|
-
return 1;
|
|
244
|
-
};
|
|
245
|
-
const action = {
|
|
246
|
-
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY,
|
|
247
|
-
payload: {
|
|
248
|
-
text: "test-text",
|
|
249
|
-
activity: {
|
|
250
|
-
channelId: "something_else",
|
|
251
|
-
from: {
|
|
252
|
-
role: "user"
|
|
253
|
-
},
|
|
254
|
-
channelData: {
|
|
255
|
-
metadata: {
|
|
256
|
-
"OriginalMessageId": "1683742135918"
|
|
257
|
-
},
|
|
258
|
-
"webchat:sequence-id": 12345
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
264
|
-
let resultValue;
|
|
265
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
266
|
-
const channelData = middleware.payload.activity.channelData;
|
|
267
|
-
Object.keys(channelData).forEach(function (key) {
|
|
268
|
-
if (key === _Constants.Constants.WebchatSequenceIdAttribute) {
|
|
269
|
-
resultValue = channelData[key];
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
expect(resultValue).toEqual(12345);
|
|
273
|
-
});
|
|
274
|
-
it("no override, since the channel channelData is not present", () => {
|
|
275
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
276
|
-
const next = args => args;
|
|
277
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
278
|
-
const dispatch = () => {
|
|
279
|
-
return 1;
|
|
280
|
-
};
|
|
281
|
-
const action = {
|
|
282
|
-
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY,
|
|
283
|
-
payload: {
|
|
284
|
-
text: "test-text channel data is not present",
|
|
285
|
-
activity: {
|
|
286
|
-
channelId: "ACS_CHANNEL",
|
|
287
|
-
from: {
|
|
288
|
-
role: "user"
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
294
|
-
expect(middleware.payload).toEqual(action.payload);
|
|
295
|
-
});
|
|
296
|
-
it("no override, since channelData is empty object", () => {
|
|
297
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
298
|
-
const next = args => args;
|
|
299
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
300
|
-
const dispatch = () => {
|
|
301
|
-
return 1;
|
|
302
|
-
};
|
|
303
|
-
const action = {
|
|
304
|
-
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY,
|
|
305
|
-
payload: {
|
|
306
|
-
text: "test-text channel data empty",
|
|
307
|
-
activity: {
|
|
308
|
-
channelId: "ACS_CHANNEL",
|
|
309
|
-
from: {
|
|
310
|
-
role: "user"
|
|
311
|
-
},
|
|
312
|
-
channelData: {}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
317
|
-
expect(middleware.payload).toEqual(action.payload);
|
|
318
|
-
});
|
|
319
|
-
it("no override, since channelData null", () => {
|
|
320
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
321
|
-
const next = args => args;
|
|
322
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
323
|
-
const dispatch = () => {
|
|
324
|
-
return 1;
|
|
325
|
-
};
|
|
326
|
-
const action = {
|
|
327
|
-
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY,
|
|
328
|
-
payload: {
|
|
329
|
-
text: "test-channel Data null",
|
|
330
|
-
activity: {
|
|
331
|
-
channelId: "ACS_CHANNEL",
|
|
332
|
-
from: {
|
|
333
|
-
role: "user"
|
|
334
|
-
},
|
|
335
|
-
channelData: null
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
const middleware = (0, _messageSequenceIdOverrideMiddleware.default)(dispatch)(next)(action);
|
|
340
|
-
expect(middleware.payload).toEqual(action.payload);
|
|
341
|
-
});
|
|
342
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
|
|
2
|
-
import { cleanup } from "@testing-library/react";
|
|
3
|
-
jest.mock("@microsoft/omnichannel-chat-sdk");
|
|
4
|
-
describe("EmailTranscriptPaneStateful unit test", () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
cleanup;
|
|
7
|
-
jest.resetAllMocks();
|
|
8
|
-
});
|
|
9
|
-
it("Method emailLiveChatTranscript is called", async () => {
|
|
10
|
-
const omnichannelConfig = {
|
|
11
|
-
orgUrl: "",
|
|
12
|
-
orgId: "",
|
|
13
|
-
widgetId: ""
|
|
14
|
-
};
|
|
15
|
-
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
|
|
16
|
-
jest.spyOn(chatSDK, "emailLiveChatTranscript").mockResolvedValue(Promise.resolve());
|
|
17
|
-
const chatTranscriptBody = {
|
|
18
|
-
emailAddress: "sample@microsoft.com",
|
|
19
|
-
attachmentMessage: "sample",
|
|
20
|
-
locale: "sample"
|
|
21
|
-
};
|
|
22
|
-
try {
|
|
23
|
-
await chatSDK.emailLiveChatTranscript(chatTranscriptBody);
|
|
24
|
-
expect(chatSDK.emailLiveChatTranscript).toHaveBeenCalledTimes(1);
|
|
25
|
-
// eslint-disable-next-line no-empty
|
|
26
|
-
} catch (ex) {}
|
|
27
|
-
});
|
|
28
|
-
it("Method emailLiveChatTranscript throws exception", async () => {
|
|
29
|
-
const errorMessage = "Error";
|
|
30
|
-
const omnichannelConfig = {
|
|
31
|
-
orgUrl: "",
|
|
32
|
-
orgId: "",
|
|
33
|
-
widgetId: ""
|
|
34
|
-
};
|
|
35
|
-
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
|
|
36
|
-
jest.spyOn(chatSDK, "emailLiveChatTranscript").mockRejectedValue(new Error(errorMessage));
|
|
37
|
-
const chatTranscriptBody = {
|
|
38
|
-
emailAddress: "sample@microsoft.com",
|
|
39
|
-
attachmentMessage: "sample",
|
|
40
|
-
locale: "sample"
|
|
41
|
-
};
|
|
42
|
-
try {
|
|
43
|
-
await chatSDK.emailLiveChatTranscript(chatTranscriptBody);
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
-
} catch (ex) {
|
|
46
|
-
expect(ex.message).toEqual(errorMessage);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
it("Method emailLiveChatTranscript undefined throws exception", async () => {
|
|
50
|
-
const errorMessage = "Error";
|
|
51
|
-
const omnichannelConfig = {
|
|
52
|
-
orgUrl: "",
|
|
53
|
-
orgId: "",
|
|
54
|
-
widgetId: ""
|
|
55
|
-
};
|
|
56
|
-
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
|
|
57
|
-
const chatTranscriptBody = {
|
|
58
|
-
emailAddress: "sample@microsoft.com",
|
|
59
|
-
attachmentMessage: "sample",
|
|
60
|
-
locale: "sample"
|
|
61
|
-
};
|
|
62
|
-
try {
|
|
63
|
-
await chatSDK.emailLiveChatTranscript(chatTranscriptBody);
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
-
} catch (ex) {
|
|
66
|
-
expect(ex.message).toEqual(errorMessage);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
|
|
2
|
-
import { cleanup } from "@testing-library/react";
|
|
3
|
-
jest.mock("@microsoft/omnichannel-chat-sdk");
|
|
4
|
-
describe("DownloadTranscriptStateful unit test", () => {
|
|
5
|
-
afterEach(() => {
|
|
6
|
-
cleanup;
|
|
7
|
-
jest.resetAllMocks();
|
|
8
|
-
});
|
|
9
|
-
it("Method getLiveChatTranscript is called", async () => {
|
|
10
|
-
const omnichannelConfig = {
|
|
11
|
-
orgUrl: "",
|
|
12
|
-
orgId: "",
|
|
13
|
-
widgetId: ""
|
|
14
|
-
};
|
|
15
|
-
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
|
|
16
|
-
jest.spyOn(chatSDK, "getLiveChatTranscript").mockResolvedValue(Promise.resolve());
|
|
17
|
-
try {
|
|
18
|
-
await chatSDK.getLiveChatTranscript();
|
|
19
|
-
expect(chatSDK.getLiveChatTranscript).toHaveBeenCalledTimes(1);
|
|
20
|
-
// eslint-disable-next-line no-empty
|
|
21
|
-
} catch (ex) {}
|
|
22
|
-
});
|
|
23
|
-
it("Method getLiveChatTranscript throws exception", async () => {
|
|
24
|
-
const errorMessage = "Error";
|
|
25
|
-
const omnichannelConfig = {
|
|
26
|
-
orgUrl: "",
|
|
27
|
-
orgId: "",
|
|
28
|
-
widgetId: ""
|
|
29
|
-
};
|
|
30
|
-
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
|
|
31
|
-
jest.spyOn(chatSDK, "getLiveChatTranscript").mockRejectedValue(new Error(errorMessage));
|
|
32
|
-
try {
|
|
33
|
-
await chatSDK.getLiveChatTranscript();
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
-
} catch (ex) {
|
|
36
|
-
expect(ex.message).toEqual(errorMessage);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
it("Method getLiveChatTranscript undefined throws exception", async () => {
|
|
40
|
-
const errorMessage = "Error";
|
|
41
|
-
const omnichannelConfig = {
|
|
42
|
-
orgUrl: "",
|
|
43
|
-
orgId: "",
|
|
44
|
-
widgetId: ""
|
|
45
|
-
};
|
|
46
|
-
const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
|
|
47
|
-
try {
|
|
48
|
-
await chatSDK.getLiveChatTranscript();
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
-
} catch (ex) {
|
|
51
|
-
expect(ex.message).toEqual(errorMessage);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { Constants } from "../../../../../common/Constants";
|
|
2
|
-
import { DirectLineActivityType } from "../../enums/DirectLineActivityType";
|
|
3
|
-
import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
|
|
4
|
-
import { MessageTypes } from "../../enums/MessageType";
|
|
5
|
-
import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
|
|
6
|
-
import { createActivityMiddleware } from "./activityMiddleware";
|
|
7
|
-
describe("activityMiddleware test", () => {
|
|
8
|
-
it("createActivityMiddleware() with Channel role sender should returns nothing", () => {
|
|
9
|
-
spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
10
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
11
|
-
const args = {
|
|
12
|
-
activity: {
|
|
13
|
-
channelData: {
|
|
14
|
-
type: MessageTypes.Thread
|
|
15
|
-
},
|
|
16
|
-
from: {
|
|
17
|
-
role: DirectLineSenderRole.Channel
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const results = createActivityMiddleware()()(next)(args);
|
|
22
|
-
expect(results()).toEqual(false);
|
|
23
|
-
expect(TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(1);
|
|
24
|
-
});
|
|
25
|
-
it("createActivityMiddleware() with Hidden tag should return nothing", () => {
|
|
26
|
-
spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
27
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
28
|
-
const args = {
|
|
29
|
-
activity: {
|
|
30
|
-
channelData: {
|
|
31
|
-
tags: [Constants.hiddenTag]
|
|
32
|
-
},
|
|
33
|
-
from: {
|
|
34
|
-
role: DirectLineSenderRole.User
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const results = createActivityMiddleware()()(next)(args);
|
|
39
|
-
expect(results()).toEqual(false);
|
|
40
|
-
expect(TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(0);
|
|
41
|
-
});
|
|
42
|
-
it("createActivityMiddleware() with System tag should return system message", () => {
|
|
43
|
-
var _results$props, _results$props$danger;
|
|
44
|
-
spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
45
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
46
|
-
const systemMessage = "system message";
|
|
47
|
-
const args = {
|
|
48
|
-
activity: {
|
|
49
|
-
text: systemMessage,
|
|
50
|
-
channelData: {
|
|
51
|
-
tags: [Constants.systemMessageTag]
|
|
52
|
-
},
|
|
53
|
-
from: {
|
|
54
|
-
role: DirectLineSenderRole.User
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const results = createActivityMiddleware()()(next)(args);
|
|
59
|
-
expect(TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(0);
|
|
60
|
-
expect((_results$props = results().props) === null || _results$props === void 0 ? void 0 : (_results$props$danger = _results$props.dangerouslySetInnerHTML) === null || _results$props$danger === void 0 ? void 0 : _results$props$danger.__html).toEqual(systemMessage);
|
|
61
|
-
});
|
|
62
|
-
it("createActivityMiddleware() should escape html texts to prevent XSS attacks", () => {
|
|
63
|
-
var _results$props2, _results$props2$dange;
|
|
64
|
-
spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
65
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
66
|
-
const systemMessage = "<img src='' onerror=\"alert('XSS attack')\"/>";
|
|
67
|
-
const args = {
|
|
68
|
-
activity: {
|
|
69
|
-
text: systemMessage,
|
|
70
|
-
channelData: {
|
|
71
|
-
tags: [Constants.systemMessageTag]
|
|
72
|
-
},
|
|
73
|
-
from: {
|
|
74
|
-
role: DirectLineSenderRole.User
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
const results = createActivityMiddleware()()(next)(args);
|
|
79
|
-
expect(TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(0);
|
|
80
|
-
expect((_results$props2 = results().props) === null || _results$props2 === void 0 ? void 0 : (_results$props2$dange = _results$props2.dangerouslySetInnerHTML) === null || _results$props2$dange === void 0 ? void 0 : _results$props2$dange.__html).toEqual("<img src='' onerror="alert('XSS attack')"/>");
|
|
81
|
-
});
|
|
82
|
-
it("createActivityMiddleware() with QueuePosition tag should log QueuePosition message", () => {
|
|
83
|
-
spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
84
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
85
|
-
const systemMessage = "system message";
|
|
86
|
-
const args = {
|
|
87
|
-
activity: {
|
|
88
|
-
text: systemMessage,
|
|
89
|
-
channelData: {
|
|
90
|
-
tags: [Constants.systemMessageTag, Constants.queuePositionMessageTag]
|
|
91
|
-
},
|
|
92
|
-
from: {
|
|
93
|
-
role: DirectLineSenderRole.User
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
createActivityMiddleware()()(next)(args);
|
|
98
|
-
expect(TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(1);
|
|
99
|
-
});
|
|
100
|
-
it("createActivityMiddleware() with same clientmessageid with next activity should return nothing", () => {
|
|
101
|
-
spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
102
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
103
|
-
const systemMessage = "system message";
|
|
104
|
-
const args = {
|
|
105
|
-
activity: {
|
|
106
|
-
text: systemMessage,
|
|
107
|
-
channelData: {
|
|
108
|
-
tags: [Constants.systemMessageTag],
|
|
109
|
-
clientmessageid: "1234"
|
|
110
|
-
},
|
|
111
|
-
from: {
|
|
112
|
-
role: DirectLineSenderRole.User
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
nextVisibleActivity: {
|
|
116
|
-
channelData: {
|
|
117
|
-
clientmessageid: "1234"
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
const results = createActivityMiddleware()()(next)(args);
|
|
122
|
-
expect(results()).toEqual(false);
|
|
123
|
-
});
|
|
124
|
-
it("createActivityMiddleware() with same messageid with next activity should return nothing", () => {
|
|
125
|
-
spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
126
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
127
|
-
const systemMessage = "system message";
|
|
128
|
-
const args = {
|
|
129
|
-
activity: {
|
|
130
|
-
text: systemMessage,
|
|
131
|
-
channelData: {
|
|
132
|
-
tags: [Constants.systemMessageTag]
|
|
133
|
-
},
|
|
134
|
-
from: {
|
|
135
|
-
role: DirectLineSenderRole.User
|
|
136
|
-
},
|
|
137
|
-
messageid: "1234"
|
|
138
|
-
},
|
|
139
|
-
nextVisibleActivity: {
|
|
140
|
-
messageid: "1234"
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
const results = createActivityMiddleware()()(next)(args);
|
|
144
|
-
expect(results()).toEqual(false);
|
|
145
|
-
});
|
|
146
|
-
it("createActivityMiddleware() should render normal user messages", () => {
|
|
147
|
-
var _results$props3, _results$props3$child, _results$props3$child2;
|
|
148
|
-
spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
149
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
150
|
-
const userMessage = "Hello World";
|
|
151
|
-
const args = {
|
|
152
|
-
activity: {
|
|
153
|
-
text: userMessage,
|
|
154
|
-
channelId: "webchat",
|
|
155
|
-
channelData: {
|
|
156
|
-
isHtmlEncoded: false
|
|
157
|
-
},
|
|
158
|
-
from: {
|
|
159
|
-
role: DirectLineSenderRole.User
|
|
160
|
-
},
|
|
161
|
-
type: DirectLineActivityType.Message
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
const results = createActivityMiddleware()()(next)(args);
|
|
165
|
-
expect((_results$props3 = results().props) === null || _results$props3 === void 0 ? void 0 : (_results$props3$child = _results$props3.children) === null || _results$props3$child === void 0 ? void 0 : (_results$props3$child2 = _results$props3$child.activity) === null || _results$props3$child2 === void 0 ? void 0 : _results$props3$child2.text).toEqual(userMessage);
|
|
166
|
-
});
|
|
167
|
-
it("createActivityMiddleware() should not render typing messages", () => {
|
|
168
|
-
var _results$activity;
|
|
169
|
-
spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
170
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
171
|
-
const userMessage = "Hello World";
|
|
172
|
-
const args = {
|
|
173
|
-
activity: {
|
|
174
|
-
text: userMessage,
|
|
175
|
-
channelId: "webchat",
|
|
176
|
-
channelData: {
|
|
177
|
-
isHtmlEncoded: false
|
|
178
|
-
},
|
|
179
|
-
from: {
|
|
180
|
-
role: DirectLineSenderRole.User
|
|
181
|
-
},
|
|
182
|
-
type: DirectLineActivityType.Typing
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
const results = createActivityMiddleware()()(next)(args);
|
|
186
|
-
expect((_results$activity = results().activity) === null || _results$activity === void 0 ? void 0 : _results$activity.text).toEqual(userMessage);
|
|
187
|
-
});
|
|
188
|
-
});
|