@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,187 +0,0 @@
|
|
|
1
|
-
import { Container } from '@servicetitan/react-ioc';
|
|
2
|
-
import { ChatMessageModelText, mockChatMessageModelText } from '@servicetitan/titan-chat-ui-common';
|
|
3
|
-
import { CHATBOT_API_CLIENT, Models, ModelsMocks } from '@servicetitan/titan-chatbot-api';
|
|
4
|
-
import { FC, ReactElement } from 'react';
|
|
5
|
-
import { CypressMocks, testInitContainerChatbot, testRenderWrapperChatbot } from '../..';
|
|
6
|
-
import { ChatUiSelectors } from '../../utils/chat-ui-selectors';
|
|
7
|
-
|
|
8
|
-
interface IChatbotMessageAnswerReadonlyProps {
|
|
9
|
-
message: ChatMessageModelText;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function runChatbotMessageAnswerReadonlySharedTests(
|
|
13
|
-
ChatbotMessageAnswerReadonlyComponent: FC<IChatbotMessageAnswerReadonlyProps>,
|
|
14
|
-
wrapperComponent?: (component: ReactElement) => ReactElement
|
|
15
|
-
) {
|
|
16
|
-
let container: Container;
|
|
17
|
-
let api: CypressMocks.ChatbotApiClientMock;
|
|
18
|
-
|
|
19
|
-
const mockApiClient = () => {
|
|
20
|
-
api.postSession = cy.stub().resolves(ModelsMocks.mockSession());
|
|
21
|
-
api.getOptions = cy.stub().resolves(ModelsMocks.mockFrontendModel());
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
container = testInitContainerChatbot();
|
|
26
|
-
api = container.get<CypressMocks.ChatbotApiClientMock>(CHATBOT_API_CLIENT);
|
|
27
|
-
mockApiClient();
|
|
28
|
-
cy.viewport(550, 800);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const render = (message: ChatMessageModelText, onAfterInit?: () => void) => {
|
|
32
|
-
return cy.wrap(null).then(() => {
|
|
33
|
-
const component = <ChatbotMessageAnswerReadonlyComponent message={message} />;
|
|
34
|
-
const wrappedComponent = wrapperComponent ? wrapperComponent(component) : component;
|
|
35
|
-
|
|
36
|
-
return testRenderWrapperChatbot(container, wrappedComponent, onAfterInit);
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
it('should render basic readonly message answer', () => {
|
|
41
|
-
const message = mockChatMessageModelText(false, {
|
|
42
|
-
message: 'This is a readonly answer from the chatbot',
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
render(message);
|
|
46
|
-
|
|
47
|
-
cy.contains('This is a readonly answer from the chatbot').should('be.visible');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should render multiline text correctly', () => {
|
|
51
|
-
const multilineMessage = 'Line 1\nLine 2\nLine 3';
|
|
52
|
-
const message = mockChatMessageModelText(false, {
|
|
53
|
-
message: multilineMessage,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
render(message);
|
|
57
|
-
|
|
58
|
-
cy.contains('Line 1').should('be.visible');
|
|
59
|
-
cy.contains('Line 2').should('be.visible');
|
|
60
|
-
cy.contains('Line 3').should('be.visible');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should render readonly message without bot message data', () => {
|
|
64
|
-
const message = mockChatMessageModelText(false, {
|
|
65
|
-
message: 'Simple readonly answer',
|
|
66
|
-
data: undefined,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
render(message);
|
|
70
|
-
|
|
71
|
-
cy.contains('Simple readonly answer').should('be.visible');
|
|
72
|
-
|
|
73
|
-
// Should not render links when no bot message data
|
|
74
|
-
ChatUiSelectors.chatbotLinksLink.should('not.exist');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('should render readonly message with bot message data but no links', () => {
|
|
78
|
-
const botMessageWithoutLinks: Models.IBotMessageWithFeedback = {
|
|
79
|
-
...ModelsMocks.mockBotMessage({ answer: 'Answer without links' }),
|
|
80
|
-
scoredUrls: [],
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const message = mockChatMessageModelText(false, {
|
|
84
|
-
message: 'Answer without links',
|
|
85
|
-
data: botMessageWithoutLinks,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
render(message);
|
|
89
|
-
|
|
90
|
-
cy.contains('Answer without links').should('be.visible');
|
|
91
|
-
|
|
92
|
-
// Should not render links when scoredUrls is empty
|
|
93
|
-
ChatUiSelectors.chatbotLinksCollapsible.should('not.exist');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('should render readonly message with bot message data and links', () => {
|
|
97
|
-
const botMessageWithFeedback: Models.IBotMessageWithFeedback = {
|
|
98
|
-
...ModelsMocks.mockBotMessage({ answer: 'Readonly answer with links' }),
|
|
99
|
-
scoredUrls: [
|
|
100
|
-
ModelsMocks.mockScoredUrl({
|
|
101
|
-
url: 'https://example.com/article1',
|
|
102
|
-
title: 'Example Article 1',
|
|
103
|
-
score: 0.9,
|
|
104
|
-
}),
|
|
105
|
-
ModelsMocks.mockScoredUrl({
|
|
106
|
-
url: 'https://example.com/article2',
|
|
107
|
-
title: 'Example Article 2',
|
|
108
|
-
score: 0.8,
|
|
109
|
-
}),
|
|
110
|
-
ModelsMocks.mockScoredUrl({
|
|
111
|
-
url: 'https://example.com/article3',
|
|
112
|
-
title: 'Example Article 3',
|
|
113
|
-
score: 0.7,
|
|
114
|
-
}),
|
|
115
|
-
],
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const message = mockChatMessageModelText(false, {
|
|
119
|
-
message: 'Readonly answer with links',
|
|
120
|
-
data: botMessageWithFeedback,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
render(message);
|
|
124
|
-
|
|
125
|
-
cy.contains('Readonly answer with links').should('be.visible');
|
|
126
|
-
|
|
127
|
-
// Check that links are rendered with correct labels
|
|
128
|
-
ChatUiSelectors.chatbotLinksMore.should('contain.text', 'Learn more').click();
|
|
129
|
-
ChatUiSelectors.chatbotLinksLink.should('be.visible');
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('should render readonly message with bot message data and single link', () => {
|
|
133
|
-
const botMessageWithSingleLink: Models.IBotMessageWithFeedback = {
|
|
134
|
-
...ModelsMocks.mockBotMessage({ answer: 'Answer with single link' }),
|
|
135
|
-
scoredUrls: [
|
|
136
|
-
ModelsMocks.mockScoredUrl({
|
|
137
|
-
url: 'https://example.com/single-article',
|
|
138
|
-
title: 'Single Article',
|
|
139
|
-
score: 0.95,
|
|
140
|
-
}),
|
|
141
|
-
],
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const message = mockChatMessageModelText(false, {
|
|
145
|
-
message: 'Answer with single link',
|
|
146
|
-
data: botMessageWithSingleLink,
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
render(message);
|
|
150
|
-
|
|
151
|
-
cy.contains('Answer with single link').should('be.visible');
|
|
152
|
-
|
|
153
|
-
// Check that single link is rendered
|
|
154
|
-
ChatUiSelectors.chatbotLinksMore.should('be.visible').click();
|
|
155
|
-
ChatUiSelectors.chatbotLinksLink.should('have.length', 1);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('should handle null/undefined scoredUrls gracefully', () => {
|
|
159
|
-
const botMessageWithNullUrls: Models.IBotMessageWithFeedback = {
|
|
160
|
-
...ModelsMocks.mockBotMessage({ answer: 'Answer with null URLs' }),
|
|
161
|
-
scoredUrls: null as any,
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const message = mockChatMessageModelText(false, {
|
|
165
|
-
message: 'Answer with null URLs',
|
|
166
|
-
data: botMessageWithNullUrls,
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
render(message);
|
|
170
|
-
|
|
171
|
-
cy.contains('Answer with null URLs').should('be.visible');
|
|
172
|
-
|
|
173
|
-
// Should not render links when scoredUrls is null
|
|
174
|
-
ChatUiSelectors.chatbotLinksCollapsible.should('not.exist');
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('should render empty message gracefully', () => {
|
|
178
|
-
const message = mockChatMessageModelText(false, {
|
|
179
|
-
message: '',
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
render(message);
|
|
183
|
-
|
|
184
|
-
// Component should still render even with empty message
|
|
185
|
-
cy.get('body').should('be.visible');
|
|
186
|
-
});
|
|
187
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { Container } from '@servicetitan/react-ioc';
|
|
2
|
-
import { ChatMessageModelText, mockChatMessageModelText } from '@servicetitan/titan-chat-ui-common';
|
|
3
|
-
import {
|
|
4
|
-
CHATBOT_API_CLIENT,
|
|
5
|
-
CHATBOT_UI_STORE_TOKEN,
|
|
6
|
-
ChatbotUiStore,
|
|
7
|
-
IChatbotUiStore,
|
|
8
|
-
Models,
|
|
9
|
-
ModelsMocks,
|
|
10
|
-
} from '@servicetitan/titan-chatbot-api';
|
|
11
|
-
import { FC, ReactElement } from 'react';
|
|
12
|
-
import { CypressMocks, testInitContainerChatbot, testRenderWrapperChatbot } from '../..';
|
|
13
|
-
import { ChatUiSelectors } from '../../utils/chat-ui-selectors';
|
|
14
|
-
|
|
15
|
-
interface IChatbotMessageAnswerProps {
|
|
16
|
-
message: ChatMessageModelText;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function runChatbotMessageAnswerSharedTests(
|
|
20
|
-
ChatbotMessageAnswerComponent: FC<IChatbotMessageAnswerProps>,
|
|
21
|
-
wrapperComponent?: (component: ReactElement) => ReactElement
|
|
22
|
-
) {
|
|
23
|
-
let container: Container;
|
|
24
|
-
let api: CypressMocks.ChatbotApiClientMock;
|
|
25
|
-
let chatbotUiStore: IChatbotUiStore;
|
|
26
|
-
|
|
27
|
-
const mockApiClient = () => {
|
|
28
|
-
api.postSession = cy.stub().resolves(ModelsMocks.mockSession());
|
|
29
|
-
api.getOptions = cy.stub().resolves(ModelsMocks.mockFrontendModel());
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
container = testInitContainerChatbot();
|
|
34
|
-
api = container.get<CypressMocks.ChatbotApiClientMock>(CHATBOT_API_CLIENT);
|
|
35
|
-
chatbotUiStore = container.get<ChatbotUiStore>(CHATBOT_UI_STORE_TOKEN);
|
|
36
|
-
mockApiClient();
|
|
37
|
-
cy.viewport(550, 800);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const render = (message: ChatMessageModelText, onAfterInit?: () => void) => {
|
|
41
|
-
return cy.wrap(null).then(() => {
|
|
42
|
-
const component = <ChatbotMessageAnswerComponent message={message} />;
|
|
43
|
-
const wrappedComponent = wrapperComponent ? wrapperComponent(component) : component;
|
|
44
|
-
|
|
45
|
-
return testRenderWrapperChatbot(container, wrappedComponent, onAfterInit);
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
it('should render basic message answer', () => {
|
|
50
|
-
const message = mockChatMessageModelText(false, {
|
|
51
|
-
message: 'This is a test answer from the chatbot',
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
render(message);
|
|
55
|
-
|
|
56
|
-
ChatUiSelectors.chatbotMessageAnswer.should('be.visible');
|
|
57
|
-
ChatUiSelectors.chatbotMessageAnswer.should(
|
|
58
|
-
'contain.text',
|
|
59
|
-
'This is a test answer from the chatbot'
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('should render message answer with bot message data and links', () => {
|
|
64
|
-
const botMessageWithFeedback: Models.IBotMessageWithFeedback = {
|
|
65
|
-
...ModelsMocks.mockBotMessage({ answer: 'Test answer with links' }),
|
|
66
|
-
scoredUrls: [
|
|
67
|
-
ModelsMocks.mockScoredUrl({
|
|
68
|
-
url: 'https://example.com/article1',
|
|
69
|
-
title: 'Example Article 1',
|
|
70
|
-
score: 0.9,
|
|
71
|
-
}),
|
|
72
|
-
ModelsMocks.mockScoredUrl({
|
|
73
|
-
url: 'https://example.com/article2',
|
|
74
|
-
title: 'Example Article 2',
|
|
75
|
-
score: 0.8,
|
|
76
|
-
}),
|
|
77
|
-
],
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const message = mockChatMessageModelText(false, {
|
|
81
|
-
message: 'Test answer with links',
|
|
82
|
-
data: botMessageWithFeedback,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
render(message);
|
|
86
|
-
|
|
87
|
-
ChatUiSelectors.chatbotMessageAnswer.should('be.visible');
|
|
88
|
-
ChatUiSelectors.chatbotMessageAnswer.should('contain.text', 'Test answer with links');
|
|
89
|
-
|
|
90
|
-
// Check that links are rendered
|
|
91
|
-
ChatUiSelectors.chatbotLinksMore.should('contain.text', 'Learn more').click();
|
|
92
|
-
ChatUiSelectors.chatbotLinksLink.should('be.visible');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should render multiline text correctly', () => {
|
|
96
|
-
const multilineMessage = 'Line 1\nLine 2\nLine 3';
|
|
97
|
-
const message = mockChatMessageModelText(false, {
|
|
98
|
-
message: multilineMessage,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
render(message);
|
|
102
|
-
|
|
103
|
-
ChatUiSelectors.chatbotMessageAnswer.should('be.visible');
|
|
104
|
-
ChatUiSelectors.chatbotMessageAnswer.should('contain.text', 'Line 1');
|
|
105
|
-
ChatUiSelectors.chatbotMessageAnswer.should('contain.text', 'Line 2');
|
|
106
|
-
ChatUiSelectors.chatbotMessageAnswer.should('contain.text', 'Line 3');
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('should trigger scroll when links are toggled for last message', () => {
|
|
110
|
-
const botMessageWithFeedback: Models.IBotMessageWithFeedback = {
|
|
111
|
-
...ModelsMocks.mockBotMessage({ answer: 'Last message with links' }),
|
|
112
|
-
scoredUrls: [
|
|
113
|
-
ModelsMocks.mockScoredUrl({
|
|
114
|
-
url: 'https://example.com/article',
|
|
115
|
-
title: 'Example Article',
|
|
116
|
-
score: 0.9,
|
|
117
|
-
}),
|
|
118
|
-
],
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const message = mockChatMessageModelText(false, {
|
|
122
|
-
message: 'Last message with links',
|
|
123
|
-
data: botMessageWithFeedback,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
render(message, () => {
|
|
127
|
-
// Set this message as the last message in the store
|
|
128
|
-
chatbotUiStore.setMessages([message]);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
cy.wait(1).then(() => {
|
|
132
|
-
// Verify the message is the last one in the store
|
|
133
|
-
expect(chatbotUiStore.messages.at(-1)?.id).to.equal(message.id);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
ChatUiSelectors.chatbotMessageAnswer.should('be.visible');
|
|
137
|
-
|
|
138
|
-
// Toggle links to trigger scroll
|
|
139
|
-
ChatUiSelectors.chatbotLinksMore.click();
|
|
140
|
-
|
|
141
|
-
// Verify scroll was triggered (this would be implementation-specific)
|
|
142
|
-
cy.wait(150); // Wait for setTimeout to complete
|
|
143
|
-
});
|
|
144
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { Container, Provider, useDependencies } from '@servicetitan/react-ioc';
|
|
2
|
-
import {
|
|
3
|
-
CHATBOT_API_CLIENT,
|
|
4
|
-
MessageFeedbackGuardrailStore,
|
|
5
|
-
ModelsMocks,
|
|
6
|
-
} from '@servicetitan/titan-chatbot-api';
|
|
7
|
-
import { FC, ReactElement } from 'react';
|
|
8
|
-
import { CypressMocks, testInitContainerChatbot, testRenderWrapperChatbot } from '../..';
|
|
9
|
-
import { ChatUiSelectors } from '../../utils/chat-ui-selectors';
|
|
10
|
-
|
|
11
|
-
export function runChatbotMessageFeedbackFormGuardrailSharedTests(
|
|
12
|
-
ChatbotMessageFeedbackFormGuardrailComponent: FC,
|
|
13
|
-
wrapperComponent?: (component: ReactElement) => ReactElement
|
|
14
|
-
) {
|
|
15
|
-
let container: Container;
|
|
16
|
-
let api: CypressMocks.ChatbotApiClientMock;
|
|
17
|
-
let messageFeedbackGuardrailStore: MessageFeedbackGuardrailStore;
|
|
18
|
-
|
|
19
|
-
const mockApiClient = () => {
|
|
20
|
-
api.postSession = cy.stub().resolves(ModelsMocks.mockSession());
|
|
21
|
-
api.getOptions = cy.stub().resolves(ModelsMocks.mockFrontendModel());
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
container = testInitContainerChatbot();
|
|
26
|
-
container.bind(MessageFeedbackGuardrailStore).toSelf().inSingletonScope();
|
|
27
|
-
api = container.get<CypressMocks.ChatbotApiClientMock>(CHATBOT_API_CLIENT);
|
|
28
|
-
messageFeedbackGuardrailStore = container.get(MessageFeedbackGuardrailStore);
|
|
29
|
-
mockApiClient();
|
|
30
|
-
cy.viewport(550, 800);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const getFormError = () => cy.get('[data-anvil-component="Banner"]');
|
|
34
|
-
const checkValid = () => {
|
|
35
|
-
cy.getCy('validator').click();
|
|
36
|
-
getFormError().should('not.exist');
|
|
37
|
-
};
|
|
38
|
-
const checkInvalid = () => {
|
|
39
|
-
cy.getCy('validator').click();
|
|
40
|
-
getFormError().should('be.visible');
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const render = (onAfterInit?: () => void) => {
|
|
44
|
-
return cy.wrap(null).then(() => {
|
|
45
|
-
const Validator: FC = () => {
|
|
46
|
-
const [formStore] = useDependencies(MessageFeedbackGuardrailStore);
|
|
47
|
-
return (
|
|
48
|
-
<button
|
|
49
|
-
className="m-t-3"
|
|
50
|
-
data-cy="validator"
|
|
51
|
-
onClick={() => formStore.formState.validate()}
|
|
52
|
-
>
|
|
53
|
-
Validate
|
|
54
|
-
</button>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const component = (
|
|
59
|
-
<Provider
|
|
60
|
-
singletons={[
|
|
61
|
-
{
|
|
62
|
-
provide: MessageFeedbackGuardrailStore,
|
|
63
|
-
useValue: messageFeedbackGuardrailStore,
|
|
64
|
-
},
|
|
65
|
-
]}
|
|
66
|
-
>
|
|
67
|
-
<ChatbotMessageFeedbackFormGuardrailComponent />
|
|
68
|
-
<Validator />
|
|
69
|
-
</Provider>
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const wrappedComponent = wrapperComponent ? wrapperComponent(component) : component;
|
|
73
|
-
|
|
74
|
-
return testRenderWrapperChatbot(container, wrappedComponent, onAfterInit);
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
it('should render form', () => {
|
|
79
|
-
render();
|
|
80
|
-
|
|
81
|
-
ChatUiSelectors.chatbotMessageFeedback.should('be.visible');
|
|
82
|
-
ChatUiSelectors.chatbotMessageFeedbackLinkUrl.should('be.visible');
|
|
83
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.should('be.visible');
|
|
84
|
-
checkInvalid();
|
|
85
|
-
getFormError().find('.Banner__title').should('contain.text', 'Form Incomplete');
|
|
86
|
-
getFormError()
|
|
87
|
-
.find('ul > li')
|
|
88
|
-
.should('contain.text', 'At least one input must be provided.');
|
|
89
|
-
|
|
90
|
-
ChatUiSelectors.chatbotMessageFeedbackLinkUrl.type('https://example.com');
|
|
91
|
-
checkValid();
|
|
92
|
-
|
|
93
|
-
ChatUiSelectors.chatbotMessageFeedbackLinkUrl.clear();
|
|
94
|
-
checkInvalid();
|
|
95
|
-
|
|
96
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.type('Test comment');
|
|
97
|
-
checkValid();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should validate form when both fields are filled', () => {
|
|
101
|
-
render();
|
|
102
|
-
|
|
103
|
-
ChatUiSelectors.chatbotMessageFeedbackLinkUrl.type('https://example.com');
|
|
104
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.type('Additional feedback comment');
|
|
105
|
-
checkValid();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('should show error when form is submitted empty', () => {
|
|
109
|
-
render();
|
|
110
|
-
|
|
111
|
-
checkInvalid();
|
|
112
|
-
getFormError().should('be.visible');
|
|
113
|
-
getFormError().find('.Banner__title').should('contain.text', 'Form Incomplete');
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('should clear validation error when valid input is provided', () => {
|
|
117
|
-
render();
|
|
118
|
-
|
|
119
|
-
// First show the error
|
|
120
|
-
checkInvalid();
|
|
121
|
-
getFormError().should('be.visible');
|
|
122
|
-
|
|
123
|
-
// Then provide valid input
|
|
124
|
-
ChatUiSelectors.chatbotMessageFeedbackLinkUrl.type('https://valid-url.com');
|
|
125
|
-
checkValid();
|
|
126
|
-
});
|
|
127
|
-
}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { Container, Provider, useDependencies } from '@servicetitan/react-ioc';
|
|
2
|
-
import {
|
|
3
|
-
CHATBOT_API_CLIENT,
|
|
4
|
-
CHATBOT_UI_STORE_TOKEN,
|
|
5
|
-
ChatbotUiStore,
|
|
6
|
-
IChatbotUiStore,
|
|
7
|
-
MessageFeedbackStore,
|
|
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
|
-
export function runChatbotMessageFeedbackFormSharedTests(
|
|
15
|
-
ChatbotMessageFeedbackFormComponent: FC,
|
|
16
|
-
wrapperComponent?: (component: ReactElement) => ReactElement
|
|
17
|
-
) {
|
|
18
|
-
let container: Container;
|
|
19
|
-
let api: CypressMocks.ChatbotApiClientMock;
|
|
20
|
-
let chatbotUiStore: IChatbotUiStore;
|
|
21
|
-
let messageFeedbackStore: MessageFeedbackStore;
|
|
22
|
-
|
|
23
|
-
const mockApiClient = () => {
|
|
24
|
-
api.postSession = cy.stub().resolves(ModelsMocks.mockSession());
|
|
25
|
-
api.getOptions = cy.stub().resolves(ModelsMocks.mockFrontendModel());
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
container = testInitContainerChatbot();
|
|
30
|
-
container.bind<MessageFeedbackStore>(MessageFeedbackStore).toSelf().inSingletonScope();
|
|
31
|
-
api = container.get<CypressMocks.ChatbotApiClientMock>(CHATBOT_API_CLIENT);
|
|
32
|
-
chatbotUiStore = container.get<ChatbotUiStore>(CHATBOT_UI_STORE_TOKEN);
|
|
33
|
-
messageFeedbackStore = container.get<MessageFeedbackStore>(MessageFeedbackStore);
|
|
34
|
-
mockApiClient();
|
|
35
|
-
cy.viewport(550, 800);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const getFormError = () =>
|
|
39
|
-
ChatUiSelectors.chatbotMessageFeedback.find(
|
|
40
|
-
'.FormField__errorText,[class^="_error-container"]'
|
|
41
|
-
);
|
|
42
|
-
const checkValid = () => {
|
|
43
|
-
cy.getCy('validator').click();
|
|
44
|
-
getFormError().should('not.exist');
|
|
45
|
-
};
|
|
46
|
-
const checkInvalid = () => {
|
|
47
|
-
cy.getCy('validator').click();
|
|
48
|
-
getFormError().should('be.visible');
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const render = (onAfterInit?: () => void) => {
|
|
52
|
-
return cy.wrap(null).then(() => {
|
|
53
|
-
const Validator: FC = () => {
|
|
54
|
-
const [formStore] = useDependencies(MessageFeedbackStore);
|
|
55
|
-
return (
|
|
56
|
-
<button
|
|
57
|
-
style={{ marginTop: '20px' }}
|
|
58
|
-
data-cy="validator"
|
|
59
|
-
onClick={() => formStore.formState.validate()}
|
|
60
|
-
>
|
|
61
|
-
Validate
|
|
62
|
-
</button>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const component = (
|
|
67
|
-
<Provider
|
|
68
|
-
singletons={[
|
|
69
|
-
{
|
|
70
|
-
provide: MessageFeedbackStore,
|
|
71
|
-
useValue: messageFeedbackStore,
|
|
72
|
-
},
|
|
73
|
-
]}
|
|
74
|
-
>
|
|
75
|
-
<ChatbotMessageFeedbackFormComponent />
|
|
76
|
-
<Validator />
|
|
77
|
-
</Provider>
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const wrappedComponent = wrapperComponent ? wrapperComponent(component) : component;
|
|
81
|
-
|
|
82
|
-
return testRenderWrapperChatbot(container, wrappedComponent, onAfterInit);
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
it('should render default state external', () => {
|
|
87
|
-
render();
|
|
88
|
-
cy.clock(Date.parse('2023-10-01T00:00:00Z'));
|
|
89
|
-
|
|
90
|
-
// Default render
|
|
91
|
-
ChatUiSelectors.chatbotMessageFeedback.should('be.visible');
|
|
92
|
-
ChatUiSelectors.chatbotMessageFeedbackUnrelated.should('be.visible');
|
|
93
|
-
ChatUiSelectors.chatbotMessageFeedbackUnclear.should('be.visible');
|
|
94
|
-
ChatUiSelectors.chatbotMessageFeedbackNotFull.should('be.visible');
|
|
95
|
-
ChatUiSelectors.chatbotMessageFeedbackIncorrect.should('be.visible');
|
|
96
|
-
ChatUiSelectors.chatbotMessageFeedbackOther.should('be.visible');
|
|
97
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.should('not.exist');
|
|
98
|
-
checkValid();
|
|
99
|
-
|
|
100
|
-
// Click 'other' and check comment textarea
|
|
101
|
-
ChatUiSelectors.chatbotMessageFeedbackOther.parent().find('input').click({ force: true });
|
|
102
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment
|
|
103
|
-
.should('be.visible')
|
|
104
|
-
.type('Test comment');
|
|
105
|
-
getFormError().should('not.exist');
|
|
106
|
-
checkValid();
|
|
107
|
-
|
|
108
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.clear().blur();
|
|
109
|
-
getFormError().should('be.visible').should('contain.text', 'Enter details.');
|
|
110
|
-
checkInvalid();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('should render default state internal', () => {
|
|
114
|
-
render(() => {
|
|
115
|
-
chatbotUiStore.customizations.feedback = {
|
|
116
|
-
isCommentAlwaysRequired: true,
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
cy.clock(Date.parse('2023-10-01T00:00:00Z'));
|
|
120
|
-
|
|
121
|
-
// Default render
|
|
122
|
-
ChatUiSelectors.chatbotMessageFeedback.should('be.visible');
|
|
123
|
-
ChatUiSelectors.chatbotMessageFeedbackUnrelated.should('be.visible');
|
|
124
|
-
ChatUiSelectors.chatbotMessageFeedbackUnclear.should('be.visible');
|
|
125
|
-
ChatUiSelectors.chatbotMessageFeedbackNotFull.should('be.visible');
|
|
126
|
-
ChatUiSelectors.chatbotMessageFeedbackIncorrect.should('be.visible');
|
|
127
|
-
ChatUiSelectors.chatbotMessageFeedbackOther.should('be.visible');
|
|
128
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.should('be.visible');
|
|
129
|
-
checkInvalid();
|
|
130
|
-
|
|
131
|
-
// Don't click 'other' and check comment textarea: should be mandatory
|
|
132
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.focus().blur();
|
|
133
|
-
getFormError().should('be.visible').should('contain.text', 'Enter details.');
|
|
134
|
-
checkInvalid();
|
|
135
|
-
|
|
136
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.type('Test comment');
|
|
137
|
-
checkValid();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('should validate form when selecting feedback option without other', () => {
|
|
141
|
-
render();
|
|
142
|
-
cy.clock(Date.parse('2023-10-01T00:00:00Z'));
|
|
143
|
-
|
|
144
|
-
ChatUiSelectors.chatbotMessageFeedbackUnrelated
|
|
145
|
-
.parent()
|
|
146
|
-
.find('input')
|
|
147
|
-
.click({ force: true });
|
|
148
|
-
checkValid();
|
|
149
|
-
|
|
150
|
-
ChatUiSelectors.chatbotMessageFeedbackUnclear.parent().find('input').click({ force: true });
|
|
151
|
-
checkValid();
|
|
152
|
-
|
|
153
|
-
ChatUiSelectors.chatbotMessageFeedbackIncorrect
|
|
154
|
-
.parent()
|
|
155
|
-
.find('input')
|
|
156
|
-
.click({ force: true });
|
|
157
|
-
checkValid();
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('should handle multiple selection changes', () => {
|
|
161
|
-
render();
|
|
162
|
-
cy.clock(Date.parse('2023-10-01T00:00:00Z'));
|
|
163
|
-
|
|
164
|
-
// First select a standard option
|
|
165
|
-
ChatUiSelectors.chatbotMessageFeedbackUnrelated
|
|
166
|
-
.parent()
|
|
167
|
-
.find('input')
|
|
168
|
-
.click({ force: true });
|
|
169
|
-
checkValid();
|
|
170
|
-
|
|
171
|
-
// Then switch to 'other' option
|
|
172
|
-
ChatUiSelectors.chatbotMessageFeedbackOther.parent().find('input').click({ force: true });
|
|
173
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.should('be.visible');
|
|
174
|
-
|
|
175
|
-
// Should be invalid without comment
|
|
176
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.focus().blur();
|
|
177
|
-
getFormError().should('be.visible').should('contain.text', 'Enter details.');
|
|
178
|
-
checkInvalid();
|
|
179
|
-
|
|
180
|
-
// Add comment and validate
|
|
181
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.type('Custom feedback');
|
|
182
|
-
checkValid();
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('should show error when other is selected but comment is cleared', () => {
|
|
186
|
-
render();
|
|
187
|
-
cy.clock(Date.parse('2023-10-01T00:00:00Z'));
|
|
188
|
-
|
|
189
|
-
ChatUiSelectors.chatbotMessageFeedbackOther.parent().find('input').click({ force: true });
|
|
190
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.type('Initial comment');
|
|
191
|
-
checkValid();
|
|
192
|
-
|
|
193
|
-
// Clear the comment
|
|
194
|
-
ChatUiSelectors.chatbotMessageFeedbackOtherComment.clear().blur();
|
|
195
|
-
getFormError().should('be.visible').should('contain.text', 'Enter details.');
|
|
196
|
-
checkInvalid();
|
|
197
|
-
});
|
|
198
|
-
}
|