@servicetitan/titan-chat-ui 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.
Files changed (74) hide show
  1. package/CHANGELOG.md +12 -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.tsbuildinfo +1 -1
  72. package/dist/components/chat/chat-error.module.less +0 -6
  73. package/src/components/chat/chat-error.module.less +0 -6
  74. package/src/components/chat/chat-error.module.less.d.ts +0 -3
@@ -1,19 +1,10 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { BodyText, Stack } from '@servicetitan/design-system';
3
- import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
4
- import { mount } from 'cypress/react';
2
+ import { runMessageSystemSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
5
3
  import { MessageSystem } from '../message-system';
6
- describe('[MessageSystem]', () => {
7
- beforeEach(() => {
8
- cy.viewport('macbook-13');
9
- });
10
- it('should be properly rendered', () => {
11
- mount(_jsx(MessageSystem, { className: "custom-class", children: _jsx(Stack, { className: "border", children: _jsx(BodyText, { "data-cy": "content", children: "message system content" }) }) }));
12
- ChatUiSelectors.chatMessageSystem.should('have.class', 'custom-class').should('be.visible');
13
- });
14
- it('should be properly rendered fullwidth', () => {
15
- mount(_jsx(MessageSystem, { className: "custom-class", fullWidth: true, children: _jsx(Stack, { className: "border", children: _jsx(BodyText, { "data-cy": "content", children: "message system content" }) }) }));
16
- ChatUiSelectors.chatMessageSystem.should('have.class', 'custom-class').should('be.visible');
4
+ describe('MessageSystem', () => {
5
+ runMessageSystemSharedTests(MessageSystem, {
6
+ TextComponent: BodyText,
7
+ ContainerComponent: Stack,
17
8
  });
18
9
  });
19
10
  //# sourceMappingURL=message-system.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-system.test.js","sourceRoot":"","sources":["../../../../src/components/messages/__tests-cy__/message-system.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,UAAU,CAAC,GAAG,EAAE;QACZ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACnC,KAAK,CACD,KAAC,aAAa,IAAC,SAAS,EAAC,cAAc,YACnC,KAAC,KAAK,IAAC,SAAS,EAAC,QAAQ,YACrB,KAAC,QAAQ,eAAS,SAAS,uCAAkC,GACzD,GACI,CACnB,CAAC;QACF,eAAe,CAAC,iBAAiB,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,KAAK,CACD,KAAC,aAAa,IAAC,SAAS,EAAC,cAAc,EAAC,SAAS,kBAC7C,KAAC,KAAK,IAAC,SAAS,EAAC,QAAQ,YACrB,KAAC,QAAQ,eAAS,SAAS,uCAAkC,GACzD,GACI,CACnB,CAAC;QACF,eAAe,CAAC,iBAAiB,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"message-system.test.js","sourceRoot":"","sources":["../../../../src/components/messages/__tests-cy__/message-system.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC3B,2BAA2B,CAAC,aAAa,EAAE;QACvC,aAAa,EAAE,QAAQ;QACvB,kBAAkB,EAAE,KAAK;KAC5B,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,25 +1,6 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
3
- import { mount } from 'cypress/react';
1
+ import { runMessageTimeoutSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
4
2
  import { MessageTimeout } from '../message-timeout';
5
3
  describe('MessageTimeout', () => {
6
- it('should render message', () => {
7
- const onResume = cy.spy().as('onResume');
8
- const onReset = cy.spy().as('onReset');
9
- mount(_jsx(MessageTimeout, { onResume: onResume, onReset: onReset }));
10
- ChatUiSelectors.chatMessageTimeout
11
- .should('be.visible')
12
- .should('contain.text', [
13
- 'Your session has timed out.',
14
- 'Would you like to resume it or start a new one?',
15
- 'Continue session or Start new session',
16
- ].join(''));
17
- ChatUiSelectors.chatMessageTimeoutResume.should('be.visible');
18
- ChatUiSelectors.chatMessageTimeoutReset.should('be.visible');
19
- ChatUiSelectors.chatMessageTimeoutResume.click();
20
- cy.get('@onResume').should('have.been.calledOnce');
21
- ChatUiSelectors.chatMessageTimeoutReset.click();
22
- cy.get('@onReset').should('have.been.calledOnce');
23
- });
4
+ runMessageTimeoutSharedTests(MessageTimeout);
24
5
  });
25
6
  //# sourceMappingURL=message-timeout.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-timeout.test.js","sourceRoot":"","sources":["../../../../src/components/messages/__tests-cy__/message-timeout.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC7B,MAAM,QAAQ,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;QACvC,KAAK,CAAC,KAAC,cAAc,IAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAI,CAAC,CAAC;QAEhE,eAAe,CAAC,kBAAkB;aAC7B,MAAM,CAAC,YAAY,CAAC;aACpB,MAAM,CACH,cAAc,EACd;YACI,6BAA6B;YAC7B,iDAAiD;YACjD,uCAAuC;SAC1C,CAAC,IAAI,CAAC,EAAE,CAAC,CACb,CAAC;QACN,eAAe,CAAC,wBAAwB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC9D,eAAe,CAAC,uBAAuB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAE7D,eAAe,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;QACjD,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACnD,eAAe,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAC;QAChD,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"message-timeout.test.js","sourceRoot":"","sources":["../../../../src/components/messages/__tests-cy__/message-timeout.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5B,4BAA4B,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC"}
@@ -1,48 +1,6 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ChatParticipantIcon } from '@servicetitan/titan-chat-ui-common';
3
- import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
4
- import { mount } from 'cypress/react';
1
+ import { runMessageTypingSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
5
2
  import { MessageTyping } from '../message-typing';
6
- describe('ChatMessageTyping', () => {
7
- function render(icon) {
8
- mount(_jsx(MessageTyping, { avatar: {
9
- name: 'Test User Name',
10
- icon,
11
- className: 'custom-class',
12
- } }));
13
- ChatUiSelectors.chatMessageTyping.should('be.visible').children().should('have.length', 2);
14
- ChatUiSelectors.chatMessageTypingDots.should('be.visible');
15
- }
16
- it('should render message with bot icon', () => {
17
- render(ChatParticipantIcon.Bot);
18
- ChatUiSelectors.chatAvatarBot
19
- .should('be.visible')
20
- .should('have.class', 'custom-class')
21
- .invoke('css', 'background-image')
22
- .then(bgColor => {
23
- const isSvg = Boolean(bgColor.indexOf('data:image/svg+xml;base64') >= 0);
24
- expect(isSvg).to.eq(true);
25
- });
26
- });
27
- it('should render message with empty icon', () => {
28
- render(ChatParticipantIcon.Empty);
29
- ChatUiSelectors.chatAvatarEmpty.should('exist').should('not.be.visible');
30
- });
31
- it('should render message with initials', () => {
32
- render(ChatParticipantIcon.Initials);
33
- ChatUiSelectors.chatAvatarInitials.should('be.visible').should('contain.text', 'T');
34
- });
35
- it('should not cancel the dots animation', () => {
36
- cy.clock();
37
- render(ChatParticipantIcon.Initials);
38
- // Verify the rendered component + check the dots animation doesn't change over the time
39
- ChatUiSelectors.chatMessageTypingDots.should('be.visible');
40
- cy.tick(10000);
41
- ChatUiSelectors.chatMessageTypingDots.should('be.visible');
42
- cy.tick(20000);
43
- ChatUiSelectors.chatMessageTypingDots.should('be.visible');
44
- cy.tick(30000);
45
- ChatUiSelectors.chatMessageTypingDots.should('be.visible');
46
- });
3
+ describe('MessageTyping', () => {
4
+ runMessageTypingSharedTests(MessageTyping);
47
5
  });
48
6
  //# sourceMappingURL=message-typing.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-typing.test.js","sourceRoot":"","sources":["../../../../src/components/messages/__tests-cy__/message-typing.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,SAAS,MAAM,CAAC,IAAyB;QACrC,KAAK,CACD,KAAC,aAAa,IACV,MAAM,EAAE;gBACJ,IAAI,EAAE,gBAAgB;gBACtB,IAAI;gBACJ,SAAS,EAAE,cAAc;aAC5B,GACH,CACL,CAAC;QACF,eAAe,CAAC,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QAC3F,eAAe,CAAC,qBAAqB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC;IAED,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAChC,eAAe,CAAC,aAAa;aACxB,MAAM,CAAC,YAAY,CAAC;aACpB,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC;aACpC,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC;aACjC,IAAI,CAAC,OAAO,CAAC,EAAE;YACZ,MAAM,KAAK,GAAG,OAAO,CAChB,OAAyB,CAAC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CACvE,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAClC,eAAe,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACrC,eAAe,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC5C,EAAE,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACrC,wFAAwF;QACxF,eAAe,CAAC,qBAAqB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC3D,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACf,eAAe,CAAC,qBAAqB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC3D,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACf,eAAe,CAAC,qBAAqB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAC3D,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACf,eAAe,CAAC,qBAAqB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"message-typing.test.js","sourceRoot":"","sources":["../../../../src/components/messages/__tests-cy__/message-typing.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC3B,2BAA2B,CAAC,aAAa,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
@@ -1,27 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { BodyText } from '@servicetitan/design-system';
3
- import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
4
- import { mount } from 'cypress/react';
2
+ import { runMessageUserSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
5
3
  import { MessageUser } from '../message-user';
6
- describe('[MessageUser]', () => {
7
- beforeEach(() => {
8
- cy.viewport('macbook-13');
9
- });
10
- it('should be properly rendered', () => {
11
- mount(_jsx(MessageUser, { children: _jsx(BodyText, { "data-cy": "content", children: "message user content" }) }));
12
- ChatUiSelectors.chatMessageUser.should('be.visible');
13
- ChatUiSelectors.chatMessageContent
14
- .should('be.visible')
15
- .should('contain.text', 'message user content');
16
- });
17
- it('should be properly rendered with long text', () => {
18
- const longText = 'message user content '.repeat(100).trim();
19
- mount(_jsx(MessageUser, { children: _jsx(BodyText, { "data-cy": "content", children: longText }) }));
20
- ChatUiSelectors.chatMessageContent.should('be.visible').should('contain.text', longText);
21
- });
22
- it('should be rendered with footer', () => {
23
- mount(_jsx(MessageUser, { messageFooter: _jsx(BodyText, { children: "message user footer" }), children: _jsx(BodyText, { "data-cy": "content", children: "message user content" }) }));
24
- ChatUiSelectors.chatMessageFooter.should('be.visible');
25
- });
4
+ describe('MessageUser', () => {
5
+ runMessageUserSharedTests(MessageUser, BodyText);
26
6
  });
27
7
  //# sourceMappingURL=message-user.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-user.test.js","sourceRoot":"","sources":["../../../../src/components/messages/__tests-cy__/message-user.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC3B,UAAU,CAAC,GAAG,EAAE;QACZ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACnC,KAAK,CACD,KAAC,WAAW,cACR,KAAC,QAAQ,eAAS,SAAS,qCAAgC,GACjD,CACjB,CAAC;QACF,eAAe,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACrD,eAAe,CAAC,kBAAkB;aAC7B,MAAM,CAAC,YAAY,CAAC;aACpB,MAAM,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QAClD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5D,KAAK,CACD,KAAC,WAAW,cACR,KAAC,QAAQ,eAAS,SAAS,YAAE,QAAQ,GAAY,GACvC,CACjB,CAAC;QACF,eAAe,CAAC,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,KAAK,CACD,KAAC,WAAW,IAAC,aAAa,EAAE,KAAC,QAAQ,sCAA+B,YAChE,KAAC,QAAQ,eAAS,SAAS,qCAAgC,GACjD,CACjB,CAAC;QACF,eAAe,CAAC,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"message-user.test.js","sourceRoot":"","sources":["../../../../src/components/messages/__tests-cy__/message-user.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,yBAAyB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/titan-chat-ui",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Chat experience UI package",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "push:local": "yalc push"
18
18
  },
19
19
  "dependencies": {
20
- "@servicetitan/titan-chat-ui-common": "^3.1.0",
20
+ "@servicetitan/titan-chat-ui-common": "^3.1.1",
21
21
  "lodash": "4.17.21",
22
22
  "nanoid": "^5.1.5"
23
23
  },
@@ -40,7 +40,7 @@
40
40
  "react-dom": "^18"
41
41
  },
42
42
  "devDependencies": {
43
- "@servicetitan/titan-chatbot-ui-cypress": "^3.1.0",
43
+ "@servicetitan/titan-chatbot-ui-cypress": "^3.1.1",
44
44
  "cypress": "^14.3.2"
45
45
  },
46
46
  "keywords": [
@@ -53,5 +53,5 @@
53
53
  "cli": {
54
54
  "webpack": false
55
55
  },
56
- "gitHead": "cf6382312324155aa466ef1c5394b94d6fc267a5"
56
+ "gitHead": "83c89de5b42d24ce5d7fcd034810bf596a673a08"
57
57
  }
@@ -0,0 +1,6 @@
1
+ import { runChatErrorSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
2
+ import { ChatError } from '../chat-error';
3
+
4
+ describe('ChatError', () => {
5
+ runChatErrorSharedTests(ChatError);
6
+ });
@@ -0,0 +1,6 @@
1
+ import { runChatInputFileSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
2
+ import { ChatInputFile } from '../chat-input-file';
3
+
4
+ describe('ChatInputFile', () => {
5
+ runChatInputFileSharedTests(ChatInputFile);
6
+ });
@@ -0,0 +1,6 @@
1
+ import { runChatInputSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
2
+ import { ChatInput } from '../chat-input';
3
+
4
+ describe('ChatInput', () => {
5
+ runChatInputSharedTests(ChatInput);
6
+ });
@@ -0,0 +1,6 @@
1
+ import { runChatLogSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
2
+ import { ChatLog } from '../chat-log';
3
+
4
+ describe('[ChatLog]', () => {
5
+ runChatLogSharedTests(ChatLog);
6
+ });
@@ -1,111 +1,6 @@
1
- import { Provider } from '@servicetitan/react-ioc';
2
- import { CHAT_UI_STORE_TOKEN, mockChatMessageModelText } from '@servicetitan/titan-chat-ui-common';
3
- import { ChatUiSelectors, CypressMocks } from '@servicetitan/titan-chatbot-ui-cypress';
4
- import { mount } from 'cypress/react';
1
+ import { runChatMessagesSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
5
2
  import { ChatMessages } from '../chat-messages';
6
3
 
7
4
  describe('[ChatMessages]', () => {
8
- let storeMock: CypressMocks.ChatUiStoreMock;
9
-
10
- beforeEach(() => {
11
- cy.viewport(780, 600);
12
- cy.clock(new Date('2023-10-01T10:10:00Z').getTime());
13
- storeMock = new CypressMocks.ChatUiStoreMock();
14
- });
15
-
16
- const render = () => {
17
- return mount(
18
- <Provider
19
- singletons={[
20
- {
21
- provide: CHAT_UI_STORE_TOKEN,
22
- useValue: storeMock,
23
- },
24
- ]}
25
- >
26
- <ChatMessages messages={storeMock.messages} />
27
- </Provider>
28
- );
29
- };
30
-
31
- it('should render default chat', () => {
32
- render();
33
-
34
- ChatUiSelectors.chatMessages.should('be.visible');
35
- ChatUiSelectors.chatMessage.should('have.length', 2);
36
- });
37
-
38
- it('should render several consecutive agent messages without extra avatars', () => {
39
- storeMock.messages = [
40
- mockChatMessageModelText(true, {
41
- id: 'id1',
42
- timestamp: new Date('2023-01-01T10:10:00Z'),
43
- message: 'Hello, this is the first message',
44
- }),
45
- mockChatMessageModelText(true, {
46
- id: 'id2',
47
- message: 'Hello, this is the second message. '.repeat(5).trim(),
48
- timestamp: new Date('2023-01-01T10:10:59.999Z'),
49
- }),
50
- mockChatMessageModelText(true, {
51
- id: 'id3',
52
- message: 'Hello, this is the third message',
53
- timestamp: new Date('2023-01-01T10:11:00Z'),
54
- }),
55
- mockChatMessageModelText(true, {
56
- id: 'id4',
57
- message: 'Hello, this is the forth message',
58
- timestamp: new Date('2023-01-01T10:11:01Z'),
59
- }),
60
- mockChatMessageModelText(false, {
61
- id: 'id11',
62
- timestamp: new Date('2023-01-01T11:10:00Z'),
63
- message: 'Hello, this is the first message',
64
- }),
65
- mockChatMessageModelText(false, {
66
- id: 'id22',
67
- message: 'Hello, this is the second message',
68
- timestamp: new Date('2023-01-01T11:11:00Z'),
69
- }),
70
- mockChatMessageModelText(false, {
71
- id: 'id33',
72
- message: 'Hello, this is the third message',
73
- timestamp: new Date('2023-01-01T11:12:00Z'),
74
- }),
75
- mockChatMessageModelText(false, {
76
- id: 'id44',
77
- message: 'Hello, this is the forth message',
78
- timestamp: new Date('2023-01-01T11:12:01Z'),
79
- }),
80
- ];
81
- render();
82
-
83
- const getTimestamp = (i: number) =>
84
- ChatUiSelectors.chatMessage
85
- .eq(i)
86
- .find(`[data-cy="${ChatUiSelectors.cy.chatMessageFooter}"]`);
87
-
88
- ChatUiSelectors.chatMessageAgent.should('have.length', 4);
89
- ChatUiSelectors.chatMessageUser.should('have.length', 4);
90
-
91
- // Agent avatar should be visible only for the first message in group
92
- const getAvatar = (i: number) =>
93
- ChatUiSelectors.chatMessageAgent
94
- .find(`[data-cy="${ChatUiSelectors.cy.chatAvatar}"]`)
95
- .eq(i);
96
- getAvatar(0).should('be.visible');
97
- getAvatar(1).should('not.exist');
98
- getAvatar(2).should('not.exist');
99
- getAvatar(3).should('not.exist');
100
-
101
- // Footer with date should be visible only for the different formatted timestamps
102
- getTimestamp(0).should('not.exist');
103
- getTimestamp(1).should('be.visible').should('contain.text', 'agent • 10:10 AM');
104
- getTimestamp(2).should('not.exist');
105
- getTimestamp(3).should('be.visible').should('contain.text', 'agent • 10:11 AM');
106
- getTimestamp(4).should('be.visible').should('contain.text', '11:10 AM');
107
- getTimestamp(5).should('be.visible').should('contain.text', '11:11 AM');
108
- getTimestamp(6).should('not.exist');
109
- getTimestamp(7).should('be.visible').should('contain.text', '11:12 AM');
110
- });
5
+ runChatMessagesSharedTests(ChatMessages);
111
6
  });
@@ -0,0 +1,6 @@
1
+ import { runChatNotificationsTests } from '@servicetitan/titan-chatbot-ui-cypress';
2
+ import { ChatNotifications } from '../chat-notifications';
3
+
4
+ describe('ChatNotifications', () => {
5
+ runChatNotificationsTests(ChatNotifications);
6
+ });
@@ -0,0 +1,6 @@
1
+ import { runChatTimerTests } from '@servicetitan/titan-chatbot-ui-cypress';
2
+ import { ChatTimer } from '../chat-timer';
3
+
4
+ describe('ChatTimer', () => {
5
+ runChatTimerTests(ChatTimer);
6
+ });
@@ -1,159 +1,6 @@
1
- import { Container, provide, useDependencies } from '@servicetitan/react-ioc';
2
- import {
3
- CHAT_UI_BACKEND_STORE_TOKEN,
4
- CHAT_UI_STORE_TOKEN,
5
- ChatParticipantIcon,
6
- ChatUiBackendEchoStore,
7
- ChatUiStore,
8
- IChatUiBackendStore,
9
- IChatUiStore,
10
- } from '@servicetitan/titan-chat-ui-common';
11
- import { ChatUiSelectors } from '@servicetitan/titan-chatbot-ui-cypress';
12
- import { mount } from 'cypress/react';
13
- import { useEffect } from 'react';
1
+ import { runChatSharedTests } from '@servicetitan/titan-chatbot-ui-cypress';
14
2
  import { Chat } from '../chat';
15
3
 
16
- const initContainer = () => {
17
- const rootContainer = new Container();
18
- const container = new Container();
19
- container.parent = rootContainer;
20
- container.bind<IChatUiStore>(CHAT_UI_STORE_TOKEN).to(ChatUiStore).inSingletonScope();
21
- container
22
- .bind<IChatUiBackendStore>(CHAT_UI_BACKEND_STORE_TOKEN)
23
- .to(ChatUiBackendEchoStore)
24
- .inSingletonScope();
25
- return container;
26
- };
27
-
28
- describe('[Chat]', () => {
29
- let container: Container;
30
- let chatUiStore: IChatUiStore;
31
- let chatUiBackendStore: ChatUiBackendEchoStore;
32
-
33
- beforeEach(() => {
34
- container = initContainer();
35
- chatUiStore = container.get<IChatUiStore>(CHAT_UI_STORE_TOKEN);
36
- chatUiBackendStore = container.get<ChatUiBackendEchoStore>(CHAT_UI_BACKEND_STORE_TOKEN);
37
- cy.viewport(780, 800);
38
- cy.clock(Date.parse('2023-10-01T00:00:00Z'));
39
- });
40
-
41
- const render = () => {
42
- const ChatWrapper = provide({
43
- singletons: [
44
- {
45
- provide: CHAT_UI_STORE_TOKEN,
46
- useValue: chatUiStore,
47
- },
48
- {
49
- provide: CHAT_UI_BACKEND_STORE_TOKEN,
50
- useValue: chatUiBackendStore,
51
- },
52
- ],
53
- })(() => {
54
- const [chatUiStore, chatUiBackendStore] = useDependencies(
55
- CHAT_UI_STORE_TOKEN,
56
- CHAT_UI_BACKEND_STORE_TOKEN
57
- );
58
- useEffect(() => {
59
- const init = async () => {
60
- chatUiBackendStore.subscribe();
61
- await chatUiStore.run({
62
- agentName: 'EchoBot',
63
- agentIcon: ChatParticipantIcon.Bot,
64
- });
65
- };
66
- init().then(() => {});
67
- return () => chatUiBackendStore.unsubscribe();
68
- }, [chatUiStore, chatUiBackendStore]);
69
- return <Chat className="h-100vh max-h-100vh" />;
70
- });
71
-
72
- cy.spy(chatUiStore, 'run').as('runSpy');
73
- mount(<ChatWrapper />);
74
-
75
- ChatUiSelectors.chatConnecting.should('be.visible');
76
- cy.tick(1000);
77
- return cy.wrap(
78
- new Promise(resolve => {
79
- cy.get('@runSpy')
80
- .should('have.been.calledOnce')
81
- .then((invocation: any) => {
82
- const initPromise = invocation.firstCall.returnValue as ReturnType<
83
- IChatUiStore['run']
84
- >;
85
- initPromise.then(resolve);
86
- });
87
- })
88
- );
89
- };
90
-
91
- const ask = (message: string) => {
92
- ChatUiSelectors.chatInput.type(`${message}{enter}`);
93
- };
94
-
95
- it('should render default chat', () => {
96
- render().then(() => {
97
- ChatUiSelectors.chatMessages.should('be.visible');
98
- ChatUiSelectors.chatMessageAgent.should('have.length', 1).should('be.visible');
99
- ChatUiSelectors.chatMessageContentAgent
100
- .should('be.visible')
101
- .should(
102
- 'contain.text',
103
- "Hello! I'm generic echo bot. I can echo your messages. Try it out!"
104
- );
105
- ChatUiSelectors.chatNotifications.should('exist');
106
- ChatUiSelectors.chatSend.should('be.visible').should('be.disabled');
107
- ChatUiSelectors.chatInput.should('be.visible').should('not.be.disabled');
108
-
109
- ChatUiSelectors.chatInput.type('Hello');
110
- ChatUiSelectors.chatSend.click();
111
-
112
- ChatUiSelectors.chatMessageUser
113
- .should('be.visible')
114
- .should('have.length', 1)
115
- .should('contain.text', 'Hello');
116
- ChatUiSelectors.chatMessageTyping.should('be.visible');
117
- ChatUiSelectors.chatMessageAgent.should('have.length', 1);
118
-
119
- cy.tick(1000);
120
-
121
- ChatUiSelectors.chatMessageTyping.should('not.exist');
122
- ChatUiSelectors.chatMessageAgent.should('have.length', 2);
123
- });
124
- });
125
-
126
- it('should render chat error message', () => {
127
- render().then(() => {
128
- chatUiStore.setTimer({ secondsTotal: 100, secondsLeft: 10 });
129
- chatUiStore.setError('error message', {
130
- title: 'Custom Error',
131
- recoverStrategy: {
132
- recoverButtonTitle: 'Recover button title',
133
- },
134
- });
135
-
136
- ChatUiSelectors.chatTimer.should('not.exist');
137
- ChatUiSelectors.chatError.should('be.visible');
138
- });
139
- });
140
-
141
- it('should handle send message error and retry', () => {
142
- render().then(() => {
143
- ask('[Error]Custom error message');
144
- cy.tick(1000);
145
-
146
- // Check error message
147
- ChatUiSelectors.chatMessageError
148
- .should('be.visible')
149
- .should('contain.text', 'Message not delivered. Retry');
150
- ChatUiSelectors.chatError
151
- .should('be.visible')
152
- .should('contain.text', ['Custom Error Title', 'Custom error message'].join(''));
153
-
154
- // Retry message
155
- ChatUiSelectors.chatMessageErrorRetry.should('be.visible').click();
156
- cy.tick(1000);
157
- });
158
- });
4
+ describe('Chat', () => {
5
+ runChatSharedTests(Chat);
159
6
  });
@@ -4,9 +4,8 @@ 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
6
  import { MultilineText } from '../common/multiline-text';
7
- import * as Styles from './chat-error.module.less';
8
7
 
9
- export const ChatError: FC = observer(() => {
8
+ export const ChatError: FC<{ className?: string }> = observer(({ className }) => {
10
9
  const [chatUiStore] = useDependencies(CHAT_UI_STORE_TOKEN);
11
10
  const { error } = chatUiStore;
12
11
 
@@ -22,7 +21,7 @@ export const ChatError: FC = observer(() => {
22
21
  status="critical"
23
22
  title={error.title}
24
23
  icon
25
- className={Styles.banner}
24
+ className={className}
26
25
  data-cy="titan-chat-error"
27
26
  >
28
27
  <MultilineText text={error.message} data-cy="titan-chat-error-text" />
@@ -3,7 +3,7 @@ import { provide, useDependencies } from '@servicetitan/react-ioc';
3
3
  import { CHAT_UI_STORE_TOKEN } from '@servicetitan/titan-chat-ui-common';
4
4
  import classNames from 'classnames';
5
5
  import { observer } from 'mobx-react';
6
- import { FC, useCallback, useEffect, useRef, useState } from 'react';
6
+ import { FC, FormEvent, useCallback, useEffect, useRef, useState } from 'react';
7
7
  import { ChatInputStore } from '../../stores/chat-input.store';
8
8
  import * as Styles from './chat-input.module.less';
9
9
 
@@ -21,26 +21,30 @@ export const ChatInput: FC<{ className?: string }> = provide({
21
21
  ChatInputStore
22
22
  );
23
23
 
24
- const handleSendMessage = useCallback(async () => {
25
- const validateResult = await supportChatInputStore.formState.validate();
26
- if (validateResult.hasError) {
27
- return;
28
- }
29
- const text = supportChatInputStore.formState.$.message.value;
30
- if (!text.trim() && !chatUiStore.file) {
31
- return;
32
- }
33
- supportChatInputStore.formState.$.message.onChange('');
34
- setIsSending(true);
35
- try {
36
- await chatUiStore.sendMessageText(text);
37
- } finally {
38
- setIsSending(false);
39
- }
40
- setTimeout(() => {
41
- textareaRef.current?.focus();
42
- }, 0);
43
- }, [chatUiStore, supportChatInputStore]);
24
+ const handleSendMessage = useCallback(
25
+ async (event?: FormEvent) => {
26
+ event?.preventDefault();
27
+ const validateResult = await supportChatInputStore.formState.validate();
28
+ if (validateResult.hasError) {
29
+ return;
30
+ }
31
+ const text = supportChatInputStore.formState.$.message.value;
32
+ if (!text.trim() && !chatUiStore.file) {
33
+ return;
34
+ }
35
+ supportChatInputStore.formState.$.message.onChange('');
36
+ setIsSending(true);
37
+ try {
38
+ await chatUiStore.sendMessageText(text);
39
+ } finally {
40
+ setIsSending(false);
41
+ }
42
+ setTimeout(() => {
43
+ textareaRef.current?.focus();
44
+ }, 0);
45
+ },
46
+ [chatUiStore, supportChatInputStore]
47
+ );
44
48
 
45
49
  const clearTimer = useCallback(() => {
46
50
  clearTimeout(typingTimeoutRef.current ?? 0);
@@ -13,7 +13,7 @@ export const ChatNotifications: FC<IChatNotificationsProps> = observer(() => {
13
13
  return (
14
14
  <Stack direction="column" spacing="2" data-cy="titan-chat-notifications">
15
15
  {chatUiStore.timer && !chatUiStore.isError && <ChatTimer />}
16
- {chatUiStore.isError && <ChatError />}
16
+ {chatUiStore.isError && <ChatError className="m-x-3" />}
17
17
  </Stack>
18
18
  );
19
19
  });
@@ -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);
6
+ });