@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
|
@@ -7,40 +7,41 @@ export declare enum LiveChatWidgetActionType {
|
|
|
7
7
|
SET_CONVERSATION_STATE = 5,
|
|
8
8
|
SET_PREVIOUS_FOCUSED_ELEMENT_ID = 6,
|
|
9
9
|
SET_START_CHAT_FAILING = 7,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
10
|
+
SET_START_CHAT_FAILURE_TYPE = 8,
|
|
11
|
+
SET_OUTSIDE_OPERATING_HOURS = 9,
|
|
12
|
+
SET_PRE_CHAT_SURVEY_RESPONSE = 10,
|
|
13
|
+
SET_CUSTOM_CONTEXT = 11,
|
|
14
|
+
SET_SHOW_CONFIRMATION = 12,
|
|
15
|
+
SET_SHOW_EMAIL_TRANSCRIPT_PANE = 13,
|
|
16
|
+
SET_PRECHAT_RESPONSE_EMAIL = 14,
|
|
17
|
+
SET_AUDIO_NOTIFICATION = 15,
|
|
18
|
+
SET_E2VV_ENABLED = 16,
|
|
19
|
+
SET_POST_CHAT_CONTEXT = 17,
|
|
20
|
+
SHOW_CALLING_CONTAINER = 18,
|
|
21
|
+
SET_INCOMING_CALL = 19,
|
|
22
|
+
DISABLE_VIDEO_CALL = 20,
|
|
23
|
+
DISABLE_LOCAL_VIDEO = 21,
|
|
24
|
+
DISABLE_REMOTE_VIDEO = 22,
|
|
25
|
+
SET_CHAT_TOKEN = 23,
|
|
26
|
+
SET_START_CHAT_BUTTON_DISPLAY = 24,
|
|
27
|
+
SET_PROACTIVE_CHAT_PARAMS = 25,
|
|
28
|
+
SET_TELEMETRY_DATA = 26,
|
|
29
|
+
SET_RECONNECT_ID = 27,
|
|
30
|
+
SET_UNREAD_MESSAGE_COUNT = 28,
|
|
31
|
+
SET_FOCUS_CHAT_BUTTON = 29,
|
|
32
|
+
SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED = 30,
|
|
33
|
+
SET_CONVERSATION_ENDED_BY = 31,
|
|
34
|
+
SET_WIDGET_STATE = 32,
|
|
35
|
+
SET_LIVE_CHAT_CONTEXT = 33,
|
|
36
|
+
SET_BOT_OAUTH_SIGNIN_ID = 34,
|
|
37
|
+
SET_WIDGET_SIZE = 35,
|
|
38
|
+
SET_WIDGET_INSTANCE_ID = 36,
|
|
39
|
+
SET_LIVE_CHAT_CONFIG = 37,
|
|
40
|
+
SET_POST_CHAT_WORKFLOW_IN_PROGRESS = 38,
|
|
41
|
+
SET_INITIAL_CHAT_SDK_REQUEST_ID = 39,
|
|
42
|
+
SET_SHOULD_USE_BOT_SURVEY = 40,
|
|
43
|
+
SET_CHAT_DISCONNECT_EVENT_RECEIVED = 41,
|
|
44
|
+
SET_SURVEY_MODE = 42,
|
|
45
|
+
SET_CONFIRMATION_STATE = 43,
|
|
46
|
+
SET_POST_CHAT_PARTICIPANT_TYPE = 44
|
|
46
47
|
}
|
|
@@ -6,6 +6,7 @@ export declare const shouldShowFooter: (state: ILiveChatWidgetContext) => boolea
|
|
|
6
6
|
export declare const shouldShowEmailTranscriptPane: (state: ILiveChatWidgetContext) => boolean;
|
|
7
7
|
export declare const shouldShowWebChatContainer: (state: ILiveChatWidgetContext) => boolean;
|
|
8
8
|
export declare const shouldShowLoadingPane: (state: ILiveChatWidgetContext) => boolean;
|
|
9
|
+
export declare const shouldShowStartChatErrorPane: (state: ILiveChatWidgetContext) => boolean;
|
|
9
10
|
export declare const shouldShowReconnectChatPane: (state: ILiveChatWidgetContext) => boolean;
|
|
10
11
|
export declare const shouldShowPostChatLoadingPane: (state: ILiveChatWidgetContext) => boolean;
|
|
11
12
|
export declare const shouldShowOutOfOfficeHoursPane: (state: ILiveChatWidgetContext) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.5.1-main.
|
|
3
|
+
"version": "1.5.1-main.7897747",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"webpack-cli": "^4.9.2"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@microsoft/omnichannel-chat-components": "^1.0
|
|
78
|
-
"@microsoft/omnichannel-chat-sdk": "1.
|
|
77
|
+
"@microsoft/omnichannel-chat-components": "^1.1.0",
|
|
78
|
+
"@microsoft/omnichannel-chat-sdk": "1.6.2",
|
|
79
79
|
"abort-controller-es5": "^2.0.1",
|
|
80
80
|
"dompurify": "^2.3.4",
|
|
81
81
|
"markdown-it": "^12.3.2",
|
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
"test:e2e:build": "yarn build-sample && cd automation_tests && yarn test",
|
|
98
98
|
"test:visual": "jest -c jest.config.visual.cjs",
|
|
99
99
|
"test:all": "yarn test:unit && yarn test:visual",
|
|
100
|
-
"build:esm": "babel ./src --config-file ./babel.esm.config.json --out-dir lib/esm --extensions .ts,.js,.tsx --ignore **/*.test.ts,**/*.stories.tsx,**/*.test.tsx",
|
|
101
|
-
"build:cjs": "babel ./src --config-file ./babel.config.json --out-dir lib/cjs --extensions .ts,.js,.tsx --ignore **/*.test.ts,**/*.stories.tsx,**/*.test.tsx",
|
|
100
|
+
"build:esm": "babel ./src --config-file ./babel.esm.config.json --out-dir lib/esm --extensions .ts,.js,.tsx --ignore **/*.test.ts,**/*.stories.tsx,**/*.test.tsx,**/*.spec.ts,**/*.spec.tsx",
|
|
101
|
+
"build:cjs": "babel ./src --config-file ./babel.config.json --out-dir lib/cjs --extensions .ts,.js,.tsx --ignore **/*.test.ts,**/*.stories.tsx,**/*.test.tsx,**/*.spec.ts,**/*.spec.tsx",
|
|
102
102
|
"verify": "yarn install && yarn build-storybook && yarn test:all && yarn build && yarn storybook",
|
|
103
103
|
"testpack": "yarn build && yarn pack",
|
|
104
104
|
"build-sample": "yarn build && webpack --config ./webpack.config.cjs",
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
4
|
-
var _react = require("@testing-library/react");
|
|
5
|
-
jest.mock("@microsoft/omnichannel-chat-sdk");
|
|
6
|
-
describe("EmailTranscriptPaneStateful unit test", () => {
|
|
7
|
-
afterEach(() => {
|
|
8
|
-
_react.cleanup;
|
|
9
|
-
jest.resetAllMocks();
|
|
10
|
-
});
|
|
11
|
-
it("Method emailLiveChatTranscript is called", async () => {
|
|
12
|
-
const omnichannelConfig = {
|
|
13
|
-
orgUrl: "",
|
|
14
|
-
orgId: "",
|
|
15
|
-
widgetId: ""
|
|
16
|
-
};
|
|
17
|
-
const chatSDK = new _omnichannelChatSdk.OmnichannelChatSDK(omnichannelConfig);
|
|
18
|
-
jest.spyOn(chatSDK, "emailLiveChatTranscript").mockResolvedValue(Promise.resolve());
|
|
19
|
-
const chatTranscriptBody = {
|
|
20
|
-
emailAddress: "sample@microsoft.com",
|
|
21
|
-
attachmentMessage: "sample",
|
|
22
|
-
locale: "sample"
|
|
23
|
-
};
|
|
24
|
-
try {
|
|
25
|
-
await chatSDK.emailLiveChatTranscript(chatTranscriptBody);
|
|
26
|
-
expect(chatSDK.emailLiveChatTranscript).toHaveBeenCalledTimes(1);
|
|
27
|
-
// eslint-disable-next-line no-empty
|
|
28
|
-
} catch (ex) {}
|
|
29
|
-
});
|
|
30
|
-
it("Method emailLiveChatTranscript throws exception", async () => {
|
|
31
|
-
const errorMessage = "Error";
|
|
32
|
-
const omnichannelConfig = {
|
|
33
|
-
orgUrl: "",
|
|
34
|
-
orgId: "",
|
|
35
|
-
widgetId: ""
|
|
36
|
-
};
|
|
37
|
-
const chatSDK = new _omnichannelChatSdk.OmnichannelChatSDK(omnichannelConfig);
|
|
38
|
-
jest.spyOn(chatSDK, "emailLiveChatTranscript").mockRejectedValue(new Error(errorMessage));
|
|
39
|
-
const chatTranscriptBody = {
|
|
40
|
-
emailAddress: "sample@microsoft.com",
|
|
41
|
-
attachmentMessage: "sample",
|
|
42
|
-
locale: "sample"
|
|
43
|
-
};
|
|
44
|
-
try {
|
|
45
|
-
await chatSDK.emailLiveChatTranscript(chatTranscriptBody);
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
-
} catch (ex) {
|
|
48
|
-
expect(ex.message).toEqual(errorMessage);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
it("Method emailLiveChatTranscript undefined throws exception", async () => {
|
|
52
|
-
const errorMessage = "Error";
|
|
53
|
-
const omnichannelConfig = {
|
|
54
|
-
orgUrl: "",
|
|
55
|
-
orgId: "",
|
|
56
|
-
widgetId: ""
|
|
57
|
-
};
|
|
58
|
-
const chatSDK = new _omnichannelChatSdk.OmnichannelChatSDK(omnichannelConfig);
|
|
59
|
-
const chatTranscriptBody = {
|
|
60
|
-
emailAddress: "sample@microsoft.com",
|
|
61
|
-
attachmentMessage: "sample",
|
|
62
|
-
locale: "sample"
|
|
63
|
-
};
|
|
64
|
-
try {
|
|
65
|
-
await chatSDK.emailLiveChatTranscript(chatTranscriptBody);
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
-
} catch (ex) {
|
|
68
|
-
expect(ex.message).toEqual(errorMessage);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
4
|
-
var _react = require("@testing-library/react");
|
|
5
|
-
jest.mock("@microsoft/omnichannel-chat-sdk");
|
|
6
|
-
describe("DownloadTranscriptStateful unit test", () => {
|
|
7
|
-
afterEach(() => {
|
|
8
|
-
_react.cleanup;
|
|
9
|
-
jest.resetAllMocks();
|
|
10
|
-
});
|
|
11
|
-
it("Method getLiveChatTranscript is called", async () => {
|
|
12
|
-
const omnichannelConfig = {
|
|
13
|
-
orgUrl: "",
|
|
14
|
-
orgId: "",
|
|
15
|
-
widgetId: ""
|
|
16
|
-
};
|
|
17
|
-
const chatSDK = new _omnichannelChatSdk.OmnichannelChatSDK(omnichannelConfig);
|
|
18
|
-
jest.spyOn(chatSDK, "getLiveChatTranscript").mockResolvedValue(Promise.resolve());
|
|
19
|
-
try {
|
|
20
|
-
await chatSDK.getLiveChatTranscript();
|
|
21
|
-
expect(chatSDK.getLiveChatTranscript).toHaveBeenCalledTimes(1);
|
|
22
|
-
// eslint-disable-next-line no-empty
|
|
23
|
-
} catch (ex) {}
|
|
24
|
-
});
|
|
25
|
-
it("Method getLiveChatTranscript throws exception", async () => {
|
|
26
|
-
const errorMessage = "Error";
|
|
27
|
-
const omnichannelConfig = {
|
|
28
|
-
orgUrl: "",
|
|
29
|
-
orgId: "",
|
|
30
|
-
widgetId: ""
|
|
31
|
-
};
|
|
32
|
-
const chatSDK = new _omnichannelChatSdk.OmnichannelChatSDK(omnichannelConfig);
|
|
33
|
-
jest.spyOn(chatSDK, "getLiveChatTranscript").mockRejectedValue(new Error(errorMessage));
|
|
34
|
-
try {
|
|
35
|
-
await chatSDK.getLiveChatTranscript();
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
} catch (ex) {
|
|
38
|
-
expect(ex.message).toEqual(errorMessage);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
it("Method getLiveChatTranscript undefined throws exception", async () => {
|
|
42
|
-
const errorMessage = "Error";
|
|
43
|
-
const omnichannelConfig = {
|
|
44
|
-
orgUrl: "",
|
|
45
|
-
orgId: "",
|
|
46
|
-
widgetId: ""
|
|
47
|
-
};
|
|
48
|
-
const chatSDK = new _omnichannelChatSdk.OmnichannelChatSDK(omnichannelConfig);
|
|
49
|
-
try {
|
|
50
|
-
await chatSDK.getLiveChatTranscript();
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
-
} catch (ex) {
|
|
53
|
-
expect(ex.message).toEqual(errorMessage);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _Constants = require("../../../../../common/Constants");
|
|
4
|
-
var _DirectLineActivityType = require("../../enums/DirectLineActivityType");
|
|
5
|
-
var _DirectLineSenderRole = require("../../enums/DirectLineSenderRole");
|
|
6
|
-
var _MessageType = require("../../enums/MessageType");
|
|
7
|
-
var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
|
|
8
|
-
var _activityMiddleware = require("./activityMiddleware");
|
|
9
|
-
describe("activityMiddleware test", () => {
|
|
10
|
-
it("createActivityMiddleware() with Channel role sender should returns nothing", () => {
|
|
11
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
12
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
13
|
-
const args = {
|
|
14
|
-
activity: {
|
|
15
|
-
channelData: {
|
|
16
|
-
type: _MessageType.MessageTypes.Thread
|
|
17
|
-
},
|
|
18
|
-
from: {
|
|
19
|
-
role: _DirectLineSenderRole.DirectLineSenderRole.Channel
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
24
|
-
expect(results()).toEqual(false);
|
|
25
|
-
expect(_TelemetryHelper.TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(1);
|
|
26
|
-
});
|
|
27
|
-
it("createActivityMiddleware() with Hidden tag should return nothing", () => {
|
|
28
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
29
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
30
|
-
const args = {
|
|
31
|
-
activity: {
|
|
32
|
-
channelData: {
|
|
33
|
-
tags: [_Constants.Constants.hiddenTag]
|
|
34
|
-
},
|
|
35
|
-
from: {
|
|
36
|
-
role: _DirectLineSenderRole.DirectLineSenderRole.User
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
41
|
-
expect(results()).toEqual(false);
|
|
42
|
-
expect(_TelemetryHelper.TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(0);
|
|
43
|
-
});
|
|
44
|
-
it("createActivityMiddleware() with System tag should return system message", () => {
|
|
45
|
-
var _results$props, _results$props$danger;
|
|
46
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
47
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
48
|
-
const systemMessage = "system message";
|
|
49
|
-
const args = {
|
|
50
|
-
activity: {
|
|
51
|
-
text: systemMessage,
|
|
52
|
-
channelData: {
|
|
53
|
-
tags: [_Constants.Constants.systemMessageTag]
|
|
54
|
-
},
|
|
55
|
-
from: {
|
|
56
|
-
role: _DirectLineSenderRole.DirectLineSenderRole.User
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
61
|
-
expect(_TelemetryHelper.TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(0);
|
|
62
|
-
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);
|
|
63
|
-
});
|
|
64
|
-
it("createActivityMiddleware() should escape html texts to prevent XSS attacks", () => {
|
|
65
|
-
var _results$props2, _results$props2$dange;
|
|
66
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
67
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
68
|
-
const systemMessage = "<img src='' onerror=\"alert('XSS attack')\"/>";
|
|
69
|
-
const args = {
|
|
70
|
-
activity: {
|
|
71
|
-
text: systemMessage,
|
|
72
|
-
channelData: {
|
|
73
|
-
tags: [_Constants.Constants.systemMessageTag]
|
|
74
|
-
},
|
|
75
|
-
from: {
|
|
76
|
-
role: _DirectLineSenderRole.DirectLineSenderRole.User
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
81
|
-
expect(_TelemetryHelper.TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(0);
|
|
82
|
-
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')"/>");
|
|
83
|
-
});
|
|
84
|
-
it("createActivityMiddleware() with QueuePosition tag should log QueuePosition message", () => {
|
|
85
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
86
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
87
|
-
const systemMessage = "system message";
|
|
88
|
-
const args = {
|
|
89
|
-
activity: {
|
|
90
|
-
text: systemMessage,
|
|
91
|
-
channelData: {
|
|
92
|
-
tags: [_Constants.Constants.systemMessageTag, _Constants.Constants.queuePositionMessageTag]
|
|
93
|
-
},
|
|
94
|
-
from: {
|
|
95
|
-
role: _DirectLineSenderRole.DirectLineSenderRole.User
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
(0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
100
|
-
expect(_TelemetryHelper.TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(1);
|
|
101
|
-
});
|
|
102
|
-
it("createActivityMiddleware() with same clientmessageid with next activity should return nothing", () => {
|
|
103
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
104
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
105
|
-
const systemMessage = "system message";
|
|
106
|
-
const args = {
|
|
107
|
-
activity: {
|
|
108
|
-
text: systemMessage,
|
|
109
|
-
channelData: {
|
|
110
|
-
tags: [_Constants.Constants.systemMessageTag],
|
|
111
|
-
clientmessageid: "1234"
|
|
112
|
-
},
|
|
113
|
-
from: {
|
|
114
|
-
role: _DirectLineSenderRole.DirectLineSenderRole.User
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
nextVisibleActivity: {
|
|
118
|
-
channelData: {
|
|
119
|
-
clientmessageid: "1234"
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
124
|
-
expect(results()).toEqual(false);
|
|
125
|
-
});
|
|
126
|
-
it("createActivityMiddleware() with same messageid with next activity should return nothing", () => {
|
|
127
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
128
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
129
|
-
const systemMessage = "system message";
|
|
130
|
-
const args = {
|
|
131
|
-
activity: {
|
|
132
|
-
text: systemMessage,
|
|
133
|
-
channelData: {
|
|
134
|
-
tags: [_Constants.Constants.systemMessageTag]
|
|
135
|
-
},
|
|
136
|
-
from: {
|
|
137
|
-
role: _DirectLineSenderRole.DirectLineSenderRole.User
|
|
138
|
-
},
|
|
139
|
-
messageid: "1234"
|
|
140
|
-
},
|
|
141
|
-
nextVisibleActivity: {
|
|
142
|
-
messageid: "1234"
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
146
|
-
expect(results()).toEqual(false);
|
|
147
|
-
});
|
|
148
|
-
it("createActivityMiddleware() should render normal user messages", () => {
|
|
149
|
-
var _results$props3, _results$props3$child, _results$props3$child2;
|
|
150
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
151
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
152
|
-
const userMessage = "Hello World";
|
|
153
|
-
const args = {
|
|
154
|
-
activity: {
|
|
155
|
-
text: userMessage,
|
|
156
|
-
channelId: "webchat",
|
|
157
|
-
channelData: {
|
|
158
|
-
isHtmlEncoded: false
|
|
159
|
-
},
|
|
160
|
-
from: {
|
|
161
|
-
role: _DirectLineSenderRole.DirectLineSenderRole.User
|
|
162
|
-
},
|
|
163
|
-
type: _DirectLineActivityType.DirectLineActivityType.Message
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
167
|
-
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);
|
|
168
|
-
});
|
|
169
|
-
it("createActivityMiddleware() should not render typing messages", () => {
|
|
170
|
-
var _results$activity;
|
|
171
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
172
|
-
const next = args => () => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
173
|
-
const userMessage = "Hello World";
|
|
174
|
-
const args = {
|
|
175
|
-
activity: {
|
|
176
|
-
text: userMessage,
|
|
177
|
-
channelId: "webchat",
|
|
178
|
-
channelData: {
|
|
179
|
-
isHtmlEncoded: false
|
|
180
|
-
},
|
|
181
|
-
from: {
|
|
182
|
-
role: _DirectLineSenderRole.DirectLineSenderRole.User
|
|
183
|
-
},
|
|
184
|
-
type: _DirectLineActivityType.DirectLineActivityType.Typing
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
188
|
-
expect((_results$activity = results().activity) === null || _results$activity === void 0 ? void 0 : _results$activity.text).toEqual(userMessage);
|
|
189
|
-
});
|
|
190
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("@testing-library/jest-dom/extend-expect");
|
|
4
|
-
var _cardActionMiddleware = require("./cardActionMiddleware");
|
|
5
|
-
describe("cardActionMiddleware test", () => {
|
|
6
|
-
it("createCardActionMiddleware() with undefined botMagicCodeConfig should not change the sign in card url", () => {
|
|
7
|
-
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
8
|
-
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
9
|
-
const args = {
|
|
10
|
-
cardAction: {
|
|
11
|
-
type: "signin",
|
|
12
|
-
value: signInUrl
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(undefined)()(next)(args);
|
|
16
|
-
expect(signInUrl).toEqual(results.cardAction.value);
|
|
17
|
-
});
|
|
18
|
-
it("createCardActionMiddleware() with botMagicCode enabled should not change the sign in card url", () => {
|
|
19
|
-
const botMagicCodeConfig = {
|
|
20
|
-
disabled: false
|
|
21
|
-
};
|
|
22
|
-
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
23
|
-
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
24
|
-
const args = {
|
|
25
|
-
cardAction: {
|
|
26
|
-
type: "signin",
|
|
27
|
-
value: signInUrl
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
|
|
31
|
-
expect(args.cardAction.value).toEqual(results.cardAction.value);
|
|
32
|
-
});
|
|
33
|
-
it("createCardActionMiddleware() with botMagicCode disabled & no fwdUrl should not change the sign in card url", () => {
|
|
34
|
-
const botMagicCodeConfig = {
|
|
35
|
-
disabled: true
|
|
36
|
-
};
|
|
37
|
-
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
38
|
-
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
39
|
-
const args = {
|
|
40
|
-
cardAction: {
|
|
41
|
-
type: "signin",
|
|
42
|
-
value: signInUrl
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
|
|
46
|
-
expect(args.cardAction.value).toEqual(results.cardAction.value);
|
|
47
|
-
});
|
|
48
|
-
it("createCardActionMiddleware() with botMagicCode disabled & fwdUrl should append the fwdUrl in the sign in card url", () => {
|
|
49
|
-
const botMagicCodeConfig = {
|
|
50
|
-
disabled: true,
|
|
51
|
-
fwdUrl: "http://localhost/forwarder.html"
|
|
52
|
-
};
|
|
53
|
-
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
54
|
-
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
55
|
-
const args = {
|
|
56
|
-
cardAction: {
|
|
57
|
-
type: "signin",
|
|
58
|
-
value: signInUrl
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
|
|
62
|
-
expect(signInUrl === results.cardAction.value).toBe(false);
|
|
63
|
-
expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(true);
|
|
64
|
-
});
|
|
65
|
-
it("createCardActionMiddleware() should not append fwdUrl if fwdUrl & sign in card url are not in the same domain", () => {
|
|
66
|
-
const botMagicCodeConfig = {
|
|
67
|
-
disabled: true,
|
|
68
|
-
fwdUrl: "https://localhost/forwarder.html"
|
|
69
|
-
};
|
|
70
|
-
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
71
|
-
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
72
|
-
const args = {
|
|
73
|
-
cardAction: {
|
|
74
|
-
type: "signin",
|
|
75
|
-
value: signInUrl
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
|
|
79
|
-
expect(signInUrl === results.cardAction.value).toBe(true);
|
|
80
|
-
expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(false);
|
|
81
|
-
});
|
|
82
|
-
});
|