@servicetitan/titan-chatbot-ui-cypress 3.0.1 → 3.1.1
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/CHANGELOG.md +24 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/mocks/chatbot-api-client.mock.d.ts +0 -1
- package/dist/mocks/chatbot-api-client.mock.d.ts.map +1 -1
- package/dist/mocks/chatbot-api-client.mock.js +0 -6
- package/dist/mocks/chatbot-api-client.mock.js.map +1 -1
- package/dist/tests/index.d.ts +30 -0
- package/dist/tests/index.d.ts.map +1 -0
- package/dist/tests/index.js +30 -0
- package/dist/tests/index.js.map +1 -0
- package/dist/tests/titan-chat-ui/chat-error.shared-tests.d.ts +3 -0
- package/dist/tests/titan-chat-ui/chat-error.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/chat-error.shared-tests.js +138 -0
- package/dist/tests/titan-chat-ui/chat-error.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/chat-input-file.shared-tests.d.ts +7 -0
- package/dist/tests/titan-chat-ui/chat-input-file.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/chat-input-file.shared-tests.js +123 -0
- package/dist/tests/titan-chat-ui/chat-input-file.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/chat-input.shared-tests.d.ts +3 -0
- package/dist/tests/titan-chat-ui/chat-input.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/chat-input.shared-tests.js +71 -0
- package/dist/tests/titan-chat-ui/chat-input.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/chat-log.shared-tests.d.ts +9 -0
- package/dist/tests/titan-chat-ui/chat-log.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/chat-log.shared-tests.js +73 -0
- package/dist/tests/titan-chat-ui/chat-log.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/chat-messages.shared-tests.d.ts +8 -0
- package/dist/tests/titan-chat-ui/chat-messages.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/chat-messages.shared-tests.js +118 -0
- package/dist/tests/titan-chat-ui/chat-messages.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/chat-notifications.shared-tests.d.ts +3 -0
- package/dist/tests/titan-chat-ui/chat-notifications.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/chat-notifications.shared-tests.js +110 -0
- package/dist/tests/titan-chat-ui/chat-notifications.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/chat-timer.shared-tests.d.ts +3 -0
- package/dist/tests/titan-chat-ui/chat-timer.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/chat-timer.shared-tests.js +76 -0
- package/dist/tests/titan-chat-ui/chat-timer.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/chat.shared-tests.d.ts +9 -0
- package/dist/tests/titan-chat-ui/chat.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/chat.shared-tests.js +111 -0
- package/dist/tests/titan-chat-ui/chat.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/message-agent.shared-tests.d.ts +27 -0
- package/dist/tests/titan-chat-ui/message-agent.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/message-agent.shared-tests.js +67 -0
- package/dist/tests/titan-chat-ui/message-agent.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/message-content-file.shared-tests.d.ts +10 -0
- package/dist/tests/titan-chat-ui/message-content-file.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/message-content-file.shared-tests.js +88 -0
- package/dist/tests/titan-chat-ui/message-content-file.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/message-system.shared-tests.d.ts +16 -0
- package/dist/tests/titan-chat-ui/message-system.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/message-system.shared-tests.js +65 -0
- package/dist/tests/titan-chat-ui/message-system.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/message-timeout.shared-tests.d.ts +8 -0
- package/dist/tests/titan-chat-ui/message-timeout.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/message-timeout.shared-tests.js +63 -0
- package/dist/tests/titan-chat-ui/message-timeout.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/message-typing.shared-tests.d.ts +12 -0
- package/dist/tests/titan-chat-ui/message-typing.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/message-typing.shared-tests.js +46 -0
- package/dist/tests/titan-chat-ui/message-typing.shared-tests.js.map +1 -0
- package/dist/tests/titan-chat-ui/message-user.shared-tests.d.ts +10 -0
- package/dist/tests/titan-chat-ui/message-user.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chat-ui/message-user.shared-tests.js +64 -0
- package/dist/tests/titan-chat-ui/message-user.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-filters.shared-tests.d.ts +7 -0
- package/dist/tests/titan-chatbot-ui/chatbot-filters.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-filters.shared-tests.js +118 -0
- package/dist/tests/titan-chatbot-ui/chatbot-filters.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.d.ts +9 -0
- package/dist/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.js +162 -0
- package/dist/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-links.shared-tests.d.ts +15 -0
- package/dist/tests/titan-chatbot-ui/chatbot-links.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-links.shared-tests.js +123 -0
- package/dist/tests/titan-chatbot-ui/chatbot-links.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-live.shared-tests.d.ts +9 -0
- package/dist/tests/titan-chatbot-ui/chatbot-live.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-live.shared-tests.js +84 -0
- package/dist/tests/titan-chatbot-ui/chatbot-live.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.d.ts +8 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.js +142 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.d.ts +8 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.js +105 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.d.ts +3 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.js +86 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.d.ts +3 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.js +143 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.d.ts +8 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.js +200 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.d.ts +11 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.js +81 -0
- package/dist/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.d.ts +8 -0
- package/dist/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.js +60 -0
- package/dist/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.d.ts +8 -0
- package/dist/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.js +77 -0
- package/dist/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.d.ts +7 -0
- package/dist/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.js +130 -0
- package/dist/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.d.ts +9 -0
- package/dist/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.js +157 -0
- package/dist/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.js.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot.shared-tests.d.ts +9 -0
- package/dist/tests/titan-chatbot-ui/chatbot.shared-tests.d.ts.map +1 -0
- package/dist/tests/titan-chatbot-ui/chatbot.shared-tests.js +114 -0
- package/dist/tests/titan-chatbot-ui/chatbot.shared-tests.js.map +1 -0
- package/dist/utils/chat-ui-selectors.d.ts +12 -0
- package/dist/utils/chat-ui-selectors.d.ts.map +1 -1
- package/dist/utils/chat-ui-selectors.js +24 -0
- package/dist/utils/chat-ui-selectors.js.map +1 -1
- package/dist/utils/test-utils-chatbot.d.ts +5 -0
- package/dist/utils/test-utils-chatbot.d.ts.map +1 -0
- package/dist/utils/test-utils-chatbot.js +55 -0
- package/dist/utils/test-utils-chatbot.js.map +1 -0
- package/dist/utils/test-utils.d.ts +6 -0
- package/dist/utils/test-utils.d.ts.map +1 -0
- package/dist/utils/test-utils.js +38 -0
- package/dist/utils/test-utils.js.map +1 -0
- package/package.json +10 -5
- package/src/index.ts +3 -0
- package/src/mocks/chatbot-api-client.mock.ts +0 -1
- package/src/tests/index.ts +30 -0
- package/src/tests/titan-chat-ui/chat-error.shared-tests.tsx +185 -0
- package/src/tests/titan-chat-ui/chat-input-file.shared-tests.tsx +182 -0
- package/src/tests/titan-chat-ui/chat-input.shared-tests.tsx +99 -0
- package/src/tests/titan-chat-ui/chat-log.shared-tests.tsx +117 -0
- package/src/tests/titan-chat-ui/chat-messages.shared-tests.tsx +156 -0
- package/src/tests/titan-chat-ui/chat-notifications.shared-tests.tsx +153 -0
- package/src/tests/titan-chat-ui/chat-timer.shared-tests.tsx +106 -0
- package/src/tests/titan-chat-ui/chat.shared-tests.tsx +158 -0
- package/src/tests/titan-chat-ui/message-agent.shared-tests.tsx +170 -0
- package/src/tests/titan-chat-ui/message-content-file.shared-tests.tsx +139 -0
- package/src/tests/titan-chat-ui/message-system.shared-tests.tsx +147 -0
- package/src/tests/titan-chat-ui/message-timeout.shared-tests.tsx +117 -0
- package/src/tests/titan-chat-ui/message-typing.shared-tests.tsx +92 -0
- package/src/tests/titan-chat-ui/message-user.shared-tests.tsx +138 -0
- package/src/tests/titan-chatbot-ui/chatbot-filters.shared-tests.tsx +164 -0
- package/src/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.tsx +225 -0
- package/src/tests/titan-chatbot-ui/chatbot-links.shared-tests.tsx +189 -0
- package/src/tests/titan-chatbot-ui/chatbot-live.shared-tests.tsx +127 -0
- package/src/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.tsx +187 -0
- package/src/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.tsx +144 -0
- package/src/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.tsx +127 -0
- package/src/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.tsx +198 -0
- package/src/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.tsx +285 -0
- package/src/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.tsx +112 -0
- package/src/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.tsx +91 -0
- package/src/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.tsx +116 -0
- package/src/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.tsx +182 -0
- package/src/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.tsx +221 -0
- package/src/tests/titan-chatbot-ui/chatbot.shared-tests.tsx +158 -0
- package/src/utils/chat-ui-selectors.ts +24 -0
- package/src/utils/test-utils-chatbot.tsx +73 -0
- package/src/utils/test-utils.tsx +52 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Container } from '@servicetitan/react-ioc';
|
|
2
|
+
import {
|
|
3
|
+
CHATBOT_API_CLIENT,
|
|
4
|
+
CHATBOT_UI_STORE_TOKEN,
|
|
5
|
+
ChatbotUiStore,
|
|
6
|
+
IChatbotUiStore,
|
|
7
|
+
Models,
|
|
8
|
+
ModelsMocks,
|
|
9
|
+
} from '@servicetitan/titan-chatbot-api';
|
|
10
|
+
import { FC, ReactElement } from 'react';
|
|
11
|
+
import { CypressMocks, testInitContainerChatbot, testRenderWrapperChatbot } from '../..';
|
|
12
|
+
import { ChatUiSelectors } from '../../utils/chat-ui-selectors';
|
|
13
|
+
|
|
14
|
+
interface IChatbotSessionFeedbackModalProps {
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function runChatbotSessionFeedbackModalSharedTests(
|
|
19
|
+
ChatbotSessionFeedbackModalComponent: FC<IChatbotSessionFeedbackModalProps>,
|
|
20
|
+
wrapperComponent?: (component: ReactElement) => ReactElement
|
|
21
|
+
) {
|
|
22
|
+
let container: Container;
|
|
23
|
+
let api: CypressMocks.ChatbotApiClientMock;
|
|
24
|
+
let chatbotUiStore: IChatbotUiStore;
|
|
25
|
+
|
|
26
|
+
const mockApiClient = () => {
|
|
27
|
+
api.postSession = cy.stub().resolves(ModelsMocks.mockSession());
|
|
28
|
+
api.getOptions = cy.stub().resolves(ModelsMocks.mockFrontendModel());
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
container = testInitContainerChatbot();
|
|
33
|
+
api = container.get<CypressMocks.ChatbotApiClientMock>(CHATBOT_API_CLIENT);
|
|
34
|
+
chatbotUiStore = container.get<ChatbotUiStore>(CHATBOT_UI_STORE_TOKEN);
|
|
35
|
+
mockApiClient();
|
|
36
|
+
cy.viewport(550, 800);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const assertButtonSelection = (element: Cypress.Chainable<JQuery>, selected: boolean) => {
|
|
40
|
+
element.should($el => {
|
|
41
|
+
const hasClass = $el.hasClass('Button--selected');
|
|
42
|
+
const hasAttr = $el.attr('aria-pressed') === 'true';
|
|
43
|
+
expect(hasClass || hasAttr).to.equal(selected);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const render = (onAfterInit?: () => void, onClose = cy.stub()) => {
|
|
48
|
+
return cy.wrap(null).then(() => {
|
|
49
|
+
const TestComponent: FC = () => {
|
|
50
|
+
const component = <ChatbotSessionFeedbackModalComponent onClose={onClose} />;
|
|
51
|
+
return wrapperComponent ? wrapperComponent(component) : component;
|
|
52
|
+
};
|
|
53
|
+
return testRenderWrapperChatbot(container, <TestComponent />, onAfterInit);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
it('should render the feedback modal with all elements', () => {
|
|
58
|
+
render();
|
|
59
|
+
|
|
60
|
+
ChatUiSelectors.chatbotSessionFeedbackModal.should('be.visible');
|
|
61
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsUp.should('be.visible');
|
|
62
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsDown.should('be.visible');
|
|
63
|
+
ChatUiSelectors.chatbotSessionFeedbackComment.should('be.visible');
|
|
64
|
+
ChatUiSelectors.chatbotSessionFeedbackCancel.should('be.visible');
|
|
65
|
+
ChatUiSelectors.chatbotSessionFeedbackSubmit.should('be.visible');
|
|
66
|
+
ChatUiSelectors.chatbotSessionFeedbackSubmit.should('be.disabled');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should enable submit button when thumbs up is selected', () => {
|
|
70
|
+
render();
|
|
71
|
+
|
|
72
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsUp.click();
|
|
73
|
+
ChatUiSelectors.chatbotSessionFeedbackSubmit.should('not.be.disabled');
|
|
74
|
+
assertButtonSelection(ChatUiSelectors.chatbotSessionFeedbackThumbsUp, true);
|
|
75
|
+
assertButtonSelection(ChatUiSelectors.chatbotSessionFeedbackThumbsDown, false);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should enable submit button when thumbs down is selected', () => {
|
|
79
|
+
render();
|
|
80
|
+
|
|
81
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsDown.click();
|
|
82
|
+
ChatUiSelectors.chatbotSessionFeedbackSubmit.should('not.be.disabled');
|
|
83
|
+
assertButtonSelection(ChatUiSelectors.chatbotSessionFeedbackThumbsDown, true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should allow switching between thumbs up and thumbs down', () => {
|
|
87
|
+
render();
|
|
88
|
+
|
|
89
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsUp.click();
|
|
90
|
+
assertButtonSelection(ChatUiSelectors.chatbotSessionFeedbackThumbsUp, true);
|
|
91
|
+
assertButtonSelection(ChatUiSelectors.chatbotSessionFeedbackThumbsDown, false);
|
|
92
|
+
|
|
93
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsDown.click();
|
|
94
|
+
assertButtonSelection(ChatUiSelectors.chatbotSessionFeedbackThumbsDown, true);
|
|
95
|
+
assertButtonSelection(ChatUiSelectors.chatbotSessionFeedbackThumbsUp, false);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should allow entering a comment', () => {
|
|
99
|
+
render();
|
|
100
|
+
|
|
101
|
+
const testComment = 'This is my feedback comment';
|
|
102
|
+
ChatUiSelectors.chatbotSessionFeedbackComment.type(testComment);
|
|
103
|
+
ChatUiSelectors.chatbotSessionFeedbackComment.should('have.value', testComment);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should call onClose when cancel button is clicked', () => {
|
|
107
|
+
const onClose = cy.stub().as('onClose');
|
|
108
|
+
render(undefined, onClose);
|
|
109
|
+
|
|
110
|
+
ChatUiSelectors.chatbotSessionFeedbackCancel.click();
|
|
111
|
+
cy.then(() => {
|
|
112
|
+
cy.get('@onClose').should('have.been.called');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should submit feedback with thumbs up and close modal', () => {
|
|
117
|
+
const onClose = cy.stub().as('onClose');
|
|
118
|
+
render(undefined, onClose);
|
|
119
|
+
|
|
120
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsUp.click();
|
|
121
|
+
ChatUiSelectors.chatbotSessionFeedbackSubmit.click();
|
|
122
|
+
|
|
123
|
+
cy.wait(1).then(() => {
|
|
124
|
+
cy.get('@onClose').should('have.been.called');
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should submit feedback with thumbs down, comment and close modal', () => {
|
|
129
|
+
const onClose = cy.stub().as('onClose');
|
|
130
|
+
render(undefined, onClose);
|
|
131
|
+
|
|
132
|
+
const testComment = 'This did not help me at all';
|
|
133
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsDown.click();
|
|
134
|
+
ChatUiSelectors.chatbotSessionFeedbackComment.type(testComment);
|
|
135
|
+
ChatUiSelectors.chatbotSessionFeedbackSubmit.click();
|
|
136
|
+
|
|
137
|
+
cy.wait(1).then(() => {
|
|
138
|
+
cy.get('@onClose').should('have.been.called');
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should send session feedback to the store when submitting', () => {
|
|
143
|
+
const onClose = cy.stub();
|
|
144
|
+
render(undefined, onClose);
|
|
145
|
+
|
|
146
|
+
cy.spy(chatbotUiStore, 'sendSessionFeedback').as('sendSessionFeedback');
|
|
147
|
+
|
|
148
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsUp.click();
|
|
149
|
+
ChatUiSelectors.chatbotSessionFeedbackSubmit.click();
|
|
150
|
+
|
|
151
|
+
cy.get('@sendSessionFeedback').should('have.been.called');
|
|
152
|
+
cy.get('@sendSessionFeedback').should(
|
|
153
|
+
'have.been.calledWith',
|
|
154
|
+
new Models.Feedback({
|
|
155
|
+
sessionId: ModelsMocks.mockSession().id,
|
|
156
|
+
rating: Models.FeedbackRatings.ThumbsUp,
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should send session feedback with comment when submitting', () => {
|
|
162
|
+
const onClose = cy.stub();
|
|
163
|
+
render(undefined, onClose);
|
|
164
|
+
|
|
165
|
+
cy.spy(chatbotUiStore, 'sendSessionFeedback').as('sendSessionFeedback');
|
|
166
|
+
|
|
167
|
+
const testComment = 'Great experience!';
|
|
168
|
+
ChatUiSelectors.chatbotSessionFeedbackThumbsUp.click();
|
|
169
|
+
ChatUiSelectors.chatbotSessionFeedbackComment.type(testComment);
|
|
170
|
+
ChatUiSelectors.chatbotSessionFeedbackSubmit.click();
|
|
171
|
+
|
|
172
|
+
cy.get('@sendSessionFeedback').should('have.been.called');
|
|
173
|
+
cy.get('@sendSessionFeedback').should(
|
|
174
|
+
'have.been.calledWithMatch',
|
|
175
|
+
new Models.Feedback({
|
|
176
|
+
sessionId: ModelsMocks.mockSession().id,
|
|
177
|
+
rating: Models.FeedbackRatings.ThumbsUp,
|
|
178
|
+
description: testComment,
|
|
179
|
+
})
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { ILog, Log } from '@servicetitan/log-service';
|
|
2
|
+
import { Container, Provider } from '@servicetitan/react-ioc';
|
|
3
|
+
import {
|
|
4
|
+
ApiClientTitanChat,
|
|
5
|
+
CHATBOT_API_CLIENT,
|
|
6
|
+
CHATBOT_CLIENT_SETTINGS,
|
|
7
|
+
CHATBOT_UI_BACKEND_STORE_TOKEN,
|
|
8
|
+
CHATBOT_UI_STORE_TOKEN,
|
|
9
|
+
ChatbotCustomizations,
|
|
10
|
+
ChatbotUiBackendStore,
|
|
11
|
+
ChatbotUiStore,
|
|
12
|
+
IChatbotApiClient,
|
|
13
|
+
IChatbotUiBackendStore,
|
|
14
|
+
IChatbotUiStore,
|
|
15
|
+
Models,
|
|
16
|
+
} from '@servicetitan/titan-chatbot-api';
|
|
17
|
+
import { mount } from 'cypress/react';
|
|
18
|
+
import { FC, ReactElement, useMemo } from 'react';
|
|
19
|
+
import { CypressMocks } from '../..';
|
|
20
|
+
import { ChatUiSelectors } from '../../utils/chat-ui-selectors';
|
|
21
|
+
|
|
22
|
+
const ChatbotBaseUrl = 'https://chatbot-api.example.com/base/url';
|
|
23
|
+
const ChatbotVersion = 2;
|
|
24
|
+
|
|
25
|
+
const initializeTitanChatbotContainer = () => {
|
|
26
|
+
const rootContainer = new Container();
|
|
27
|
+
const container = new Container();
|
|
28
|
+
container.parent = rootContainer;
|
|
29
|
+
container.bind<ILog>(Log).to(CypressMocks.LogMock).inSingletonScope();
|
|
30
|
+
container.bind<IChatbotUiStore>(CHATBOT_UI_STORE_TOKEN).to(ChatbotUiStore).inSingletonScope();
|
|
31
|
+
container
|
|
32
|
+
.bind<IChatbotUiBackendStore>(CHATBOT_UI_BACKEND_STORE_TOKEN)
|
|
33
|
+
.to(ChatbotUiBackendStore)
|
|
34
|
+
.inSingletonScope();
|
|
35
|
+
|
|
36
|
+
// Set up Helpcenter API client
|
|
37
|
+
const clientSettings: ApiClientTitanChat.IChatbotClientSettingsTitanChat = {
|
|
38
|
+
clientId: 'TitanChatClientId',
|
|
39
|
+
version: String(ChatbotVersion),
|
|
40
|
+
constructorParametersFactory: () => ({
|
|
41
|
+
baseUrl: ChatbotBaseUrl,
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
container
|
|
45
|
+
.bind<ApiClientTitanChat.IChatbotClientSettingsTitanChat>(CHATBOT_CLIENT_SETTINGS)
|
|
46
|
+
.toConstantValue(clientSettings);
|
|
47
|
+
container
|
|
48
|
+
.bind<IChatbotApiClient>(CHATBOT_API_CLIENT)
|
|
49
|
+
.to(ApiClientTitanChat.ChatbotApiClient)
|
|
50
|
+
.inSingletonScope();
|
|
51
|
+
return container;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
interface IChatbotProps {
|
|
55
|
+
className?: string;
|
|
56
|
+
customizations?: ChatbotCustomizations;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function runChatbotTitanChatbotSharedTests(
|
|
60
|
+
ChatbotComponent: FC<IChatbotProps>,
|
|
61
|
+
wrapperComponent?: (component: ReactElement) => ReactElement
|
|
62
|
+
) {
|
|
63
|
+
let container: Container;
|
|
64
|
+
let log: CypressMocks.LogMock;
|
|
65
|
+
let apiClientSettings: ApiClientTitanChat.IChatbotClientSettingsTitanChat;
|
|
66
|
+
let apiClient: ApiClientTitanChat.ChatbotApiClient;
|
|
67
|
+
let uiStore: ChatbotUiStore;
|
|
68
|
+
let uiBackendStore: ChatbotUiBackendStore;
|
|
69
|
+
|
|
70
|
+
beforeEach(() => {
|
|
71
|
+
container = initializeTitanChatbotContainer();
|
|
72
|
+
log = container.get<CypressMocks.LogMock>(Log);
|
|
73
|
+
apiClientSettings =
|
|
74
|
+
container.get<ApiClientTitanChat.IChatbotClientSettingsTitanChat>(
|
|
75
|
+
CHATBOT_CLIENT_SETTINGS
|
|
76
|
+
);
|
|
77
|
+
apiClient = container.get<ApiClientTitanChat.ChatbotApiClient>(CHATBOT_API_CLIENT);
|
|
78
|
+
uiStore = container.get<ChatbotUiStore>(CHATBOT_UI_STORE_TOKEN);
|
|
79
|
+
uiBackendStore = container.get<ChatbotUiBackendStore>(CHATBOT_UI_BACKEND_STORE_TOKEN);
|
|
80
|
+
cy.viewport(550, 800);
|
|
81
|
+
cy.clock(Date.parse('2023-10-01T00:00:00Z'));
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const render = () => {
|
|
85
|
+
const ChatbotWrapper: FC = () => {
|
|
86
|
+
const customizationContext = useMemo<ChatbotCustomizations>(
|
|
87
|
+
() => ({
|
|
88
|
+
filters: { enabled: true },
|
|
89
|
+
feedback: { title: 'TITLE' },
|
|
90
|
+
}),
|
|
91
|
+
[]
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const component = (
|
|
95
|
+
<ChatbotComponent
|
|
96
|
+
className="h-100vh max-h-100vh of-x-hidden"
|
|
97
|
+
customizations={customizationContext}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const wrappedComponent = wrapperComponent ? wrapperComponent(component) : component;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<Provider
|
|
105
|
+
singletons={[
|
|
106
|
+
{
|
|
107
|
+
provide: Log,
|
|
108
|
+
useValue: log,
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
provide: CHATBOT_CLIENT_SETTINGS,
|
|
112
|
+
useValue: apiClientSettings,
|
|
113
|
+
},
|
|
114
|
+
{ provide: CHATBOT_API_CLIENT, useValue: apiClient },
|
|
115
|
+
{
|
|
116
|
+
provide: CHATBOT_UI_STORE_TOKEN,
|
|
117
|
+
useValue: uiStore,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
provide: CHATBOT_UI_BACKEND_STORE_TOKEN,
|
|
121
|
+
useValue: uiBackendStore,
|
|
122
|
+
},
|
|
123
|
+
]}
|
|
124
|
+
>
|
|
125
|
+
{wrappedComponent}
|
|
126
|
+
</Provider>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
cy.spy(uiStore, 'run').as('runSpy');
|
|
130
|
+
mount(<ChatbotWrapper />);
|
|
131
|
+
return cy.wrap(
|
|
132
|
+
new Promise(resolve => {
|
|
133
|
+
cy.get('@runSpy')
|
|
134
|
+
.should('have.been.calledOnce')
|
|
135
|
+
.then((invocation: any) => {
|
|
136
|
+
const initPromise = invocation.firstCall.returnValue as ReturnType<
|
|
137
|
+
IChatbotUiStore['run']
|
|
138
|
+
>;
|
|
139
|
+
initPromise.then(resolve);
|
|
140
|
+
});
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
it('should render the chatbot with titan chat API', () => {
|
|
146
|
+
const optionsMock = CypressMocks.TC.Options;
|
|
147
|
+
const sessionMock = CypressMocks.TC.SessionPost;
|
|
148
|
+
const messageMock = CypressMocks.TC.MessagePost;
|
|
149
|
+
const messageFeedbackMock = CypressMocks.TC.MessageFeedbackPost;
|
|
150
|
+
const sessionFeedbackMock = CypressMocks.TC.SessionFeedbackPost;
|
|
151
|
+
|
|
152
|
+
const aliasOptions = optionsMock.intercept(ChatbotBaseUrl, ChatbotVersion);
|
|
153
|
+
const aliasSession = sessionMock.intercept(ChatbotBaseUrl, ChatbotVersion);
|
|
154
|
+
const aliasMessage = messageMock.intercept(ChatbotBaseUrl, ChatbotVersion);
|
|
155
|
+
const { aliasPostMessage, aliasPostSession } = CypressMocks.TC.interceptFeedback(
|
|
156
|
+
ChatbotBaseUrl,
|
|
157
|
+
ChatbotVersion
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
render().then(() => {
|
|
161
|
+
cy.log('Getting options...');
|
|
162
|
+
cy.wait(aliasOptions).then(interception => {
|
|
163
|
+
expect(interception.request.url).to.equal(
|
|
164
|
+
`${ChatbotBaseUrl}/api/v${ChatbotVersion}/options`
|
|
165
|
+
);
|
|
166
|
+
expect(interception.response?.statusCode).to.equal(200);
|
|
167
|
+
expect(interception.response?.body).to.deep.equal(optionsMock.response);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Ask the bot a question
|
|
171
|
+
cy.log('Sending message...');
|
|
172
|
+
ChatUiSelectors.chatInput.type(`${messageMock.request.question}{enter}`, { delay: 0 });
|
|
173
|
+
|
|
174
|
+
// Check that the session was created
|
|
175
|
+
cy.wait(aliasSession).then(interception => {
|
|
176
|
+
expect(interception.request.url).to.equal(
|
|
177
|
+
`${ChatbotBaseUrl}/api/v${ChatbotVersion}/session`
|
|
178
|
+
);
|
|
179
|
+
expect(interception.request.body).to.deep.equal(sessionMock.request);
|
|
180
|
+
expect(interception.response?.body).to.deep.equal(sessionMock.response);
|
|
181
|
+
expect(interception.response?.statusCode).to.equal(200);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Check the user message is sent
|
|
185
|
+
cy.wait(aliasMessage).then(interception => {
|
|
186
|
+
expect(interception.request.url).to.equal(
|
|
187
|
+
`${ChatbotBaseUrl}/api/v${ChatbotVersion}/message`
|
|
188
|
+
);
|
|
189
|
+
expect(interception.request.body).to.deep.equal(messageMock.request);
|
|
190
|
+
expect(interception.response?.body).to.deep.equal(messageMock.response);
|
|
191
|
+
expect(interception.response?.statusCode).to.equal(200);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
cy.tick(100);
|
|
195
|
+
// Send session feedback (manually)
|
|
196
|
+
cy.log('Sending session feedback...');
|
|
197
|
+
uiStore.sendSessionFeedback(new Models.Feedback(sessionFeedbackMock.request));
|
|
198
|
+
cy.wait(aliasPostSession).then(interception => {
|
|
199
|
+
expect(interception.request.url).to.equal(
|
|
200
|
+
`${ChatbotBaseUrl}/api/v${ChatbotVersion}/feedback`
|
|
201
|
+
);
|
|
202
|
+
expect(interception.request.body).to.deep.equal(sessionFeedbackMock.request);
|
|
203
|
+
expect(interception.response?.body).to.deep.equal(sessionFeedbackMock.response);
|
|
204
|
+
expect(interception.response?.statusCode).to.equal(200);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
cy.tick(100);
|
|
208
|
+
// Check the feedback is sent with thumbs up
|
|
209
|
+
cy.log('Sending message feedback...');
|
|
210
|
+
ChatUiSelectors.chatbotMessageFeedbackThumbsUp.scrollIntoView().click({ force: true });
|
|
211
|
+
cy.wait(aliasPostMessage).then(interception => {
|
|
212
|
+
expect(interception.request.url).to.equal(
|
|
213
|
+
`${ChatbotBaseUrl}/api/v${ChatbotVersion}/feedback`
|
|
214
|
+
);
|
|
215
|
+
expect(interception.request.body).to.deep.equal(messageFeedbackMock.request);
|
|
216
|
+
expect(interception.response?.body).to.deep.equal(messageFeedbackMock.response);
|
|
217
|
+
expect(interception.response?.statusCode).to.equal(200);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Container } from '@servicetitan/react-ioc';
|
|
2
|
+
import {
|
|
3
|
+
CHATBOT_API_CLIENT,
|
|
4
|
+
CHATBOT_UI_STORE_TOKEN,
|
|
5
|
+
ChatbotCustomizations,
|
|
6
|
+
ChatbotUiStore,
|
|
7
|
+
IChatbotUiStore,
|
|
8
|
+
Models,
|
|
9
|
+
ModelsMocks,
|
|
10
|
+
} from '@servicetitan/titan-chatbot-api';
|
|
11
|
+
import { CSSProperties, FC, ReactElement } from 'react';
|
|
12
|
+
import { CypressMocks, testInitContainerChatbot, testRenderWrapperChatbot } from '../..';
|
|
13
|
+
import { ChatUiSelectors } from '../../utils/chat-ui-selectors';
|
|
14
|
+
|
|
15
|
+
interface IChatbotProps {
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
customizations?: ChatbotCustomizations;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function runChatbotSharedTests(
|
|
21
|
+
ChatbotComponent: FC<IChatbotProps>,
|
|
22
|
+
wrapperComponent?: (component: ReactElement) => ReactElement
|
|
23
|
+
) {
|
|
24
|
+
let container: Container;
|
|
25
|
+
let api: CypressMocks.ChatbotApiClientMock;
|
|
26
|
+
let chatbotUiStore: IChatbotUiStore;
|
|
27
|
+
|
|
28
|
+
const mockApiClient = () => {
|
|
29
|
+
api.postSession = cy.stub().resolves(ModelsMocks.mockSession());
|
|
30
|
+
api.getOptions = cy.stub().resolves(ModelsMocks.mockFrontendModel());
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const mockAskBotApi = (answer: string) => {
|
|
34
|
+
api.postMessage = cy.stub().as('askBot').resolves(
|
|
35
|
+
ModelsMocks.mockBotMessage({
|
|
36
|
+
answer,
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
api.postFeedback = cy
|
|
40
|
+
.stub()
|
|
41
|
+
.as('askBotFeedback')
|
|
42
|
+
.resolves(
|
|
43
|
+
ModelsMocks.mockFeedback({
|
|
44
|
+
rating: Models.FeedbackRatings.ThumbsUp,
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
beforeEach(() => {
|
|
50
|
+
container = testInitContainerChatbot();
|
|
51
|
+
api = container.get<CypressMocks.ChatbotApiClientMock>(CHATBOT_API_CLIENT);
|
|
52
|
+
chatbotUiStore = container.get<ChatbotUiStore>(CHATBOT_UI_STORE_TOKEN);
|
|
53
|
+
mockApiClient();
|
|
54
|
+
cy.viewport(550, 800);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const render = (onAfterInit?: () => void) => {
|
|
58
|
+
return cy.wrap(null).then(() => {
|
|
59
|
+
const customizationContext: ChatbotCustomizations = {
|
|
60
|
+
filters: { enabled: true },
|
|
61
|
+
feedback: { title: 'TITLE' },
|
|
62
|
+
};
|
|
63
|
+
const component = (
|
|
64
|
+
<ChatbotComponent
|
|
65
|
+
style={{
|
|
66
|
+
height: '100vh',
|
|
67
|
+
width: '100%',
|
|
68
|
+
maxWidth: '100vh',
|
|
69
|
+
overflowX: 'hidden',
|
|
70
|
+
}}
|
|
71
|
+
customizations={customizationContext}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
const wrappedComponent = wrapperComponent ? wrapperComponent(component) : component;
|
|
75
|
+
|
|
76
|
+
return testRenderWrapperChatbot(container, wrappedComponent, onAfterInit);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const doAskBot = (message: string) => {
|
|
81
|
+
ChatUiSelectors.chatInput.type(`${message}{enter}`, { delay: 0 });
|
|
82
|
+
};
|
|
83
|
+
const doTriggerFile = () => {
|
|
84
|
+
chatbotUiStore.setFilePickerEnabled(true);
|
|
85
|
+
cy.then(() => {
|
|
86
|
+
ChatUiSelectors.chatUploadFile.should('be.visible');
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
it('should render the chatbot component', () => {
|
|
91
|
+
mockAskBotApi("Hello! I'm chatbot mocked response!!!");
|
|
92
|
+
|
|
93
|
+
render();
|
|
94
|
+
|
|
95
|
+
// Pick filter
|
|
96
|
+
ChatUiSelectors.chatbotFilterButton.first().click();
|
|
97
|
+
ChatUiSelectors.chatbotFilterOptions.find('label').first().click();
|
|
98
|
+
ChatUiSelectors.chatbotFilterButton.first().click();
|
|
99
|
+
|
|
100
|
+
// Ask chatbot
|
|
101
|
+
doAskBot('Hello, Chatbot!');
|
|
102
|
+
doAskBot('Hello, Chatbot! Hello, Chatbot! Hello, Chatbot! Hello, Chatbot! Hello, Chatbot!');
|
|
103
|
+
doTriggerFile();
|
|
104
|
+
|
|
105
|
+
// Check if the message is sent
|
|
106
|
+
cy.get('@askBot').should('have.been.calledTwice');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('with error handling', () => {
|
|
110
|
+
const mockAskBotApiError = (errorMessage: string) => {
|
|
111
|
+
api.postMessage = cy.stub().as('askBot').rejects(new Error(errorMessage));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
it('should react on send message API error', () => {
|
|
115
|
+
mockAskBotApiError('Chatbot API error');
|
|
116
|
+
render();
|
|
117
|
+
|
|
118
|
+
doAskBot('Hello, Chatbot!');
|
|
119
|
+
|
|
120
|
+
cy.then(() => {
|
|
121
|
+
ChatUiSelectors.chatMessageFooter
|
|
122
|
+
.last()
|
|
123
|
+
.should('be.visible')
|
|
124
|
+
.should('contain.text', 'Message not delivered. Retry');
|
|
125
|
+
const errorBanner = ChatUiSelectors.chatError.should('be.visible').within(() => {
|
|
126
|
+
errorBanner
|
|
127
|
+
.find('.Banner__text > .Banner__title, [class^="_title-container"]')
|
|
128
|
+
.should('contain.text', 'Chat Error');
|
|
129
|
+
ChatUiSelectors.chatErrorText
|
|
130
|
+
.should('be.visible')
|
|
131
|
+
.should('contain.text', 'Failed to send message');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
cy.then(() => {
|
|
136
|
+
mockAskBotApi("Hello! I'm chatbot mocked response!!!");
|
|
137
|
+
ChatUiSelectors.chatMessageErrorRetry.click();
|
|
138
|
+
ChatUiSelectors.chatMessageContentAgent
|
|
139
|
+
.should('be.visible')
|
|
140
|
+
.should('contain.text', "Hello! I'm chatbot mocked response!!!");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
describe('with message feedback', () => {
|
|
146
|
+
it('should render the chatbot component', () => {
|
|
147
|
+
mockAskBotApi("Hello! I'm chatbot mocked response!!!");
|
|
148
|
+
render();
|
|
149
|
+
|
|
150
|
+
doAskBot('Hello!');
|
|
151
|
+
ChatUiSelectors.chatbotMessageFeedbackThumbsUp.should('be.visible').click();
|
|
152
|
+
cy.get('@askBotFeedback').should('have.been.calledOnce');
|
|
153
|
+
ChatUiSelectors.chatbotMessageFeedbackSuccess
|
|
154
|
+
.should('be.visible')
|
|
155
|
+
.should('contain.text', 'Thanks for your feedback.');
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
@@ -23,6 +23,18 @@ export class ChatUiSelectors {
|
|
|
23
23
|
static get chatUploadFile() {
|
|
24
24
|
return cy.getCy(ChatUiSelectors.cy.chatUploadFile);
|
|
25
25
|
}
|
|
26
|
+
static get chatUploadFileBtn() {
|
|
27
|
+
return cy.getCy(ChatUiSelectors.cy.chatUploadFileBtn);
|
|
28
|
+
}
|
|
29
|
+
static get chatUploadFileName() {
|
|
30
|
+
return cy.getCy(ChatUiSelectors.cy.chatUploadFileName);
|
|
31
|
+
}
|
|
32
|
+
static get chatUploadFileEdit() {
|
|
33
|
+
return cy.getCy(ChatUiSelectors.cy.chatUploadFileEdit);
|
|
34
|
+
}
|
|
35
|
+
static get chatUploadFileDelete() {
|
|
36
|
+
return cy.getCy(ChatUiSelectors.cy.chatUploadFileDelete);
|
|
37
|
+
}
|
|
26
38
|
static get chatMessageError() {
|
|
27
39
|
return cy.getCy(ChatUiSelectors.cy.chatMessageError);
|
|
28
40
|
}
|
|
@@ -161,6 +173,9 @@ export class ChatUiSelectors {
|
|
|
161
173
|
static get chatbotSessionFeedbackComment() {
|
|
162
174
|
return cy.getCy(ChatUiSelectors.cy.chatbotSessionFeedbackComment);
|
|
163
175
|
}
|
|
176
|
+
static get chatbotRestartDialog() {
|
|
177
|
+
return cy.getCy(ChatUiSelectors.cy.chatbotRestartDialog);
|
|
178
|
+
}
|
|
164
179
|
static get chatbotFilters() {
|
|
165
180
|
return cy.getCy(ChatUiSelectors.cy.chatbotFilters);
|
|
166
181
|
}
|
|
@@ -179,6 +194,9 @@ export class ChatUiSelectors {
|
|
|
179
194
|
static get chatbotFilterOptions() {
|
|
180
195
|
return cy.getCy(ChatUiSelectors.cy.chatbotFilterOptions);
|
|
181
196
|
}
|
|
197
|
+
static get chatbotFilterContent() {
|
|
198
|
+
return cy.getCy(ChatUiSelectors.cy.chatbotFilterContent);
|
|
199
|
+
}
|
|
182
200
|
static get chatbotLinksMore() {
|
|
183
201
|
return cy.getCy(ChatUiSelectors.cy.chatbotLinksMore);
|
|
184
202
|
}
|
|
@@ -201,6 +219,10 @@ export class ChatUiSelectors {
|
|
|
201
219
|
chatInput: 'titan-chat-input',
|
|
202
220
|
chatSend: 'titan-chat-send',
|
|
203
221
|
chatUploadFile: 'titan-chat-upload-file',
|
|
222
|
+
chatUploadFileBtn: 'titan-chat-upload-file-btn',
|
|
223
|
+
chatUploadFileName: 'titan-chat-upload-file-name',
|
|
224
|
+
chatUploadFileEdit: 'titan-chat-upload-file-edit',
|
|
225
|
+
chatUploadFileDelete: 'titan-chat-upload-file-delete',
|
|
204
226
|
chatMessageError: 'titan-chat-message-error',
|
|
205
227
|
chatMessageErrorRetry: 'titan-chat-message-error-retry',
|
|
206
228
|
chatNotifications: 'titan-chat-notifications',
|
|
@@ -241,12 +263,14 @@ export class ChatUiSelectors {
|
|
|
241
263
|
chatbotSessionFeedbackThumbsUp: 'titan-chatbot-session-feedback-thumbs-up',
|
|
242
264
|
chatbotSessionFeedbackThumbsDown: 'titan-chatbot-session-feedback-thumbs-down',
|
|
243
265
|
chatbotSessionFeedbackComment: 'titan-chatbot-session-feedback-comment',
|
|
266
|
+
chatbotRestartDialog: 'titan-chatbot-restart-dialog',
|
|
244
267
|
chatbotFilters: 'titan-chatbot-filters',
|
|
245
268
|
chatbotFilterSearch: 'titan-chatbot-filter-search',
|
|
246
269
|
chatbotFilterAll: 'titan-chatbot-filter-all',
|
|
247
270
|
chatbotFilterNone: 'titan-chatbot-filter-none',
|
|
248
271
|
chatbotFilterButton: 'titan-chatbot-filter-button',
|
|
249
272
|
chatbotFilterOptions: 'titan-chatbot-filter-options',
|
|
273
|
+
chatbotFilterContent: 'titan-chatbot-filter-content',
|
|
250
274
|
chatbotLinksMore: 'titan-chatbot-links-more',
|
|
251
275
|
chatbotLinksCollapsible: 'titan-chatbot-links-collapsible',
|
|
252
276
|
chatbotLinksLink: 'titan-chatbot-links-link',
|