@servicetitan/titan-chat-ui-anvil2 3.1.0 → 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 +12 -0
- package/dist/components/chat/__tests-cy__/chat-error.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-error.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-error.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-error.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-input-file.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-input-file.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-input-file.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-input-file.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-input.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-input.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-input.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-input.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-log.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-log.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-log.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-log.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-messages.test.js +2 -91
- package/dist/components/chat/__tests-cy__/chat-messages.test.js.map +1 -1
- package/dist/components/chat/__tests-cy__/chat-notifications.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-notifications.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-notifications.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-notifications.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-timer.test.d.ts +2 -0
- package/dist/components/chat/__tests-cy__/chat-timer.test.d.ts.map +1 -0
- package/dist/components/chat/__tests-cy__/chat-timer.test.js +6 -0
- package/dist/components/chat/__tests-cy__/chat-timer.test.js.map +1 -0
- package/dist/components/chat/__tests-cy__/chat.test.js +3 -127
- package/dist/components/chat/__tests-cy__/chat.test.js.map +1 -1
- package/dist/components/chat/chat-connecting.js +1 -1
- package/dist/components/chat/chat-connecting.js.map +1 -1
- package/dist/components/chat/chat-error.d.ts +3 -1
- package/dist/components/chat/chat-error.d.ts.map +1 -1
- package/dist/components/chat/chat-error.js +3 -4
- package/dist/components/chat/chat-error.js.map +1 -1
- package/dist/components/chat/chat-input-file.d.ts.map +1 -1
- package/dist/components/chat/chat-input-file.js +19 -15
- package/dist/components/chat/chat-input-file.js.map +1 -1
- package/dist/components/chat/chat-input.d.ts.map +1 -1
- package/dist/components/chat/chat-input.js +5 -6
- package/dist/components/chat/chat-input.js.map +1 -1
- package/dist/components/chat/chat-input.module.less +4 -0
- package/dist/components/chat/chat-message-template-user.d.ts.map +1 -1
- package/dist/components/chat/chat-message-template-user.js +2 -2
- package/dist/components/chat/chat-message-template-user.js.map +1 -1
- package/dist/components/chat/chat-timer.d.ts.map +1 -1
- package/dist/components/chat/chat-timer.js +2 -3
- package/dist/components/chat/chat-timer.js.map +1 -1
- package/dist/components/chat/chat.d.ts.map +1 -1
- package/dist/components/chat/chat.js +7 -2
- package/dist/components/chat/chat.js.map +1 -1
- package/dist/components/chat/chat.module.less +9 -0
- package/dist/components/message-content/__tests-cy__/message-content-file.test.d.ts +2 -0
- package/dist/components/message-content/__tests-cy__/message-content-file.test.d.ts.map +1 -0
- package/dist/components/message-content/__tests-cy__/message-content-file.test.js +6 -0
- package/dist/components/message-content/__tests-cy__/message-content-file.test.js.map +1 -0
- package/dist/components/messages/__tests-cy__/message-agent.test.js +11 -77
- package/dist/components/messages/__tests-cy__/message-agent.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-system.test.js +6 -15
- package/dist/components/messages/__tests-cy__/message-system.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-timeout.test.js +2 -21
- package/dist/components/messages/__tests-cy__/message-timeout.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-typing.test.js +3 -45
- package/dist/components/messages/__tests-cy__/message-typing.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-user.test.js +3 -23
- package/dist/components/messages/__tests-cy__/message-user.test.js.map +1 -1
- package/dist/components/messages/message-timeout.d.ts.map +1 -1
- package/dist/components/messages/message-timeout.js +2 -1
- package/dist/components/messages/message-timeout.js.map +1 -1
- package/dist/components/messages/message-timeout.module.less +3 -0
- package/dist/components/messages/message-typing.js +1 -1
- package/dist/components/messages/message-typing.js.map +1 -1
- package/dist/components/messages/message-typing.module.less +4 -0
- package/package.json +4 -4
- package/src/components/chat/__tests-cy__/chat-error.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-input-file.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-input.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-log.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-messages.test.tsx +2 -107
- package/src/components/chat/__tests-cy__/chat-notifications.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat-timer.test.tsx +6 -0
- package/src/components/chat/__tests-cy__/chat.test.tsx +3 -161
- package/src/components/chat/chat-connecting.tsx +1 -1
- package/src/components/chat/chat-error.tsx +18 -21
- package/src/components/chat/chat-input-file.tsx +66 -31
- package/src/components/chat/chat-input.module.less +4 -0
- package/src/components/chat/chat-input.module.less.d.ts +1 -0
- package/src/components/chat/chat-input.tsx +31 -26
- package/src/components/chat/chat-message-template-user.tsx +11 -8
- package/src/components/chat/chat-timer.tsx +3 -9
- package/src/components/chat/chat.module.less +9 -0
- package/src/components/chat/chat.module.less.d.ts +4 -0
- package/src/components/chat/chat.tsx +33 -20
- package/src/components/message-content/__tests-cy__/message-content-file.test.tsx +6 -0
- package/src/components/messages/__tests-cy__/message-agent.test.tsx +15 -136
- package/src/components/messages/__tests-cy__/message-system.test.tsx +10 -28
- package/src/components/messages/__tests-cy__/message-timeout.test.tsx +2 -25
- package/src/components/messages/__tests-cy__/message-typing.test.tsx +3 -54
- package/src/components/messages/__tests-cy__/message-user.test.tsx +3 -37
- package/src/components/messages/message-timeout.module.less +3 -0
- package/src/components/messages/message-timeout.module.less.d.ts +3 -0
- package/src/components/messages/message-timeout.tsx +3 -2
- package/src/components/messages/message-typing.module.less +4 -0
- package/src/components/messages/message-typing.module.less.d.ts +1 -0
- package/src/components/messages/message-typing.tsx +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/components/chat/chat-error.module.less +0 -6
- package/dist/components/chat/chat-timer.module.less +0 -5
- package/src/components/chat/chat-error.module.less +0 -6
- package/src/components/chat/chat-error.module.less.d.ts +0 -3
- package/src/components/chat/chat-timer.module.less +0 -5
- package/src/components/chat/chat-timer.module.less.d.ts +0 -3
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Alert, Link, Text } from '@servicetitan/anvil2';
|
|
2
2
|
import { useDependencies } from '@servicetitan/react-ioc';
|
|
3
3
|
import { CHAT_UI_STORE_TOKEN } from '@servicetitan/titan-chat-ui-common';
|
|
4
4
|
import { observer } from 'mobx-react';
|
|
5
5
|
import { FC, useCallback } from 'react';
|
|
6
|
-
import * as Styles from './chat-timer.module.less';
|
|
7
6
|
|
|
8
7
|
export const ChatTimer: FC = observer(() => {
|
|
9
8
|
const [chatUiStore] = useDependencies(CHAT_UI_STORE_TOKEN);
|
|
@@ -15,12 +14,7 @@ export const ChatTimer: FC = observer(() => {
|
|
|
15
14
|
return null;
|
|
16
15
|
}
|
|
17
16
|
return (
|
|
18
|
-
<
|
|
19
|
-
status="info"
|
|
20
|
-
title="Chat inactive"
|
|
21
|
-
className={Styles.banner}
|
|
22
|
-
data-cy="titan-chat-timer"
|
|
23
|
-
>
|
|
17
|
+
<Alert status="info" title="Chat inactive" data-cy="titan-chat-timer">
|
|
24
18
|
<Text variant="body">
|
|
25
19
|
{'Are you still there? Please respond within '}
|
|
26
20
|
<b>{secondsLeft}s</b>
|
|
@@ -29,6 +23,6 @@ export const ChatTimer: FC = observer(() => {
|
|
|
29
23
|
<Link onClick={restartTimers} appearance="secondary" data-cy="titan-chat-timer-restart">
|
|
30
24
|
I'm here
|
|
31
25
|
</Link>
|
|
32
|
-
</
|
|
26
|
+
</Alert>
|
|
33
27
|
);
|
|
34
28
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Flex } from '@servicetitan/anvil2';
|
|
2
2
|
import { useDependencies } from '@servicetitan/react-ioc';
|
|
3
3
|
import { CHAT_UI_STORE_TOKEN, ChatCustomizations } from '@servicetitan/titan-chat-ui-common';
|
|
4
|
+
import classNames from 'classnames';
|
|
4
5
|
import { observer } from 'mobx-react';
|
|
5
|
-
import { FC,
|
|
6
|
+
import { FC, useEffect, useRef } from 'react';
|
|
6
7
|
import { ChatConnecting } from './chat-connecting';
|
|
7
8
|
import { ChatInput } from './chat-input';
|
|
8
9
|
import { ChatInputFile } from './chat-input-file';
|
|
9
10
|
import { ChatMessages } from './chat-messages';
|
|
10
11
|
import { ChatNotifications } from './chat-notifications';
|
|
12
|
+
import * as Styles from './chat.module.less';
|
|
11
13
|
|
|
12
14
|
export interface IChatProps {
|
|
13
15
|
className?: string;
|
|
@@ -33,27 +35,38 @@ export const Chat: FC<IChatProps> = observer(({ className, customizations }) =>
|
|
|
33
35
|
}, 0);
|
|
34
36
|
}, [chatUiStore.scrollCounter]);
|
|
35
37
|
|
|
38
|
+
if (chatUiStore.isStarting) {
|
|
39
|
+
return (
|
|
40
|
+
<Flex direction="column" className={className} data-cy="titan-chat">
|
|
41
|
+
{loadingComponent ?? <ChatConnecting className="p-inline-6 p-block-4" />}
|
|
42
|
+
</Flex>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
36
45
|
return (
|
|
37
46
|
<Flex direction="column" className={className} data-cy="titan-chat">
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
<Flex
|
|
48
|
+
direction="column"
|
|
49
|
+
ref={scrollRef}
|
|
50
|
+
grow="1"
|
|
51
|
+
className={classNames('p-inline-6 p-block-4', Styles.scrollContainer)}
|
|
52
|
+
>
|
|
53
|
+
<ChatMessages
|
|
54
|
+
messages={chatUiStore.messages}
|
|
55
|
+
showTypingIndicator={chatUiStore.isAgentTyping}
|
|
56
|
+
/>
|
|
57
|
+
</Flex>
|
|
58
|
+
<ChatNotifications />
|
|
59
|
+
{!chatUiStore.customizations?.input?.isDisabled && (
|
|
60
|
+
<Flex className="p-inline-6 p-block-4" direction="column" gap="4">
|
|
61
|
+
<ChatInputFile
|
|
62
|
+
className={classNames(
|
|
63
|
+
'p-4 border-radius-small border-color-subdued',
|
|
64
|
+
Styles.fileContainer
|
|
65
|
+
)}
|
|
66
|
+
/>
|
|
67
|
+
<ChatInput />
|
|
68
|
+
{Boolean(footerComponent) && footerComponent}
|
|
69
|
+
</Flex>
|
|
57
70
|
)}
|
|
58
71
|
</Flex>
|
|
59
72
|
);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { runMessageContentFileSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
2
|
+
import { MessageContentFile } from '../message-content-file';
|
|
3
|
+
|
|
4
|
+
describe('MessageContentFile', () => {
|
|
5
|
+
runMessageContentFileSharedTests(MessageContentFile, { isAnvil2: true });
|
|
6
|
+
});
|
|
@@ -1,142 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Button, Flex, Text } from '@servicetitan/anvil2';
|
|
2
2
|
import IconThumbDown from '@servicetitan/anvil2/assets/icons/material/round/thumb_down.svg';
|
|
3
3
|
import IconThumbUp from '@servicetitan/anvil2/assets/icons/material/round/thumb_up.svg';
|
|
4
|
-
import {
|
|
5
|
-
import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
6
|
-
import { mount as cyMount } from 'cypress/react';
|
|
7
|
-
import { ReactNode } from 'react';
|
|
4
|
+
import { runMessageAgentSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
8
5
|
import { MessageAgent } from '../message-agent';
|
|
9
6
|
import { MessageFooter } from '../message-footer';
|
|
10
7
|
|
|
11
|
-
describe('
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
avatar={{
|
|
25
|
-
name: 'Test User Name',
|
|
26
|
-
icon: ChatParticipantIcon.Bot,
|
|
27
|
-
className: 'custom-class',
|
|
28
|
-
}}
|
|
29
|
-
>
|
|
30
|
-
<Text data-cy="content">message agent content</Text>
|
|
31
|
-
</MessageAgent>
|
|
32
|
-
);
|
|
33
|
-
ChatUiSelectors.chatMessageAgent.should('be.visible').children().should('have.length', 2);
|
|
34
|
-
ChatUiSelectors.chatAvatarBot.should('be.visible').should('have.class', 'custom-class');
|
|
35
|
-
ChatUiSelectors.chatMessageContentAgent.should('contain.text', 'message agent content');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should be full width', () => {
|
|
39
|
-
mount(
|
|
40
|
-
<MessageAgent
|
|
41
|
-
fullWidth
|
|
42
|
-
avatar={{
|
|
43
|
-
name: 'Test User Name',
|
|
44
|
-
icon: ChatParticipantIcon.Bot,
|
|
45
|
-
}}
|
|
46
|
-
>
|
|
47
|
-
<Text>message agent content</Text>
|
|
48
|
-
</MessageAgent>
|
|
49
|
-
);
|
|
50
|
-
ChatUiSelectors.chatMessageContentAgent.should('contain.text', 'message agent content');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should render with custom data-cy', () => {
|
|
54
|
-
mount(
|
|
55
|
-
<MessageAgent
|
|
56
|
-
data-cy="custom-data-cy"
|
|
57
|
-
avatar={{
|
|
58
|
-
name: 'Test User Name',
|
|
59
|
-
icon: ChatParticipantIcon.Bot,
|
|
60
|
-
}}
|
|
61
|
-
>
|
|
62
|
-
<Text>message agent content</Text>
|
|
63
|
-
</MessageAgent>
|
|
64
|
-
);
|
|
65
|
-
cy.getCy('custom-data-cy').should('be.visible');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should render custom message footer', () => {
|
|
69
|
-
mount(
|
|
70
|
-
<MessageAgent
|
|
71
|
-
messageFooter={
|
|
72
|
-
<Flex direction="row" justifyContent="space-between" alignItems="center">
|
|
73
|
-
<MessageFooter name="name" timestamp={new Date()} />
|
|
74
|
-
<Flex direction="row" gap="2">
|
|
75
|
-
<Button icon={IconThumbUp} size="small" appearance="ghost" />
|
|
76
|
-
<Button icon={IconThumbDown} size="small" appearance="ghost" />
|
|
77
|
-
</Flex>
|
|
78
|
-
</Flex>
|
|
79
|
-
}
|
|
80
|
-
avatar={{
|
|
81
|
-
name: 'Test User Name',
|
|
82
|
-
icon: ChatParticipantIcon.Bot,
|
|
83
|
-
}}
|
|
84
|
-
>
|
|
85
|
-
<Text>message agent content</Text>
|
|
86
|
-
</MessageAgent>
|
|
87
|
-
);
|
|
88
|
-
ChatUiSelectors.chatMessageAgent.should('be.visible').children().should('have.length', 2);
|
|
89
|
-
ChatUiSelectors.chatMessageFooter
|
|
90
|
-
.should('be.visible')
|
|
91
|
-
.should('contain.text', 'name • 10:10 AM');
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should render subtle message', () => {
|
|
95
|
-
mount(
|
|
96
|
-
<MessageAgent
|
|
97
|
-
subtle
|
|
98
|
-
avatar={{
|
|
99
|
-
name: 'Test User Name',
|
|
100
|
-
icon: ChatParticipantIcon.Bot,
|
|
101
|
-
}}
|
|
102
|
-
>
|
|
103
|
-
<Flex className="border h-100" alignItems="center" data-cy="custom-content">
|
|
104
|
-
<Text>message agent content</Text>
|
|
105
|
-
</Flex>
|
|
106
|
-
</MessageAgent>
|
|
107
|
-
);
|
|
108
|
-
ChatUiSelectors.chatAvatarBot.should('be.visible');
|
|
109
|
-
cy.getCy('custom-content')
|
|
110
|
-
.should('be.visible')
|
|
111
|
-
.should('contain.text', 'message agent content');
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
describe('with different icon types', () => {
|
|
115
|
-
const render = (icon: ChatParticipantIcon) => {
|
|
116
|
-
return mount(
|
|
117
|
-
<MessageAgent
|
|
118
|
-
avatar={{
|
|
119
|
-
name: 'Test User Name',
|
|
120
|
-
icon,
|
|
121
|
-
}}
|
|
122
|
-
>
|
|
123
|
-
<Text>message agent content</Text>
|
|
124
|
-
</MessageAgent>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
it('icon bot', () => {
|
|
128
|
-
render(ChatParticipantIcon.Bot);
|
|
129
|
-
ChatUiSelectors.chatAvatarBot.should('be.visible');
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('icon initials', () => {
|
|
133
|
-
render(ChatParticipantIcon.Initials);
|
|
134
|
-
ChatUiSelectors.chatAvatarInitials.should('be.visible').should('contain.text', 'T');
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('icon empty', () => {
|
|
138
|
-
render(ChatParticipantIcon.Empty);
|
|
139
|
-
ChatUiSelectors.chatAvatarEmpty.should('exist').should('not.be.visible');
|
|
140
|
-
});
|
|
141
|
-
});
|
|
8
|
+
describe('MessageAgent', () => {
|
|
9
|
+
runMessageAgentSharedTests(
|
|
10
|
+
MessageAgent,
|
|
11
|
+
{
|
|
12
|
+
TextComponent: Text,
|
|
13
|
+
ButtonComponent: Button,
|
|
14
|
+
ContainerComponent: Flex,
|
|
15
|
+
MessageFooterComponent: MessageFooter,
|
|
16
|
+
thumbUpIcon: IconThumbUp,
|
|
17
|
+
thumbDownIcon: IconThumbDown,
|
|
18
|
+
},
|
|
19
|
+
{ isAnvil2: true }
|
|
20
|
+
);
|
|
142
21
|
});
|
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
import { Flex, Text } from '@servicetitan/anvil2';
|
|
2
|
-
import {
|
|
3
|
-
import { mount } from 'cypress/react';
|
|
2
|
+
import { runMessageSystemSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
4
3
|
import { MessageSystem } from '../message-system';
|
|
5
4
|
|
|
6
|
-
describe('
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<Text data-cy="content">message system content</Text>
|
|
16
|
-
</Flex>
|
|
17
|
-
</MessageSystem>
|
|
18
|
-
);
|
|
19
|
-
ChatUiSelectors.chatMessageSystem.should('have.class', 'custom-class').should('be.visible');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should be properly rendered fullwidth', () => {
|
|
23
|
-
mount(
|
|
24
|
-
<MessageSystem className="custom-class" fullWidth>
|
|
25
|
-
<Flex className="border">
|
|
26
|
-
<Text data-cy="content">message system content</Text>
|
|
27
|
-
</Flex>
|
|
28
|
-
</MessageSystem>
|
|
29
|
-
);
|
|
30
|
-
ChatUiSelectors.chatMessageSystem.should('have.class', 'custom-class').should('be.visible');
|
|
31
|
-
});
|
|
5
|
+
describe('MessageSystem', () => {
|
|
6
|
+
runMessageSystemSharedTests(
|
|
7
|
+
MessageSystem,
|
|
8
|
+
{
|
|
9
|
+
TextComponent: Text,
|
|
10
|
+
ContainerComponent: Flex,
|
|
11
|
+
},
|
|
12
|
+
{ isAnvil2: true }
|
|
13
|
+
);
|
|
32
14
|
});
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mount } from 'cypress/react';
|
|
1
|
+
import { runMessageTimeoutSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
3
2
|
import { MessageTimeout } from '../message-timeout';
|
|
4
3
|
|
|
5
4
|
describe('MessageTimeout', () => {
|
|
6
|
-
|
|
7
|
-
const onResume = cy.spy().as('onResume');
|
|
8
|
-
const onReset = cy.spy().as('onReset');
|
|
9
|
-
mount(<MessageTimeout onResume={onResume} onReset={onReset} />);
|
|
10
|
-
|
|
11
|
-
ChatUiSelectors.chatMessageTimeout
|
|
12
|
-
.should('be.visible')
|
|
13
|
-
.should(
|
|
14
|
-
'contain.text',
|
|
15
|
-
[
|
|
16
|
-
'Your session has timed out.',
|
|
17
|
-
'Would you like to resume it or start a new one?',
|
|
18
|
-
'Continue session or Start new session',
|
|
19
|
-
].join('')
|
|
20
|
-
);
|
|
21
|
-
ChatUiSelectors.chatMessageTimeoutResume.should('be.visible');
|
|
22
|
-
ChatUiSelectors.chatMessageTimeoutReset.should('be.visible');
|
|
23
|
-
|
|
24
|
-
ChatUiSelectors.chatMessageTimeoutResume.click();
|
|
25
|
-
cy.get('@onResume').should('have.been.calledOnce');
|
|
26
|
-
ChatUiSelectors.chatMessageTimeoutReset.click();
|
|
27
|
-
cy.get('@onReset').should('have.been.calledOnce');
|
|
28
|
-
});
|
|
5
|
+
runMessageTimeoutSharedTests(MessageTimeout);
|
|
29
6
|
});
|
|
@@ -1,57 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
3
|
-
import { mount } from 'cypress/react';
|
|
1
|
+
import { runMessageTypingSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
4
2
|
import { MessageTyping } from '../message-typing';
|
|
5
3
|
|
|
6
|
-
describe('
|
|
7
|
-
|
|
8
|
-
mount(
|
|
9
|
-
<MessageTyping
|
|
10
|
-
avatar={{
|
|
11
|
-
name: 'Test User Name',
|
|
12
|
-
icon,
|
|
13
|
-
className: 'custom-class',
|
|
14
|
-
}}
|
|
15
|
-
/>
|
|
16
|
-
);
|
|
17
|
-
ChatUiSelectors.chatMessageTyping.should('be.visible').children().should('have.length', 2);
|
|
18
|
-
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
it('should render message with bot icon', () => {
|
|
22
|
-
render(ChatParticipantIcon.Bot);
|
|
23
|
-
ChatUiSelectors.chatAvatarBot
|
|
24
|
-
.should('be.visible')
|
|
25
|
-
.should('have.class', 'custom-class')
|
|
26
|
-
.invoke('css', 'background-image')
|
|
27
|
-
.then(bgColor => {
|
|
28
|
-
const isSvg = Boolean(
|
|
29
|
-
(bgColor as any as string).indexOf('data:image/svg+xml;base64') >= 0
|
|
30
|
-
);
|
|
31
|
-
expect(isSvg).to.eq(true);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should render message with empty icon', () => {
|
|
36
|
-
render(ChatParticipantIcon.Empty);
|
|
37
|
-
ChatUiSelectors.chatAvatarEmpty.should('exist').should('not.be.visible');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('should render message with initials', () => {
|
|
41
|
-
render(ChatParticipantIcon.Initials);
|
|
42
|
-
ChatUiSelectors.chatAvatarInitials.should('be.visible').should('contain.text', 'T');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('should not cancel the dots animation', () => {
|
|
46
|
-
cy.clock();
|
|
47
|
-
render(ChatParticipantIcon.Initials);
|
|
48
|
-
// Verify the rendered component + check the dots animation doesn't change over the time
|
|
49
|
-
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
50
|
-
cy.tick(10000);
|
|
51
|
-
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
52
|
-
cy.tick(20000);
|
|
53
|
-
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
54
|
-
cy.tick(30000);
|
|
55
|
-
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
56
|
-
});
|
|
4
|
+
describe('MessageTyping', () => {
|
|
5
|
+
runMessageTypingSharedTests(MessageTyping);
|
|
57
6
|
});
|
|
@@ -1,41 +1,7 @@
|
|
|
1
1
|
import { Text } from '@servicetitan/anvil2';
|
|
2
|
-
import {
|
|
3
|
-
import { mount } from 'cypress/react';
|
|
2
|
+
import { runMessageUserSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
|
|
4
3
|
import { MessageUser } from '../message-user';
|
|
5
4
|
|
|
6
|
-
describe('
|
|
7
|
-
|
|
8
|
-
cy.viewport('macbook-13');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('should be properly rendered', () => {
|
|
12
|
-
mount(
|
|
13
|
-
<MessageUser>
|
|
14
|
-
<Text data-cy="content">message user content</Text>
|
|
15
|
-
</MessageUser>
|
|
16
|
-
);
|
|
17
|
-
ChatUiSelectors.chatMessageUser.should('be.visible');
|
|
18
|
-
ChatUiSelectors.chatMessageContent
|
|
19
|
-
.should('be.visible')
|
|
20
|
-
.should('contain.text', 'message user content');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('should be properly rendered with long text', () => {
|
|
24
|
-
const longText = 'message user content '.repeat(100).trim();
|
|
25
|
-
mount(
|
|
26
|
-
<MessageUser>
|
|
27
|
-
<Text data-cy="content">{longText}</Text>
|
|
28
|
-
</MessageUser>
|
|
29
|
-
);
|
|
30
|
-
ChatUiSelectors.chatMessageContent.should('be.visible').should('contain.text', longText);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should be rendered with footer', () => {
|
|
34
|
-
mount(
|
|
35
|
-
<MessageUser messageFooter={<Text>message user footer</Text>}>
|
|
36
|
-
<Text data-cy="content">message user content</Text>
|
|
37
|
-
</MessageUser>
|
|
38
|
-
);
|
|
39
|
-
ChatUiSelectors.chatMessageFooter.should('be.visible');
|
|
40
|
-
});
|
|
5
|
+
describe('MessageUser', () => {
|
|
6
|
+
runMessageUserSharedTests(MessageUser, Text);
|
|
41
7
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Divider, Flex, Link, Text } from '@servicetitan/anvil2';
|
|
2
2
|
import { FC, useCallback } from 'react';
|
|
3
3
|
import { MessageSystem } from './message-system';
|
|
4
|
+
import * as Styles from './message-timeout.module.less';
|
|
4
5
|
|
|
5
6
|
export interface IMessageTimeoutProps {
|
|
6
7
|
onResume: () => void;
|
|
@@ -18,9 +19,9 @@ export const MessageTimeout: FC<IMessageTimeoutProps> = ({ onReset, onResume })
|
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
21
|
<MessageSystem data-cy="titan-chat-message-timeout" fullWidth>
|
|
21
|
-
<Flex direction="column" gap="4">
|
|
22
|
+
<Flex direction="column" alignItems="center" gap="4">
|
|
22
23
|
<Divider />
|
|
23
|
-
<Text
|
|
24
|
+
<Text variant="body" className={Styles.timeoutMessage}>
|
|
24
25
|
Your session has timed out.
|
|
25
26
|
<br />
|
|
26
27
|
Would you like to resume it or start a new one?
|
|
@@ -10,7 +10,7 @@ export interface IMessageTypingProps {
|
|
|
10
10
|
|
|
11
11
|
export const MessageTyping: FC<IMessageTypingProps> = ({ avatar }) => (
|
|
12
12
|
<MessageAgent avatar={avatar} data-cy="titan-chat-message-typing" subtle>
|
|
13
|
-
<Flex className=
|
|
13
|
+
<Flex className={Styles.container} alignItems="center">
|
|
14
14
|
<div className={Styles.dotsContainer} data-cy="titan-chat-message-typing-dots">
|
|
15
15
|
<span className={Styles.dot} />
|
|
16
16
|
<span className={Styles.dot} />
|