@servicetitan/titan-chat-ui 2.0.2 → 2.0.4

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 (55) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/components/chat/__tests-cy__/chat-messages.test.js +1 -1
  3. package/dist/components/chat/__tests-cy__/chat-messages.test.js.map +1 -1
  4. package/dist/components/chat/__tests-cy__/chat.test.js +1 -1
  5. package/dist/components/chat/__tests-cy__/chat.test.js.map +1 -1
  6. package/dist/components/messages/__tests-cy__/message-agent.test.js +3 -5
  7. package/dist/components/messages/__tests-cy__/message-agent.test.js.map +1 -1
  8. package/dist/components/messages/__tests-cy__/message-system.test.js +1 -3
  9. package/dist/components/messages/__tests-cy__/message-system.test.js.map +1 -1
  10. package/dist/components/messages/__tests-cy__/message-timeout.test.js +1 -3
  11. package/dist/components/messages/__tests-cy__/message-timeout.test.js.map +1 -1
  12. package/dist/components/messages/__tests-cy__/message-typing.test.js +1 -3
  13. package/dist/components/messages/__tests-cy__/message-typing.test.js.map +1 -1
  14. package/dist/components/messages/__tests-cy__/message-user.test.js +1 -3
  15. package/dist/components/messages/__tests-cy__/message-user.test.js.map +1 -1
  16. package/dist/components/messages/message-agent.d.ts +1 -1
  17. package/dist/components/messages/message-agent.d.ts.map +1 -1
  18. package/dist/components/messages/message-agent.js +2 -2
  19. package/dist/components/messages/message-agent.js.map +1 -1
  20. package/dist/components/messages/message-system.d.ts +1 -1
  21. package/dist/components/messages/message-system.d.ts.map +1 -1
  22. package/dist/components/messages/message-system.js +2 -2
  23. package/dist/components/messages/message-system.js.map +1 -1
  24. package/dist/components/messages/message-timeout.js +1 -1
  25. package/dist/components/messages/message-timeout.js.map +1 -1
  26. package/dist/components/messages/message-typing.js +1 -1
  27. package/dist/components/messages/message-typing.js.map +1 -1
  28. package/dist/components/messages/message-user.js +1 -1
  29. package/dist/components/messages/message-user.js.map +1 -1
  30. package/dist/stores/__tests__/chat-input.store.test.js +1 -1
  31. package/dist/stores/__tests__/chat-input.store.test.js.map +1 -1
  32. package/dist/stores/__tests__/chat-ui.store.test.js +1 -1
  33. package/dist/stores/__tests__/chat-ui.store.test.js.map +1 -1
  34. package/dist/utils/test-utils.d.ts +5 -0
  35. package/dist/utils/test-utils.d.ts.map +1 -0
  36. package/dist/utils/test-utils.js +17 -0
  37. package/dist/utils/test-utils.js.map +1 -0
  38. package/package.json +3 -3
  39. package/src/components/chat/__tests-cy__/chat-messages.test.tsx +1 -1
  40. package/src/components/chat/__tests-cy__/chat.test.tsx +1 -1
  41. package/src/components/messages/__tests-cy__/message-agent.test.tsx +3 -5
  42. package/src/components/messages/__tests-cy__/message-system.test.tsx +1 -3
  43. package/src/components/messages/__tests-cy__/message-timeout.test.tsx +1 -3
  44. package/src/components/messages/__tests-cy__/message-typing.test.tsx +1 -3
  45. package/src/components/messages/__tests-cy__/message-user.test.tsx +1 -3
  46. package/src/components/messages/message-agent.tsx +4 -4
  47. package/src/components/messages/message-system.tsx +4 -4
  48. package/src/components/messages/message-timeout.tsx +1 -1
  49. package/src/components/messages/message-typing.tsx +1 -1
  50. package/src/components/messages/message-user.tsx +2 -2
  51. package/src/stores/__tests__/chat-input.store.test.ts +1 -1
  52. package/src/stores/__tests__/chat-ui.store.test.ts +1 -1
  53. package/src/utils/test-utils.ts +22 -0
  54. package/tsconfig.json +1 -1
  55. package/tsconfig.tsbuildinfo +1 -1
@@ -1,7 +1,5 @@
1
- // eslint-disable-next-line spaced-comment
2
- /// <reference types="../../../cypress" />
3
- import { ChatUiSelectors } from '@local/utils';
4
1
  import { BodyText, Button, Stack } from '@servicetitan/design-system';
2
+ import { ChatUiSelectors } from '@servicetitan/titan-chat-ui-cypress';
5
3
  import { mount } from 'cypress/react';
6
4
  import { ChatParticipantIcon } from '../../../models/support-chat';
7
5
  import { MessageAgent } from '../message-agent';
@@ -48,7 +46,7 @@ describe('[MessageAgent]', () => {
48
46
  it('should render with custom data-cy', () => {
49
47
  mount(
50
48
  <MessageAgent
51
- data-cy2="custom-data-cy"
49
+ data-cy="custom-data-cy"
52
50
  avatar={{
53
51
  name: 'Test User Name',
54
52
  icon: ChatParticipantIcon.Bot,
@@ -57,7 +55,7 @@ describe('[MessageAgent]', () => {
57
55
  <BodyText>message agent content</BodyText>
58
56
  </MessageAgent>
59
57
  );
60
- cy.getCy2('custom-data-cy').should('be.visible');
58
+ cy.getCy('custom-data-cy').should('be.visible');
61
59
  });
62
60
 
63
61
  it('should render custom message footer', () => {
@@ -1,7 +1,5 @@
1
- // eslint-disable-next-line spaced-comment
2
- /// <reference types="../../../cypress" />
3
- import { ChatUiSelectors } from '@local/utils';
4
1
  import { BodyText, Stack } from '@servicetitan/design-system';
2
+ import { ChatUiSelectors } from '@servicetitan/titan-chat-ui-cypress';
5
3
  import { mount } from 'cypress/react';
6
4
  import { MessageSystem } from '../message-system';
7
5
 
@@ -1,6 +1,4 @@
1
- // eslint-disable-next-line spaced-comment
2
- /// <reference types="../../../cypress" />
3
- import { ChatUiSelectors } from '@local/utils';
1
+ import { ChatUiSelectors } from '@servicetitan/titan-chat-ui-cypress';
4
2
  import { mount } from 'cypress/react';
5
3
  import { MessageTimeout } from '../message-timeout';
6
4
 
@@ -1,6 +1,4 @@
1
- // eslint-disable-next-line spaced-comment
2
- /// <reference types="../../../cypress" />
3
- import { ChatUiSelectors } from '@local/utils';
1
+ import { ChatUiSelectors } from '@servicetitan/titan-chat-ui-cypress';
4
2
  import { mount } from 'cypress/react';
5
3
  import { ChatParticipantIcon } from '../../../models/support-chat';
6
4
  import { MessageTyping } from '../message-typing';
@@ -1,7 +1,5 @@
1
- // eslint-disable-next-line spaced-comment
2
- /// <reference types="../../../cypress" />
3
- import { ChatUiSelectors } from '@local/utils';
4
1
  import { BodyText } from '@servicetitan/design-system';
2
+ import { ChatUiSelectors } from '@servicetitan/titan-chat-ui-cypress';
5
3
  import { mount } from 'cypress/react';
6
4
  import { MessageUser } from '../message-user';
7
5
 
@@ -12,7 +12,7 @@ export interface IMessageAgentProps {
12
12
  subtle?: boolean;
13
13
  omitAvatar?: boolean;
14
14
  className?: string;
15
- ['data-cy2']?: string;
15
+ ['data-cy']?: string;
16
16
  }
17
17
 
18
18
  export const MessageAgent: FC<PropsWithChildren<IMessageAgentProps>> = ({
@@ -26,7 +26,7 @@ export const MessageAgent: FC<PropsWithChildren<IMessageAgentProps>> = ({
26
26
  subtle,
27
27
  ...rest
28
28
  }) => {
29
- const dataCy2 = rest['data-cy2'] ?? 'titan-chat-message-agent';
29
+ const dataCy = rest['data-cy'] ?? 'titan-chat-message-agent';
30
30
  return (
31
31
  <div
32
32
  className={classNames(
@@ -36,8 +36,8 @@ export const MessageAgent: FC<PropsWithChildren<IMessageAgentProps>> = ({
36
36
  },
37
37
  className
38
38
  )}
39
- data-cy="titan-chat-message"
40
- data-cy2={dataCy2}
39
+ data-cy2="titan-chat-message"
40
+ data-cy={dataCy}
41
41
  >
42
42
  <div className={Styles.messageAvatar}>
43
43
  {!omitAvatar && avatar ? <MessageAvatar {...avatar} /> : <div />}
@@ -6,7 +6,7 @@ import * as Styles from './message-system.module.less';
6
6
  export interface IMessageSystemProps {
7
7
  fullWidth?: boolean;
8
8
  className?: string;
9
- ['data-cy2']?: string;
9
+ ['data-cy']?: string;
10
10
  }
11
11
 
12
12
  export const MessageSystem: FC<PropsWithChildren<IMessageSystemProps>> = ({
@@ -15,7 +15,7 @@ export const MessageSystem: FC<PropsWithChildren<IMessageSystemProps>> = ({
15
15
  fullWidth,
16
16
  ...rest
17
17
  }) => {
18
- const dataCy2 = rest['data-cy2'] ?? 'titan-chat-message-system';
18
+ const dataCy = rest['data-cy'] ?? 'titan-chat-message-system';
19
19
  return (
20
20
  <div
21
21
  className={classNames(
@@ -25,8 +25,8 @@ export const MessageSystem: FC<PropsWithChildren<IMessageSystemProps>> = ({
25
25
  },
26
26
  className
27
27
  )}
28
- data-cy="titan-chat-message"
29
- data-cy2={dataCy2}
28
+ data-cy2="titan-chat-message"
29
+ data-cy={dataCy}
30
30
  >
31
31
  <Stack direction="column" spacing="1" className={Styles.messageContent}>
32
32
  {children}
@@ -17,7 +17,7 @@ export const MessageTimeout: FC<IMessageTimeoutProps> = ({ onReset, onResume })
17
17
  }, [onReset]);
18
18
 
19
19
  return (
20
- <MessageSystem data-cy2="titan-chat-message-timeout" fullWidth>
20
+ <MessageSystem data-cy="titan-chat-message-timeout" fullWidth>
21
21
  <Stack direction="column" spacing="2">
22
22
  <Divider />
23
23
  <BodyText el="div" className="ta-center">
@@ -9,7 +9,7 @@ export interface IMessageTypingProps {
9
9
  }
10
10
 
11
11
  export const MessageTyping: FC<IMessageTypingProps> = ({ avatar }) => (
12
- <MessageAgent avatar={avatar} data-cy2="titan-chat-message-typing" subtle>
12
+ <MessageAgent avatar={avatar} data-cy="titan-chat-message-typing" subtle>
13
13
  <Stack className="h-100" alignItems="center">
14
14
  <div className={Styles.dotsContainer} data-cy="titan-chat-message-typing-dots">
15
15
  <span className={Styles.dot} />
@@ -18,8 +18,8 @@ export const MessageUser: FC<PropsWithChildren<IMessageUserProps>> = ({
18
18
  return (
19
19
  <div
20
20
  className={classNames(Styles.messageRoot, 'max-w-100', className)}
21
- data-cy="titan-chat-message"
22
- data-cy2="titan-chat-message-user"
21
+ data-cy2="titan-chat-message"
22
+ data-cy="titan-chat-message-user"
23
23
  >
24
24
  <Stack
25
25
  direction="column"
@@ -1,6 +1,6 @@
1
1
  import { expect } from '@jest/globals';
2
- import { initTestContainer } from '@local/utils';
3
2
  import { Container } from '@servicetitan/react-ioc';
3
+ import { initTestContainer } from '../../utils/test-utils';
4
4
  import { ChatInputStore } from '../chat-input.store';
5
5
 
6
6
  const initContainer = initTestContainer(ChatInputStore, () => {});
@@ -1,5 +1,4 @@
1
1
  import { expect } from '@jest/globals';
2
- import { initTestContainer } from '@local/utils';
3
2
  import { FileDescriptor } from '@servicetitan/form';
4
3
  import { Container } from '@servicetitan/react-ioc';
5
4
  import {
@@ -13,6 +12,7 @@ import {
13
12
  ChatParticipantIcon,
14
13
  ChatRunState,
15
14
  } from '../../models';
15
+ import { initTestContainer } from '../../utils/test-utils';
16
16
  import { ChatUiEvent, ChatUiStore, symbolAgent, symbolUser } from '../chat-ui.store';
17
17
 
18
18
  const mockAudio = {
@@ -0,0 +1,22 @@
1
+ import { Container } from '@servicetitan/react-ioc';
2
+
3
+ type Newable<T> = new (...args: never[]) => T;
4
+
5
+ export const initTestContainer = (
6
+ serviceIdentifier: Newable<unknown> | Newable<unknown>[],
7
+ initDependenciesFn: (container: Container) => void
8
+ ) => {
9
+ const rootContainer = new Container();
10
+ if (Array.isArray(serviceIdentifier)) {
11
+ serviceIdentifier.forEach(identifier => rootContainer.bind(identifier).toSelf());
12
+ } else {
13
+ rootContainer.bind(serviceIdentifier).toSelf();
14
+ }
15
+
16
+ return () => {
17
+ const container = new Container();
18
+ container.parent = rootContainer;
19
+ initDependenciesFn(container);
20
+ return container;
21
+ };
22
+ };
package/tsconfig.json CHANGED
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "references": [
15
15
  {
16
- "path": "../utils"
16
+ "path": "../titan-chat-ui-cypress"
17
17
  }
18
18
  ]
19
19
  }