@servicetitan/titan-chat-ui-anvil2 3.1.0 → 3.1.2

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.
Files changed (113) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/components/chat/__tests-cy__/chat-error.test.d.ts +2 -0
  3. package/dist/components/chat/__tests-cy__/chat-error.test.d.ts.map +1 -0
  4. package/dist/components/chat/__tests-cy__/chat-error.test.js +6 -0
  5. package/dist/components/chat/__tests-cy__/chat-error.test.js.map +1 -0
  6. package/dist/components/chat/__tests-cy__/chat-input-file.test.d.ts +2 -0
  7. package/dist/components/chat/__tests-cy__/chat-input-file.test.d.ts.map +1 -0
  8. package/dist/components/chat/__tests-cy__/chat-input-file.test.js +6 -0
  9. package/dist/components/chat/__tests-cy__/chat-input-file.test.js.map +1 -0
  10. package/dist/components/chat/__tests-cy__/chat-input.test.d.ts +2 -0
  11. package/dist/components/chat/__tests-cy__/chat-input.test.d.ts.map +1 -0
  12. package/dist/components/chat/__tests-cy__/chat-input.test.js +6 -0
  13. package/dist/components/chat/__tests-cy__/chat-input.test.js.map +1 -0
  14. package/dist/components/chat/__tests-cy__/chat-log.test.d.ts +2 -0
  15. package/dist/components/chat/__tests-cy__/chat-log.test.d.ts.map +1 -0
  16. package/dist/components/chat/__tests-cy__/chat-log.test.js +6 -0
  17. package/dist/components/chat/__tests-cy__/chat-log.test.js.map +1 -0
  18. package/dist/components/chat/__tests-cy__/chat-messages.test.js +2 -91
  19. package/dist/components/chat/__tests-cy__/chat-messages.test.js.map +1 -1
  20. package/dist/components/chat/__tests-cy__/chat-notifications.test.d.ts +2 -0
  21. package/dist/components/chat/__tests-cy__/chat-notifications.test.d.ts.map +1 -0
  22. package/dist/components/chat/__tests-cy__/chat-notifications.test.js +6 -0
  23. package/dist/components/chat/__tests-cy__/chat-notifications.test.js.map +1 -0
  24. package/dist/components/chat/__tests-cy__/chat-timer.test.d.ts +2 -0
  25. package/dist/components/chat/__tests-cy__/chat-timer.test.d.ts.map +1 -0
  26. package/dist/components/chat/__tests-cy__/chat-timer.test.js +6 -0
  27. package/dist/components/chat/__tests-cy__/chat-timer.test.js.map +1 -0
  28. package/dist/components/chat/__tests-cy__/chat.test.js +3 -127
  29. package/dist/components/chat/__tests-cy__/chat.test.js.map +1 -1
  30. package/dist/components/chat/chat-connecting.js +1 -1
  31. package/dist/components/chat/chat-connecting.js.map +1 -1
  32. package/dist/components/chat/chat-error.d.ts +3 -1
  33. package/dist/components/chat/chat-error.d.ts.map +1 -1
  34. package/dist/components/chat/chat-error.js +3 -4
  35. package/dist/components/chat/chat-error.js.map +1 -1
  36. package/dist/components/chat/chat-input-file.d.ts.map +1 -1
  37. package/dist/components/chat/chat-input-file.js +19 -15
  38. package/dist/components/chat/chat-input-file.js.map +1 -1
  39. package/dist/components/chat/chat-input.d.ts.map +1 -1
  40. package/dist/components/chat/chat-input.js +5 -6
  41. package/dist/components/chat/chat-input.js.map +1 -1
  42. package/dist/components/chat/chat-input.module.less +4 -0
  43. package/dist/components/chat/chat-message-template-user.d.ts.map +1 -1
  44. package/dist/components/chat/chat-message-template-user.js +2 -2
  45. package/dist/components/chat/chat-message-template-user.js.map +1 -1
  46. package/dist/components/chat/chat-timer.d.ts.map +1 -1
  47. package/dist/components/chat/chat-timer.js +2 -3
  48. package/dist/components/chat/chat-timer.js.map +1 -1
  49. package/dist/components/chat/chat.d.ts.map +1 -1
  50. package/dist/components/chat/chat.js +7 -2
  51. package/dist/components/chat/chat.js.map +1 -1
  52. package/dist/components/chat/chat.module.less +9 -0
  53. package/dist/components/message-content/__tests-cy__/message-content-file.test.d.ts +2 -0
  54. package/dist/components/message-content/__tests-cy__/message-content-file.test.d.ts.map +1 -0
  55. package/dist/components/message-content/__tests-cy__/message-content-file.test.js +6 -0
  56. package/dist/components/message-content/__tests-cy__/message-content-file.test.js.map +1 -0
  57. package/dist/components/messages/__tests-cy__/message-agent.test.js +11 -77
  58. package/dist/components/messages/__tests-cy__/message-agent.test.js.map +1 -1
  59. package/dist/components/messages/__tests-cy__/message-system.test.js +6 -15
  60. package/dist/components/messages/__tests-cy__/message-system.test.js.map +1 -1
  61. package/dist/components/messages/__tests-cy__/message-timeout.test.js +2 -21
  62. package/dist/components/messages/__tests-cy__/message-timeout.test.js.map +1 -1
  63. package/dist/components/messages/__tests-cy__/message-typing.test.js +3 -45
  64. package/dist/components/messages/__tests-cy__/message-typing.test.js.map +1 -1
  65. package/dist/components/messages/__tests-cy__/message-user.test.js +3 -23
  66. package/dist/components/messages/__tests-cy__/message-user.test.js.map +1 -1
  67. package/dist/components/messages/message-timeout.d.ts.map +1 -1
  68. package/dist/components/messages/message-timeout.js +2 -1
  69. package/dist/components/messages/message-timeout.js.map +1 -1
  70. package/dist/components/messages/message-timeout.module.less +3 -0
  71. package/dist/components/messages/message-typing.js +1 -1
  72. package/dist/components/messages/message-typing.js.map +1 -1
  73. package/dist/components/messages/message-typing.module.less +4 -0
  74. package/package.json +4 -4
  75. package/src/components/chat/__tests-cy__/chat-error.test.tsx +6 -0
  76. package/src/components/chat/__tests-cy__/chat-input-file.test.tsx +6 -0
  77. package/src/components/chat/__tests-cy__/chat-input.test.tsx +6 -0
  78. package/src/components/chat/__tests-cy__/chat-log.test.tsx +6 -0
  79. package/src/components/chat/__tests-cy__/chat-messages.test.tsx +2 -107
  80. package/src/components/chat/__tests-cy__/chat-notifications.test.tsx +6 -0
  81. package/src/components/chat/__tests-cy__/chat-timer.test.tsx +6 -0
  82. package/src/components/chat/__tests-cy__/chat.test.tsx +3 -161
  83. package/src/components/chat/chat-connecting.tsx +1 -1
  84. package/src/components/chat/chat-error.tsx +18 -21
  85. package/src/components/chat/chat-input-file.tsx +66 -31
  86. package/src/components/chat/chat-input.module.less +4 -0
  87. package/src/components/chat/chat-input.module.less.d.ts +1 -0
  88. package/src/components/chat/chat-input.tsx +31 -26
  89. package/src/components/chat/chat-message-template-user.tsx +11 -8
  90. package/src/components/chat/chat-timer.tsx +3 -9
  91. package/src/components/chat/chat.module.less +9 -0
  92. package/src/components/chat/chat.module.less.d.ts +4 -0
  93. package/src/components/chat/chat.tsx +33 -20
  94. package/src/components/message-content/__tests-cy__/message-content-file.test.tsx +6 -0
  95. package/src/components/messages/__tests-cy__/message-agent.test.tsx +15 -136
  96. package/src/components/messages/__tests-cy__/message-system.test.tsx +10 -28
  97. package/src/components/messages/__tests-cy__/message-timeout.test.tsx +2 -25
  98. package/src/components/messages/__tests-cy__/message-typing.test.tsx +3 -54
  99. package/src/components/messages/__tests-cy__/message-user.test.tsx +3 -37
  100. package/src/components/messages/message-timeout.module.less +3 -0
  101. package/src/components/messages/message-timeout.module.less.d.ts +3 -0
  102. package/src/components/messages/message-timeout.tsx +3 -2
  103. package/src/components/messages/message-typing.module.less +4 -0
  104. package/src/components/messages/message-typing.module.less.d.ts +1 -0
  105. package/src/components/messages/message-typing.tsx +1 -1
  106. package/tsconfig.json +1 -1
  107. package/tsconfig.tsbuildinfo +1 -1
  108. package/dist/components/chat/chat-error.module.less +0 -6
  109. package/dist/components/chat/chat-timer.module.less +0 -5
  110. package/src/components/chat/chat-error.module.less +0 -6
  111. package/src/components/chat/chat-error.module.less.d.ts +0 -3
  112. package/src/components/chat/chat-timer.module.less +0 -5
  113. package/src/components/chat/chat-timer.module.less.d.ts +0 -3
@@ -1,9 +1,8 @@
1
- import { Announcement, Link, Text } from '@servicetitan/anvil2';
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
- <Announcement
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
- </Announcement>
26
+ </Alert>
33
27
  );
34
28
  });
@@ -0,0 +1,9 @@
1
+ .scrollContainer {
2
+ overflow-y: auto;
3
+ overflow-x: hidden;
4
+ }
5
+
6
+ .fileContainer {
7
+ border-width: 1px;
8
+ border-style: dashed;
9
+ }
@@ -0,0 +1,4 @@
1
+ export const __esModule: true;
2
+ export const fileContainer: string;
3
+ export const scrollContainer: string;
4
+
@@ -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, Fragment, useEffect, useRef } from 'react';
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
- {chatUiStore.isStarting ? (
39
- (loadingComponent ?? <ChatConnecting className="p-x-3 p-y-2" />)
40
- ) : (
41
- <Fragment>
42
- <div ref={scrollRef} className="p-x-3 p-y-2 flex-grow-1 of-y-auto">
43
- <ChatMessages
44
- messages={chatUiStore.messages}
45
- showTypingIndicator={chatUiStore.isAgentTyping}
46
- />
47
- </div>
48
- <ChatNotifications />
49
- {!chatUiStore.customizations?.input?.isDisabled && (
50
- <Flex className="p-x-3 p-y-2" direction="column" gap="4">
51
- <ChatInputFile className="p-2 box-sizing-border-box border-radius-1 border border-style-dashed" />
52
- <ChatInput />
53
- {Boolean(footerComponent) && footerComponent}
54
- </Flex>
55
- )}
56
- </Fragment>
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/cypress-shared';
2
+ import { MessageContentFile } from '../message-content-file';
3
+
4
+ describe('MessageContentFile', () => {
5
+ runMessageContentFileSharedTests(MessageContentFile, { isAnvil2: true });
6
+ });
@@ -1,142 +1,21 @@
1
- import { AnvilProvider, Button, Flex, Text } from '@servicetitan/anvil2';
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 { ChatParticipantIcon } from '@servicetitan/titan-chat-ui-common';
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/cypress-shared';
8
5
  import { MessageAgent } from '../message-agent';
9
6
  import { MessageFooter } from '../message-footer';
10
7
 
11
- describe('[MessageAgent]', () => {
12
- beforeEach(() => {
13
- cy.viewport('macbook-13');
14
- cy.clock(new Date('2023-10-10T10:10:00Z').getTime());
15
- });
16
-
17
- const mount = (children: ReactNode) => {
18
- return cyMount(<AnvilProvider>{children}</AnvilProvider>);
19
- };
20
-
21
- it('should be properly rendered', () => {
22
- mount(
23
- <MessageAgent
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 { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
3
- import { mount } from 'cypress/react';
2
+ import { runMessageSystemSharedTests } from '@servicetitan/cypress-shared';
4
3
  import { MessageSystem } from '../message-system';
5
4
 
6
- describe('[MessageSystem]', () => {
7
- beforeEach(() => {
8
- cy.viewport('macbook-13');
9
- });
10
-
11
- it('should be properly rendered', () => {
12
- mount(
13
- <MessageSystem className="custom-class">
14
- <Flex className="border">
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 { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
2
- import { mount } from 'cypress/react';
1
+ import { runMessageTimeoutSharedTests } from '@servicetitan/cypress-shared';
3
2
  import { MessageTimeout } from '../message-timeout';
4
3
 
5
4
  describe('MessageTimeout', () => {
6
- it('should render message', () => {
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 { ChatParticipantIcon } from '@servicetitan/titan-chat-ui-common';
2
- import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
3
- import { mount } from 'cypress/react';
1
+ import { runMessageTypingSharedTests } from '@servicetitan/cypress-shared';
4
2
  import { MessageTyping } from '../message-typing';
5
3
 
6
- describe('ChatMessageTyping', () => {
7
- function render(icon: ChatParticipantIcon) {
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 { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
3
- import { mount } from 'cypress/react';
2
+ import { runMessageUserSharedTests } from '@servicetitan/cypress-shared';
4
3
  import { MessageUser } from '../message-user';
5
4
 
6
- describe('[MessageUser]', () => {
7
- beforeEach(() => {
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
  });
@@ -0,0 +1,3 @@
1
+ .timeoutMessage {
2
+ text-align: center;
3
+ }
@@ -0,0 +1,3 @@
1
+ export const __esModule: true;
2
+ export const timeoutMessage: string;
3
+
@@ -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 className="ta-center">
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?
@@ -1,5 +1,9 @@
1
1
  @import '@servicetitan/tokens/dist/tokens.less';
2
2
 
3
+ .container {
4
+ height: 100%;
5
+ }
6
+
3
7
  .dotsContainer {
4
8
  @keyframes dot-jumping {
5
9
  0% {
@@ -1,4 +1,5 @@
1
1
  export const __esModule: true;
2
+ export const container: string;
2
3
  export const dot: string;
3
4
  export const dotJumping: string;
4
5
  export const dotsContainer: string;
@@ -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="h-100" alignItems="center">
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} />
package/tsconfig.json CHANGED
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "references": [
17
17
  {
18
- "path": "../titan-chatbot-ui-cypress"
18
+ "path": "../cypress-shared"
19
19
  },
20
20
  {
21
21
  "path": "../titan-chat-ui-common"