@servicetitan/titan-chat-ui 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 (75) 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 -123
  29. package/dist/components/chat/__tests-cy__/chat.test.js.map +1 -1
  30. package/dist/components/chat/chat-error.d.ts +3 -1
  31. package/dist/components/chat/chat-error.d.ts.map +1 -1
  32. package/dist/components/chat/chat-error.js +2 -3
  33. package/dist/components/chat/chat-error.js.map +1 -1
  34. package/dist/components/chat/chat-input.d.ts.map +1 -1
  35. package/dist/components/chat/chat-input.js +2 -1
  36. package/dist/components/chat/chat-input.js.map +1 -1
  37. package/dist/components/chat/chat-notifications.js +1 -1
  38. package/dist/components/chat/chat-notifications.js.map +1 -1
  39. package/dist/components/message-content/__tests-cy__/message-content-file.test.d.ts +2 -0
  40. package/dist/components/message-content/__tests-cy__/message-content-file.test.d.ts.map +1 -0
  41. package/dist/components/message-content/__tests-cy__/message-content-file.test.js +6 -0
  42. package/dist/components/message-content/__tests-cy__/message-content-file.test.js.map +1 -0
  43. package/dist/components/messages/__tests-cy__/message-agent.test.js +7 -72
  44. package/dist/components/messages/__tests-cy__/message-agent.test.js.map +1 -1
  45. package/dist/components/messages/__tests-cy__/message-system.test.js +5 -14
  46. package/dist/components/messages/__tests-cy__/message-system.test.js.map +1 -1
  47. package/dist/components/messages/__tests-cy__/message-timeout.test.js +2 -21
  48. package/dist/components/messages/__tests-cy__/message-timeout.test.js.map +1 -1
  49. package/dist/components/messages/__tests-cy__/message-typing.test.js +3 -45
  50. package/dist/components/messages/__tests-cy__/message-typing.test.js.map +1 -1
  51. package/dist/components/messages/__tests-cy__/message-user.test.js +3 -23
  52. package/dist/components/messages/__tests-cy__/message-user.test.js.map +1 -1
  53. package/package.json +4 -4
  54. package/src/components/chat/__tests-cy__/chat-error.test.tsx +6 -0
  55. package/src/components/chat/__tests-cy__/chat-input-file.test.tsx +6 -0
  56. package/src/components/chat/__tests-cy__/chat-input.test.tsx +6 -0
  57. package/src/components/chat/__tests-cy__/chat-log.test.tsx +6 -0
  58. package/src/components/chat/__tests-cy__/chat-messages.test.tsx +2 -107
  59. package/src/components/chat/__tests-cy__/chat-notifications.test.tsx +6 -0
  60. package/src/components/chat/__tests-cy__/chat-timer.test.tsx +6 -0
  61. package/src/components/chat/__tests-cy__/chat.test.tsx +3 -156
  62. package/src/components/chat/chat-error.tsx +2 -3
  63. package/src/components/chat/chat-input.tsx +25 -21
  64. package/src/components/chat/chat-notifications.tsx +1 -1
  65. package/src/components/message-content/__tests-cy__/message-content-file.test.tsx +6 -0
  66. package/src/components/messages/__tests-cy__/message-agent.test.tsx +7 -129
  67. package/src/components/messages/__tests-cy__/message-system.test.tsx +5 -27
  68. package/src/components/messages/__tests-cy__/message-timeout.test.tsx +2 -25
  69. package/src/components/messages/__tests-cy__/message-typing.test.tsx +3 -54
  70. package/src/components/messages/__tests-cy__/message-user.test.tsx +3 -37
  71. package/tsconfig.json +1 -1
  72. package/tsconfig.tsbuildinfo +1 -1
  73. package/dist/components/chat/chat-error.module.less +0 -6
  74. package/src/components/chat/chat-error.module.less +0 -6
  75. package/src/components/chat/chat-error.module.less.d.ts +0 -3
@@ -1,135 +1,13 @@
1
+ import { runMessageAgentSharedTests } from '@servicetitan/cypress-shared';
1
2
  import { BodyText, Button, Stack } from '@servicetitan/design-system';
2
- import { ChatParticipantIcon } from '@servicetitan/titan-chat-ui-common';
3
- import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
4
- import { mount } from 'cypress/react';
5
3
  import { MessageAgent } from '../message-agent';
6
4
  import { MessageFooter } from '../message-footer';
7
5
 
8
- describe('[MessageAgent]', () => {
9
- beforeEach(() => {
10
- cy.viewport('macbook-13');
11
- cy.clock(new Date('2023-10-10T10:10:00Z').getTime());
12
- });
13
-
14
- it('should be properly rendered', () => {
15
- mount(
16
- <MessageAgent
17
- avatar={{
18
- name: 'Test User Name',
19
- icon: ChatParticipantIcon.Bot,
20
- className: 'custom-class',
21
- }}
22
- >
23
- <BodyText data-cy="content">message agent content</BodyText>
24
- </MessageAgent>
25
- );
26
- ChatUiSelectors.chatMessageAgent.should('be.visible').children().should('have.length', 2);
27
- ChatUiSelectors.chatAvatarBot.should('be.visible').should('have.class', 'custom-class');
28
- ChatUiSelectors.chatMessageContentAgent.should('contain.text', 'message agent content');
29
- });
30
-
31
- it('should be full width', () => {
32
- mount(
33
- <MessageAgent
34
- fullWidth
35
- avatar={{
36
- name: 'Test User Name',
37
- icon: ChatParticipantIcon.Bot,
38
- }}
39
- >
40
- <BodyText>message agent content</BodyText>
41
- </MessageAgent>
42
- );
43
- ChatUiSelectors.chatMessageContentAgent.should('contain.text', 'message agent content');
44
- });
45
-
46
- it('should render with custom data-cy', () => {
47
- mount(
48
- <MessageAgent
49
- data-cy="custom-data-cy"
50
- avatar={{
51
- name: 'Test User Name',
52
- icon: ChatParticipantIcon.Bot,
53
- }}
54
- >
55
- <BodyText>message agent content</BodyText>
56
- </MessageAgent>
57
- );
58
- cy.getCy('custom-data-cy').should('be.visible');
59
- });
60
-
61
- it('should render custom message footer', () => {
62
- mount(
63
- <MessageAgent
64
- messageFooter={
65
- <Stack direction="row" justifyContent="space-between" alignItems="center">
66
- <MessageFooter name="name" timestamp={new Date()} />
67
- <Stack direction="row" spacing="1">
68
- <Button iconName="thumb_up" xsmall fill="subtle" />
69
- <Button iconName="thumb_down" xsmall fill="subtle" />
70
- </Stack>
71
- </Stack>
72
- }
73
- avatar={{
74
- name: 'Test User Name',
75
- icon: ChatParticipantIcon.Bot,
76
- }}
77
- >
78
- <BodyText>message agent content</BodyText>
79
- </MessageAgent>
80
- );
81
- ChatUiSelectors.chatMessageAgent.should('be.visible').children().should('have.length', 2);
82
- ChatUiSelectors.chatMessageFooter
83
- .should('be.visible')
84
- .should('contain.text', 'name • 10:10 AM');
85
- });
86
-
87
- it('should render subtle message', () => {
88
- mount(
89
- <MessageAgent
90
- subtle
91
- avatar={{
92
- name: 'Test User Name',
93
- icon: ChatParticipantIcon.Bot,
94
- }}
95
- >
96
- <Stack className="border h-100" alignItems="center" data-cy="custom-content">
97
- <BodyText>message agent content</BodyText>
98
- </Stack>
99
- </MessageAgent>
100
- );
101
- ChatUiSelectors.chatAvatarBot.should('be.visible');
102
- cy.getCy('custom-content')
103
- .should('be.visible')
104
- .should('contain.text', 'message agent content');
105
- });
106
-
107
- describe('with different icon types', () => {
108
- const render = (icon: ChatParticipantIcon) => {
109
- return mount(
110
- <MessageAgent
111
- avatar={{
112
- name: 'Test User Name',
113
- icon,
114
- }}
115
- >
116
- <BodyText>message agent content</BodyText>
117
- </MessageAgent>
118
- );
119
- };
120
- it('icon bot', () => {
121
- render(ChatParticipantIcon.Bot);
122
- ChatUiSelectors.chatAvatarBot.should('be.visible');
123
- });
124
-
125
- it('icon initials', () => {
126
- render(ChatParticipantIcon.Initials);
127
- ChatUiSelectors.chatAvatarInitials.should('be.visible').should('contain.text', 'T');
128
- });
129
-
130
- it('icon empty', () => {
131
- render(ChatParticipantIcon.Empty);
132
- ChatUiSelectors.chatAvatarEmpty.should('exist').should('not.be.visible');
133
- });
6
+ describe('MessageAgent', () => {
7
+ runMessageAgentSharedTests(MessageAgent, {
8
+ TextComponent: BodyText,
9
+ ButtonComponent: Button,
10
+ ContainerComponent: Stack,
11
+ MessageFooterComponent: MessageFooter,
134
12
  });
135
13
  });
@@ -1,32 +1,10 @@
1
+ import { runMessageSystemSharedTests } from '@servicetitan/cypress-shared';
1
2
  import { BodyText, Stack } from '@servicetitan/design-system';
2
- import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
3
- import { mount } from 'cypress/react';
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
- <Stack className="border">
15
- <BodyText data-cy="content">message system content</BodyText>
16
- </Stack>
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
- <Stack className="border">
26
- <BodyText data-cy="content">message system content</BodyText>
27
- </Stack>
28
- </MessageSystem>
29
- );
30
- ChatUiSelectors.chatMessageSystem.should('have.class', 'custom-class').should('be.visible');
5
+ describe('MessageSystem', () => {
6
+ runMessageSystemSharedTests(MessageSystem, {
7
+ TextComponent: BodyText,
8
+ ContainerComponent: Stack,
31
9
  });
32
10
  });
@@ -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
+ import { runMessageUserSharedTests } from '@servicetitan/cypress-shared';
1
2
  import { BodyText } from '@servicetitan/design-system';
2
- import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
3
- import { mount } from 'cypress/react';
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
- <BodyText data-cy="content">message user content</BodyText>
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
- <BodyText data-cy="content">{longText}</BodyText>
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={<BodyText>message user footer</BodyText>}>
36
- <BodyText data-cy="content">message user content</BodyText>
37
- </MessageUser>
38
- );
39
- ChatUiSelectors.chatMessageFooter.should('be.visible');
40
- });
5
+ describe('MessageUser', () => {
6
+ runMessageUserSharedTests(MessageUser, BodyText);
41
7
  });
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"