@servicetitan/titan-chatbot-ui-cypress 3.1.1 → 3.1.3
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 +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/utils/chat-ui-selectors.d.ts +2 -0
- package/dist/utils/chat-ui-selectors.d.ts.map +1 -1
- package/dist/utils/chat-ui-selectors.js +4 -0
- package/dist/utils/chat-ui-selectors.js.map +1 -1
- package/package.json +5 -12
- package/src/index.ts +0 -3
- package/src/utils/chat-ui-selectors.ts +4 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/index.d.ts +0 -30
- package/dist/tests/index.d.ts.map +0 -1
- package/dist/tests/index.js +0 -30
- package/dist/tests/index.js.map +0 -1
- package/dist/tests/titan-chat-ui/chat-error.shared-tests.d.ts +0 -3
- package/dist/tests/titan-chat-ui/chat-error.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/chat-error.shared-tests.js +0 -138
- package/dist/tests/titan-chat-ui/chat-error.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/chat-input-file.shared-tests.d.ts +0 -7
- package/dist/tests/titan-chat-ui/chat-input-file.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/chat-input-file.shared-tests.js +0 -123
- package/dist/tests/titan-chat-ui/chat-input-file.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/chat-input.shared-tests.d.ts +0 -3
- package/dist/tests/titan-chat-ui/chat-input.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/chat-input.shared-tests.js +0 -71
- package/dist/tests/titan-chat-ui/chat-input.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/chat-log.shared-tests.d.ts +0 -9
- package/dist/tests/titan-chat-ui/chat-log.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/chat-log.shared-tests.js +0 -73
- package/dist/tests/titan-chat-ui/chat-log.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/chat-messages.shared-tests.d.ts +0 -8
- package/dist/tests/titan-chat-ui/chat-messages.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/chat-messages.shared-tests.js +0 -118
- package/dist/tests/titan-chat-ui/chat-messages.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/chat-notifications.shared-tests.d.ts +0 -3
- package/dist/tests/titan-chat-ui/chat-notifications.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/chat-notifications.shared-tests.js +0 -110
- package/dist/tests/titan-chat-ui/chat-notifications.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/chat-timer.shared-tests.d.ts +0 -3
- package/dist/tests/titan-chat-ui/chat-timer.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/chat-timer.shared-tests.js +0 -76
- package/dist/tests/titan-chat-ui/chat-timer.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/chat.shared-tests.d.ts +0 -9
- package/dist/tests/titan-chat-ui/chat.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/chat.shared-tests.js +0 -111
- package/dist/tests/titan-chat-ui/chat.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/message-agent.shared-tests.d.ts +0 -27
- package/dist/tests/titan-chat-ui/message-agent.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/message-agent.shared-tests.js +0 -67
- package/dist/tests/titan-chat-ui/message-agent.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/message-content-file.shared-tests.d.ts +0 -10
- package/dist/tests/titan-chat-ui/message-content-file.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/message-content-file.shared-tests.js +0 -88
- package/dist/tests/titan-chat-ui/message-content-file.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/message-system.shared-tests.d.ts +0 -16
- package/dist/tests/titan-chat-ui/message-system.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/message-system.shared-tests.js +0 -65
- package/dist/tests/titan-chat-ui/message-system.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/message-timeout.shared-tests.d.ts +0 -8
- package/dist/tests/titan-chat-ui/message-timeout.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/message-timeout.shared-tests.js +0 -63
- package/dist/tests/titan-chat-ui/message-timeout.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/message-typing.shared-tests.d.ts +0 -12
- package/dist/tests/titan-chat-ui/message-typing.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/message-typing.shared-tests.js +0 -46
- package/dist/tests/titan-chat-ui/message-typing.shared-tests.js.map +0 -1
- package/dist/tests/titan-chat-ui/message-user.shared-tests.d.ts +0 -10
- package/dist/tests/titan-chat-ui/message-user.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chat-ui/message-user.shared-tests.js +0 -64
- package/dist/tests/titan-chat-ui/message-user.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-filters.shared-tests.d.ts +0 -7
- package/dist/tests/titan-chatbot-ui/chatbot-filters.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-filters.shared-tests.js +0 -118
- package/dist/tests/titan-chatbot-ui/chatbot-filters.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.d.ts +0 -9
- package/dist/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.js +0 -162
- package/dist/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-links.shared-tests.d.ts +0 -15
- package/dist/tests/titan-chatbot-ui/chatbot-links.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-links.shared-tests.js +0 -123
- package/dist/tests/titan-chatbot-ui/chatbot-links.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-live.shared-tests.d.ts +0 -9
- package/dist/tests/titan-chatbot-ui/chatbot-live.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-live.shared-tests.js +0 -84
- package/dist/tests/titan-chatbot-ui/chatbot-live.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.d.ts +0 -8
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.js +0 -142
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.d.ts +0 -8
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.js +0 -105
- package/dist/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.d.ts +0 -3
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.js +0 -86
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.d.ts +0 -3
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.js +0 -143
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.d.ts +0 -8
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.js +0 -200
- package/dist/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.d.ts +0 -11
- package/dist/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.js +0 -81
- package/dist/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.d.ts +0 -8
- package/dist/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.js +0 -60
- package/dist/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.d.ts +0 -8
- package/dist/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.js +0 -77
- package/dist/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.d.ts +0 -7
- package/dist/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.js +0 -130
- package/dist/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.d.ts +0 -9
- package/dist/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.js +0 -157
- package/dist/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.js.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot.shared-tests.d.ts +0 -9
- package/dist/tests/titan-chatbot-ui/chatbot.shared-tests.d.ts.map +0 -1
- package/dist/tests/titan-chatbot-ui/chatbot.shared-tests.js +0 -114
- package/dist/tests/titan-chatbot-ui/chatbot.shared-tests.js.map +0 -1
- package/dist/utils/test-utils-chatbot.d.ts +0 -5
- package/dist/utils/test-utils-chatbot.d.ts.map +0 -1
- package/dist/utils/test-utils-chatbot.js +0 -55
- package/dist/utils/test-utils-chatbot.js.map +0 -1
- package/dist/utils/test-utils.d.ts +0 -6
- package/dist/utils/test-utils.d.ts.map +0 -1
- package/dist/utils/test-utils.js +0 -38
- package/dist/utils/test-utils.js.map +0 -1
- package/src/tests/index.ts +0 -30
- package/src/tests/titan-chat-ui/chat-error.shared-tests.tsx +0 -185
- package/src/tests/titan-chat-ui/chat-input-file.shared-tests.tsx +0 -182
- package/src/tests/titan-chat-ui/chat-input.shared-tests.tsx +0 -99
- package/src/tests/titan-chat-ui/chat-log.shared-tests.tsx +0 -117
- package/src/tests/titan-chat-ui/chat-messages.shared-tests.tsx +0 -156
- package/src/tests/titan-chat-ui/chat-notifications.shared-tests.tsx +0 -153
- package/src/tests/titan-chat-ui/chat-timer.shared-tests.tsx +0 -106
- package/src/tests/titan-chat-ui/chat.shared-tests.tsx +0 -158
- package/src/tests/titan-chat-ui/message-agent.shared-tests.tsx +0 -170
- package/src/tests/titan-chat-ui/message-content-file.shared-tests.tsx +0 -139
- package/src/tests/titan-chat-ui/message-system.shared-tests.tsx +0 -147
- package/src/tests/titan-chat-ui/message-timeout.shared-tests.tsx +0 -117
- package/src/tests/titan-chat-ui/message-typing.shared-tests.tsx +0 -92
- package/src/tests/titan-chat-ui/message-user.shared-tests.tsx +0 -138
- package/src/tests/titan-chatbot-ui/chatbot-filters.shared-tests.tsx +0 -164
- package/src/tests/titan-chatbot-ui/chatbot-help-center.shared-tests.tsx +0 -225
- package/src/tests/titan-chatbot-ui/chatbot-links.shared-tests.tsx +0 -189
- package/src/tests/titan-chatbot-ui/chatbot-live.shared-tests.tsx +0 -127
- package/src/tests/titan-chatbot-ui/chatbot-message-answer-readonly.shared-tests.tsx +0 -187
- package/src/tests/titan-chatbot-ui/chatbot-message-answer.shared-tests.tsx +0 -144
- package/src/tests/titan-chatbot-ui/chatbot-message-feedback-form-guardrail.shared-tests.tsx +0 -127
- package/src/tests/titan-chatbot-ui/chatbot-message-feedback-form.shared-tests.tsx +0 -198
- package/src/tests/titan-chatbot-ui/chatbot-message-feedback-popover.shared-tests.tsx +0 -285
- package/src/tests/titan-chatbot-ui/chatbot-message-typing.shared-tests.tsx +0 -112
- package/src/tests/titan-chatbot-ui/chatbot-restart-dialog.shared-tests.tsx +0 -91
- package/src/tests/titan-chatbot-ui/chatbot-restart-link.shared-tests.tsx +0 -116
- package/src/tests/titan-chatbot-ui/chatbot-session-feedback-modal.shared-tests.tsx +0 -182
- package/src/tests/titan-chatbot-ui/chatbot-titan-chatbot.shared-tests.tsx +0 -221
- package/src/tests/titan-chatbot-ui/chatbot.shared-tests.tsx +0 -158
- package/src/utils/test-utils-chatbot.tsx +0 -73
- package/src/utils/test-utils.tsx +0 -52
|
@@ -1,182 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,221 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { ILog, Log } from '@servicetitan/log-service';
|
|
2
|
-
import { Container, provide } from '@servicetitan/react-ioc';
|
|
3
|
-
import { ChatParticipantIcon } from '@servicetitan/titan-chat-ui-common';
|
|
4
|
-
import {
|
|
5
|
-
CHATBOT_API_CLIENT,
|
|
6
|
-
CHATBOT_UI_BACKEND_STORE_TOKEN,
|
|
7
|
-
CHATBOT_UI_STORE_TOKEN,
|
|
8
|
-
ChatbotUiBackendStore,
|
|
9
|
-
ChatbotUiStore,
|
|
10
|
-
IChatbotApiClient,
|
|
11
|
-
IChatbotUiBackendStore,
|
|
12
|
-
IChatbotUiStore,
|
|
13
|
-
} from '@servicetitan/titan-chatbot-api';
|
|
14
|
-
import { mount } from 'cypress/react';
|
|
15
|
-
import { FC, ReactNode } from 'react';
|
|
16
|
-
import { CypressMocks } from '..';
|
|
17
|
-
|
|
18
|
-
export const testInitContainerChatbot = () => {
|
|
19
|
-
const rootContainer = new Container();
|
|
20
|
-
const container = new Container();
|
|
21
|
-
container.parent = rootContainer;
|
|
22
|
-
container.bind<ILog>(Log).to(CypressMocks.LogMock).inSingletonScope();
|
|
23
|
-
container
|
|
24
|
-
.bind<IChatbotApiClient>(CHATBOT_API_CLIENT)
|
|
25
|
-
.to(CypressMocks.ChatbotApiClientMock)
|
|
26
|
-
.inSingletonScope();
|
|
27
|
-
container.bind<IChatbotUiStore>(CHATBOT_UI_STORE_TOKEN).to(ChatbotUiStore).inSingletonScope();
|
|
28
|
-
container
|
|
29
|
-
.bind<IChatbotUiBackendStore>(CHATBOT_UI_BACKEND_STORE_TOKEN)
|
|
30
|
-
.to(ChatbotUiBackendStore)
|
|
31
|
-
.inSingletonScope();
|
|
32
|
-
return container;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const testRenderWrapperChatbot = async (
|
|
36
|
-
container: Container,
|
|
37
|
-
component: ReactNode,
|
|
38
|
-
onAfterInit: () => void = () => {}
|
|
39
|
-
) => {
|
|
40
|
-
const log = container.get<ILog>(Log);
|
|
41
|
-
const chatbotApiClient = container.get<IChatbotApiClient>(CHATBOT_API_CLIENT);
|
|
42
|
-
const chatbotUiStore = container.get<IChatbotUiStore>(CHATBOT_UI_STORE_TOKEN);
|
|
43
|
-
const chatbotUiBackendStore = container.get<IChatbotUiBackendStore>(
|
|
44
|
-
CHATBOT_UI_BACKEND_STORE_TOKEN
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
chatbotUiBackendStore.subscribe();
|
|
48
|
-
await chatbotUiStore.run({
|
|
49
|
-
agentName: 'EchoBot',
|
|
50
|
-
agentIcon: ChatParticipantIcon.Bot,
|
|
51
|
-
});
|
|
52
|
-
onAfterInit?.();
|
|
53
|
-
|
|
54
|
-
const RenderWrapper: FC = provide({
|
|
55
|
-
singletons: [
|
|
56
|
-
{
|
|
57
|
-
provide: Log,
|
|
58
|
-
useValue: log,
|
|
59
|
-
},
|
|
60
|
-
{ provide: CHATBOT_API_CLIENT, useValue: chatbotApiClient },
|
|
61
|
-
{
|
|
62
|
-
provide: CHATBOT_UI_STORE_TOKEN,
|
|
63
|
-
useValue: chatbotUiStore,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
provide: CHATBOT_UI_BACKEND_STORE_TOKEN,
|
|
67
|
-
useValue: chatbotUiBackendStore,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
})(() => component);
|
|
71
|
-
RenderWrapper.displayName = 'RenderWrapper';
|
|
72
|
-
mount(<RenderWrapper />);
|
|
73
|
-
};
|
package/src/utils/test-utils.tsx
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Container, provide } from '@servicetitan/react-ioc';
|
|
2
|
-
import {
|
|
3
|
-
CHAT_UI_BACKEND_STORE_TOKEN,
|
|
4
|
-
CHAT_UI_STORE_TOKEN,
|
|
5
|
-
ChatParticipantIcon,
|
|
6
|
-
ChatUiBackendEchoStore,
|
|
7
|
-
ChatUiStore,
|
|
8
|
-
IChatUiBackendStore,
|
|
9
|
-
IChatUiStore,
|
|
10
|
-
} from '@servicetitan/titan-chat-ui-common';
|
|
11
|
-
import { mount } from 'cypress/react';
|
|
12
|
-
import { FC, ReactNode } from 'react';
|
|
13
|
-
|
|
14
|
-
export const testInitContainer = () => {
|
|
15
|
-
const rootContainer = new Container();
|
|
16
|
-
const container = new Container();
|
|
17
|
-
container.parent = rootContainer;
|
|
18
|
-
container.bind<IChatUiStore>(CHAT_UI_STORE_TOKEN).to(ChatUiStore).inSingletonScope();
|
|
19
|
-
container
|
|
20
|
-
.bind<IChatUiBackendStore>(CHAT_UI_BACKEND_STORE_TOKEN)
|
|
21
|
-
.to(ChatUiBackendEchoStore)
|
|
22
|
-
.inSingletonScope();
|
|
23
|
-
return container;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const testRenderWrapper = async (
|
|
27
|
-
chatUiStore: IChatUiStore,
|
|
28
|
-
chatUiBackendStore: IChatUiBackendStore,
|
|
29
|
-
component: ReactNode,
|
|
30
|
-
onAfterInit: () => void = () => {}
|
|
31
|
-
) => {
|
|
32
|
-
chatUiBackendStore.subscribe();
|
|
33
|
-
await chatUiStore.run({
|
|
34
|
-
agentName: 'EchoBot',
|
|
35
|
-
agentIcon: ChatParticipantIcon.Bot,
|
|
36
|
-
});
|
|
37
|
-
onAfterInit?.();
|
|
38
|
-
const RenderWrapper: FC = provide({
|
|
39
|
-
singletons: [
|
|
40
|
-
{
|
|
41
|
-
provide: CHAT_UI_STORE_TOKEN,
|
|
42
|
-
useValue: chatUiStore,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
provide: CHAT_UI_BACKEND_STORE_TOKEN,
|
|
46
|
-
useValue: chatUiBackendStore,
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
})(() => component);
|
|
50
|
-
RenderWrapper.displayName = 'RenderWrapper';
|
|
51
|
-
mount(<RenderWrapper />);
|
|
52
|
-
};
|