@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.
- package/CHANGELOG.md +24 -0
- package/dist/components/chat/__tests-cy__/chat-messages.test.js +1 -1
- package/dist/components/chat/__tests-cy__/chat-messages.test.js.map +1 -1
- package/dist/components/chat/__tests-cy__/chat.test.js +1 -1
- package/dist/components/chat/__tests-cy__/chat.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-agent.test.js +3 -5
- package/dist/components/messages/__tests-cy__/message-agent.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-system.test.js +1 -3
- package/dist/components/messages/__tests-cy__/message-system.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-timeout.test.js +1 -3
- package/dist/components/messages/__tests-cy__/message-timeout.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-typing.test.js +1 -3
- package/dist/components/messages/__tests-cy__/message-typing.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-user.test.js +1 -3
- package/dist/components/messages/__tests-cy__/message-user.test.js.map +1 -1
- package/dist/components/messages/message-agent.d.ts +1 -1
- package/dist/components/messages/message-agent.d.ts.map +1 -1
- package/dist/components/messages/message-agent.js +2 -2
- package/dist/components/messages/message-agent.js.map +1 -1
- package/dist/components/messages/message-system.d.ts +1 -1
- package/dist/components/messages/message-system.d.ts.map +1 -1
- package/dist/components/messages/message-system.js +2 -2
- package/dist/components/messages/message-system.js.map +1 -1
- package/dist/components/messages/message-timeout.js +1 -1
- package/dist/components/messages/message-timeout.js.map +1 -1
- package/dist/components/messages/message-typing.js +1 -1
- package/dist/components/messages/message-typing.js.map +1 -1
- package/dist/components/messages/message-user.js +1 -1
- package/dist/components/messages/message-user.js.map +1 -1
- package/dist/stores/__tests__/chat-input.store.test.js +1 -1
- package/dist/stores/__tests__/chat-input.store.test.js.map +1 -1
- package/dist/stores/__tests__/chat-ui.store.test.js +1 -1
- package/dist/stores/__tests__/chat-ui.store.test.js.map +1 -1
- package/dist/utils/test-utils.d.ts +5 -0
- package/dist/utils/test-utils.d.ts.map +1 -0
- package/dist/utils/test-utils.js +17 -0
- package/dist/utils/test-utils.js.map +1 -0
- package/package.json +3 -3
- package/src/components/chat/__tests-cy__/chat-messages.test.tsx +1 -1
- package/src/components/chat/__tests-cy__/chat.test.tsx +1 -1
- package/src/components/messages/__tests-cy__/message-agent.test.tsx +3 -5
- package/src/components/messages/__tests-cy__/message-system.test.tsx +1 -3
- package/src/components/messages/__tests-cy__/message-timeout.test.tsx +1 -3
- package/src/components/messages/__tests-cy__/message-typing.test.tsx +1 -3
- package/src/components/messages/__tests-cy__/message-user.test.tsx +1 -3
- package/src/components/messages/message-agent.tsx +4 -4
- package/src/components/messages/message-system.tsx +4 -4
- package/src/components/messages/message-timeout.tsx +1 -1
- package/src/components/messages/message-typing.tsx +1 -1
- package/src/components/messages/message-user.tsx +2 -2
- package/src/stores/__tests__/chat-input.store.test.ts +1 -1
- package/src/stores/__tests__/chat-ui.store.test.ts +1 -1
- package/src/utils/test-utils.ts +22 -0
- package/tsconfig.json +1 -1
- 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-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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
|
|
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-
|
|
40
|
-
data-
|
|
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-
|
|
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
|
|
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-
|
|
29
|
-
data-
|
|
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-
|
|
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-
|
|
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-
|
|
22
|
-
data-
|
|
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
|
+
};
|