@microsoft/omnichannel-chat-widget 1.5.1-main.e2be12d → 1.6.0
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 +23 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +3 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +25 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -4
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +35 -13
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +50 -6
- 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 -3
- 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 +20 -1
- package/lib/esm/common/telemetry/TelemetryConstants.js +3 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +26 -4
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -4
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +36 -14
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +52 -8
- 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 -3
- 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 +21 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -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/livechatwidget/common/startChatErrorHandler.spec.js +0 -282
- 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/livechatwidget/common/startChatErrorHandler.spec.js +0 -280
- 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/livechatwidget/common/startChatErrorHandler.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
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IStartChatErrorPaneControlProps {
|
|
2
|
+
id?: string;
|
|
3
|
+
role?: string;
|
|
4
|
+
dir?: "rtl" | "ltr" | "auto";
|
|
5
|
+
hideIcon?: boolean;
|
|
6
|
+
hideTitle?: boolean;
|
|
7
|
+
hideSubtitle?: boolean;
|
|
8
|
+
titleText?: string;
|
|
9
|
+
subtitleText?: string;
|
|
10
|
+
unauthorizedTitleText?: string;
|
|
11
|
+
unauthorizedSubtitleText?: string;
|
|
12
|
+
authSetupErrorTitleText?: string;
|
|
13
|
+
authSetupErrorSubtitleText?: string;
|
|
14
|
+
}
|
package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IStartChatErrorPaneComponentOverrides } from "./IStartChatErrorPaneComponentOverrides";
|
|
2
|
+
import { IStartChatErrorPaneControlProps } from "./IStartChatErrorPaneControlProps";
|
|
3
|
+
import { IStartChatErrorPaneStyleProps } from "./IStartChatErrorPaneStyleProps";
|
|
4
|
+
export interface IStartChatErrorPaneProps {
|
|
5
|
+
componentOverrides?: IStartChatErrorPaneComponentOverrides;
|
|
6
|
+
controlProps?: IStartChatErrorPaneControlProps;
|
|
7
|
+
styleProps?: IStartChatErrorPaneStyleProps;
|
|
8
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IImageProps, IStyle } from "@fluentui/react";
|
|
2
|
+
import { IStartChatErrorPaneClassNames } from "./IStartChatErrorPaneClassNames";
|
|
3
|
+
export interface IStartChatErrorPaneStyleProps {
|
|
4
|
+
generalStyleProps?: IStyle;
|
|
5
|
+
titleStyleProps?: IStyle;
|
|
6
|
+
subtitleStyleProps?: IStyle;
|
|
7
|
+
iconStyleProps?: IStyle;
|
|
8
|
+
iconImageProps?: IImageProps;
|
|
9
|
+
classNames?: IStartChatErrorPaneClassNames;
|
|
10
|
+
}
|
|
@@ -4,6 +4,7 @@ import { IInternalTelemetryData } from "../../common/telemetry/interfaces/IInter
|
|
|
4
4
|
import { ILiveChatWidgetLocalizedTexts } from "./ILiveChatWidgetLocalizedTexts";
|
|
5
5
|
import { IRenderingMiddlewareProps } from "../../components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps";
|
|
6
6
|
import { ConfirmationState, ConversationEndEntity, ParticipantType } from "../../common/Constants";
|
|
7
|
+
import { StartChatFailureType } from "./StartChatFailureType";
|
|
7
8
|
export interface ILiveChatWidgetContext {
|
|
8
9
|
domainStates: {
|
|
9
10
|
liveChatConfig: ChatConfig | undefined;
|
|
@@ -23,6 +24,7 @@ export interface ILiveChatWidgetContext {
|
|
|
23
24
|
transcriptRequestId: string;
|
|
24
25
|
confirmationPaneConfirmedOptionClicked: boolean;
|
|
25
26
|
confirmationState: ConfirmationState;
|
|
27
|
+
startChatFailureType: StartChatFailureType;
|
|
26
28
|
};
|
|
27
29
|
appStates: {
|
|
28
30
|
conversationState: ConversationState;
|
|
@@ -49,6 +51,7 @@ export interface ILiveChatWidgetContext {
|
|
|
49
51
|
};
|
|
50
52
|
uiStates: {
|
|
51
53
|
showConfirmationPane: boolean;
|
|
54
|
+
showStartChatErrorPane: boolean;
|
|
52
55
|
showEmailTranscriptPane: boolean;
|
|
53
56
|
disableVideoCall: boolean;
|
|
54
57
|
showCallingPopup: boolean;
|
|
@@ -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.
|
|
3
|
+
"version": "1.6.0",
|
|
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.6.
|
|
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,282 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
4
|
-
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
5
|
-
var _startChatErrorHandler = require("./startChatErrorHandler");
|
|
6
|
-
var _Constants = require("../../../common/Constants");
|
|
7
|
-
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
|
-
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
9
|
-
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
10
|
-
describe("startChatErrorHandler unit test", () => {
|
|
11
|
-
it("handleStartChatError should log failed event and return if exception is undefined", () => {
|
|
12
|
-
const dispatch = jest.fn();
|
|
13
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
14
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
15
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, undefined, false);
|
|
16
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
17
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
18
|
-
ExceptionDetails: expect.objectContaining({
|
|
19
|
-
Exception: "Widget load complete with error: undefined"
|
|
20
|
-
})
|
|
21
|
-
}));
|
|
22
|
-
expect(dispatch).not.toHaveBeenCalled();
|
|
23
|
-
});
|
|
24
|
-
it("handleStartChatError should log failed with error event for AuthenticationFailedErrorString", () => {
|
|
25
|
-
const dispatch = jest.fn();
|
|
26
|
-
const mockEx = new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
27
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
28
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
29
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
30
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
31
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
32
|
-
ExceptionDetails: expect.objectContaining({
|
|
33
|
-
Exception: `Widget load complete with error: Error: ${_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString}`
|
|
34
|
-
})
|
|
35
|
-
}));
|
|
36
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
37
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
38
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
39
|
-
}));
|
|
40
|
-
});
|
|
41
|
-
it("handleStartChatError should log failed with error event for NetworkErrorString", () => {
|
|
42
|
-
const dispatch = jest.fn();
|
|
43
|
-
const mockEx = new Error(_Constants.WidgetLoadCustomErrorString.NetworkErrorString);
|
|
44
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
45
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
46
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
47
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
48
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
49
|
-
ExceptionDetails: expect.objectContaining({
|
|
50
|
-
Exception: `Widget load complete with error: Error: ${_Constants.WidgetLoadCustomErrorString.NetworkErrorString}`
|
|
51
|
-
})
|
|
52
|
-
}));
|
|
53
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
54
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
55
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
56
|
-
}));
|
|
57
|
-
});
|
|
58
|
-
it("handleStartChatError should log complete event for WidgetUseOutsideOperatingHour", () => {
|
|
59
|
-
const dispatch = jest.fn();
|
|
60
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.WidgetUseOutsideOperatingHour);
|
|
61
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
62
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
63
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
64
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
65
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("INFO", expect.objectContaining({
|
|
66
|
-
Description: `Widget load complete. ${_Constants.WidgetLoadTelemetryMessage.OOOHMessage}`
|
|
67
|
-
}));
|
|
68
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
69
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
70
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
71
|
-
}));
|
|
72
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
73
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS
|
|
74
|
-
}));
|
|
75
|
-
});
|
|
76
|
-
it("handleStartChatError should log failed with error event for PersistentChatConversationRetrievalFailure for non-400 status", () => {
|
|
77
|
-
const dispatch = jest.fn();
|
|
78
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure, 429);
|
|
79
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
80
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
81
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
82
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
83
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
84
|
-
Description: "Widget load complete with error",
|
|
85
|
-
ExceptionDetails: expect.objectContaining({
|
|
86
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure}`,
|
|
87
|
-
HttpResponseStatusCode: 429
|
|
88
|
-
})
|
|
89
|
-
}));
|
|
90
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
91
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
92
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
93
|
-
}));
|
|
94
|
-
});
|
|
95
|
-
it("handleStartChatError should log failed event for PersistentChatConversationRetrievalFailure for 400 status", () => {
|
|
96
|
-
const dispatch = jest.fn();
|
|
97
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure, 400);
|
|
98
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
99
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
100
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
101
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
102
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
103
|
-
ExceptionDetails: expect.objectContaining({
|
|
104
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure}`,
|
|
105
|
-
HttpResponseStatusCode: 400
|
|
106
|
-
})
|
|
107
|
-
}));
|
|
108
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
109
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
110
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
111
|
-
}));
|
|
112
|
-
});
|
|
113
|
-
it("handleStartChatError should log failed with error event for ConversationInitializationFailure for non-400 status", () => {
|
|
114
|
-
const dispatch = jest.fn();
|
|
115
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure, 429);
|
|
116
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
117
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
118
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
119
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
120
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
121
|
-
Description: "Widget load complete with error",
|
|
122
|
-
ExceptionDetails: expect.objectContaining({
|
|
123
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure}`,
|
|
124
|
-
HttpResponseStatusCode: 429
|
|
125
|
-
})
|
|
126
|
-
}));
|
|
127
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
128
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
129
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
130
|
-
}));
|
|
131
|
-
});
|
|
132
|
-
it("handleStartChatError should log failed event for ConversationInitializationFailure for 400 status", () => {
|
|
133
|
-
const dispatch = jest.fn();
|
|
134
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure, 400);
|
|
135
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
136
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
137
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
138
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
139
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
140
|
-
ExceptionDetails: expect.objectContaining({
|
|
141
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure}`,
|
|
142
|
-
HttpResponseStatusCode: 400
|
|
143
|
-
})
|
|
144
|
-
}));
|
|
145
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
146
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
147
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
148
|
-
}));
|
|
149
|
-
});
|
|
150
|
-
it("handleStartChatError should log failed with error event for ChatTokenRetrievalFailure for non-400 status", () => {
|
|
151
|
-
const dispatch = jest.fn();
|
|
152
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure, 429);
|
|
153
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
154
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
155
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
156
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
157
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
158
|
-
Description: "Widget load complete with error",
|
|
159
|
-
ExceptionDetails: expect.objectContaining({
|
|
160
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure}`,
|
|
161
|
-
HttpResponseStatusCode: 429
|
|
162
|
-
})
|
|
163
|
-
}));
|
|
164
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
165
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
166
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
167
|
-
}));
|
|
168
|
-
});
|
|
169
|
-
it("handleStartChatError should log failed event for ChatTokenRetrievalFailure for 400 status", () => {
|
|
170
|
-
const dispatch = jest.fn();
|
|
171
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure, 400);
|
|
172
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
173
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
174
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
175
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
176
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
177
|
-
ExceptionDetails: expect.objectContaining({
|
|
178
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure}`,
|
|
179
|
-
HttpResponseStatusCode: 400
|
|
180
|
-
})
|
|
181
|
-
}));
|
|
182
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
183
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
184
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
185
|
-
}));
|
|
186
|
-
});
|
|
187
|
-
it("handleStartChatError should log failed with error event for UninitializedChatSDK", () => {
|
|
188
|
-
const dispatch = jest.fn();
|
|
189
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK);
|
|
190
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
191
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
192
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
193
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
194
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
195
|
-
Description: "Widget load complete with error",
|
|
196
|
-
ExceptionDetails: expect.objectContaining({
|
|
197
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK}`
|
|
198
|
-
})
|
|
199
|
-
}));
|
|
200
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
201
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
202
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
203
|
-
}));
|
|
204
|
-
});
|
|
205
|
-
it("handleStartChatError should log failed with error event for InvalidConversation", () => {
|
|
206
|
-
const dispatch = jest.fn();
|
|
207
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.InvalidConversation);
|
|
208
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
209
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
210
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
211
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
212
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
213
|
-
Description: "Widget load complete with error",
|
|
214
|
-
ExceptionDetails: expect.objectContaining({
|
|
215
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.InvalidConversation}`
|
|
216
|
-
})
|
|
217
|
-
}));
|
|
218
|
-
expect(dispatch).toHaveBeenCalledTimes(16);
|
|
219
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
220
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
221
|
-
payload: _ConversationState.ConversationState.Closed
|
|
222
|
-
}));
|
|
223
|
-
});
|
|
224
|
-
it("handleStartChatError should log failed with error event for ClosedConversation", () => {
|
|
225
|
-
const dispatch = jest.fn();
|
|
226
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ClosedConversation);
|
|
227
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
228
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
229
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
230
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
231
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
232
|
-
Description: "Widget load complete with error",
|
|
233
|
-
ExceptionDetails: expect.objectContaining({
|
|
234
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ClosedConversation}`
|
|
235
|
-
})
|
|
236
|
-
}));
|
|
237
|
-
expect(dispatch).toHaveBeenCalledTimes(16);
|
|
238
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
239
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
240
|
-
payload: _ConversationState.ConversationState.Closed
|
|
241
|
-
}));
|
|
242
|
-
});
|
|
243
|
-
it("handleStartChatError should log failed event for any other errors", () => {
|
|
244
|
-
const dispatch = jest.fn();
|
|
245
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure, 405);
|
|
246
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
247
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
248
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
249
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
250
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
251
|
-
ExceptionDetails: expect.objectContaining({
|
|
252
|
-
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure}`,
|
|
253
|
-
HttpResponseStatusCode: 405
|
|
254
|
-
})
|
|
255
|
-
}));
|
|
256
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
257
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
258
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
259
|
-
}));
|
|
260
|
-
});
|
|
261
|
-
it("handleStartChatError should force end chat if isStartChatSuccessful is true", () => {
|
|
262
|
-
const dispatch = jest.fn();
|
|
263
|
-
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure, 405);
|
|
264
|
-
const mockSDK = {
|
|
265
|
-
endChat: jest.fn()
|
|
266
|
-
};
|
|
267
|
-
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
268
|
-
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
269
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch, mockSDK, {}, mockEx, true);
|
|
270
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(3);
|
|
271
|
-
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
272
|
-
ExceptionDetails: expect.objectContaining({
|
|
273
|
-
Exception: "SessionInit was successful, but widget load failed."
|
|
274
|
-
})
|
|
275
|
-
}));
|
|
276
|
-
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
277
|
-
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
278
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
279
|
-
}));
|
|
280
|
-
expect(mockSDK.endChat).toHaveBeenCalled();
|
|
281
|
-
});
|
|
282
|
-
});
|