@servicetitan/titan-chat-ui 2.0.1 → 2.0.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.
- package/CHANGELOG.md +13 -0
- package/dist/components/chat/__tests-cy__/chat-messages.test.js +14 -13
- package/dist/components/chat/__tests-cy__/chat-messages.test.js.map +1 -1
- package/dist/components/chat/__tests-cy__/chat.test.js +21 -20
- package/dist/components/chat/__tests-cy__/chat.test.js.map +1 -1
- package/dist/components/chat/chat-error.js +1 -1
- package/dist/components/chat/chat-error.js.map +1 -1
- package/dist/components/chat/chat-message-template-user.js +1 -1
- package/dist/components/chat/chat-message-template-user.js.map +1 -1
- package/dist/components/chat/chat.js +1 -1
- package/dist/components/chat/chat.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-agent.test.js +13 -22
- package/dist/components/messages/__tests-cy__/message-agent.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-system.test.js +3 -2
- package/dist/components/messages/__tests-cy__/message-system.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-timeout.test.js +6 -11
- package/dist/components/messages/__tests-cy__/message-timeout.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-typing.test.js +10 -9
- package/dist/components/messages/__tests-cy__/message-typing.test.js.map +1 -1
- package/dist/components/messages/__tests-cy__/message-user.test.js +5 -9
- package/dist/components/messages/__tests-cy__/message-user.test.js.map +1 -1
- package/dist/components/messages/message-agent.d.ts +3 -2
- package/dist/components/messages/message-agent.d.ts.map +1 -1
- package/dist/components/messages/message-agent.js +4 -5
- package/dist/components/messages/message-agent.js.map +1 -1
- package/dist/components/messages/message-avatar.d.ts.map +1 -1
- package/dist/components/messages/message-avatar.js +5 -1
- package/dist/components/messages/message-avatar.js.map +1 -1
- package/dist/components/messages/message-system.d.ts +2 -2
- 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.d.ts +1 -2
- package/dist/components/messages/message-timeout.d.ts.map +1 -1
- package/dist/components/messages/message-timeout.js +2 -4
- package/dist/components/messages/message-timeout.js.map +1 -1
- package/dist/components/messages/message-typing.d.ts +1 -2
- package/dist/components/messages/message-typing.d.ts.map +1 -1
- package/dist/components/messages/message-typing.js +1 -5
- package/dist/components/messages/message-typing.js.map +1 -1
- package/dist/components/messages/message-user.d.ts +1 -2
- package/dist/components/messages/message-user.d.ts.map +1 -1
- package/dist/components/messages/message-user.js +3 -6
- package/dist/components/messages/message-user.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/stores/__tests__/chat-input.store.test.js +5 -1
- package/dist/stores/__tests__/chat-input.store.test.js.map +1 -1
- package/dist/stores/__tests__/chat-ui.store.test.d.ts +2 -0
- package/dist/stores/__tests__/chat-ui.store.test.d.ts.map +1 -0
- package/dist/stores/__tests__/chat-ui.store.test.js +424 -0
- package/dist/stores/__tests__/chat-ui.store.test.js.map +1 -0
- package/dist/stores/chat-ui.store.d.ts.map +1 -1
- package/dist/stores/chat-ui.store.js +9 -10
- package/dist/stores/chat-ui.store.js.map +1 -1
- package/dist/utils/__tests__/text-utils.test.d.ts +2 -0
- package/dist/utils/__tests__/text-utils.test.d.ts.map +1 -0
- package/dist/utils/__tests__/text-utils.test.js +59 -0
- package/dist/utils/__tests__/text-utils.test.js.map +1 -0
- package/dist/utils/text-utils.d.ts +0 -5
- package/dist/utils/text-utils.d.ts.map +1 -1
- package/dist/utils/text-utils.js +2 -51
- package/dist/utils/text-utils.js.map +1 -1
- package/package.json +9 -3
- package/src/components/chat/__tests-cy__/chat-messages.test.tsx +17 -17
- package/src/components/chat/__tests-cy__/chat.test.tsx +21 -20
- package/src/components/chat/chat-error.tsx +1 -1
- package/src/components/chat/chat-message-template-user.tsx +2 -2
- package/src/components/chat/chat.tsx +1 -1
- package/src/components/messages/__tests-cy__/message-agent.test.tsx +13 -31
- package/src/components/messages/__tests-cy__/message-system.test.tsx +3 -2
- package/src/components/messages/__tests-cy__/message-timeout.test.tsx +6 -13
- package/src/components/messages/__tests-cy__/message-typing.test.tsx +10 -9
- package/src/components/messages/__tests-cy__/message-user.test.tsx +5 -14
- package/src/components/messages/message-agent.tsx +18 -12
- package/src/components/messages/message-avatar.tsx +7 -3
- package/src/components/messages/message-system.tsx +5 -4
- package/src/components/messages/message-timeout.tsx +9 -8
- package/src/components/messages/message-typing.tsx +12 -16
- package/src/components/messages/message-user.tsx +7 -11
- package/src/index.ts +1 -0
- package/src/stores/__tests__/chat-input.store.test.ts +5 -1
- package/src/stores/__tests__/chat-ui.store.test.ts +531 -0
- package/src/stores/chat-ui.store.ts +9 -10
- package/src/utils/__tests__/text-utils.test.ts +70 -0
- package/src/utils/text-utils.ts +2 -59
- package/tsconfig.json +5 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/models/component.d.ts +0 -4
- package/dist/models/component.d.ts.map +0 -1
- package/dist/models/component.js +0 -2
- package/dist/models/component.js.map +0 -1
- package/dist/utils/test-utils.d.ts +0 -5
- package/dist/utils/test-utils.d.ts.map +0 -1
- package/dist/utils/test-utils.js +0 -17
- package/dist/utils/test-utils.js.map +0 -1
- package/src/models/component.ts +0 -3
- package/src/utils/test-utils.ts +0 -22
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { expect } from '@jest/globals';
|
|
2
|
+
import { extractFilenameAndExt, formatChatMessageDate, getFirstName, getNameInitials, getNameInitialsFirst, } from '../text-utils';
|
|
3
|
+
describe('text-utils', () => {
|
|
4
|
+
test('should get initials from name', () => {
|
|
5
|
+
expect(getNameInitials('')).toEqual('');
|
|
6
|
+
expect(getNameInitials('A')).toEqual('A');
|
|
7
|
+
expect(getNameInitials('AB')).toEqual('A');
|
|
8
|
+
expect(getNameInitials('abcd')).toEqual('A');
|
|
9
|
+
expect(getNameInitials(' abcd ')).toEqual('A');
|
|
10
|
+
expect(getNameInitials(' a b c ')).toEqual('AB');
|
|
11
|
+
expect(getNameInitials('abcd ef')).toEqual('AE');
|
|
12
|
+
expect(getNameInitials('a b c d')).toEqual('AB');
|
|
13
|
+
});
|
|
14
|
+
test('should extract filename and ext', () => {
|
|
15
|
+
expect(extractFilenameAndExt('')).toEqual(['', '']);
|
|
16
|
+
expect(extractFilenameAndExt('a')).toEqual(['a', '']);
|
|
17
|
+
expect(extractFilenameAndExt('a.')).toEqual(['a.', '']);
|
|
18
|
+
expect(extractFilenameAndExt('a.b')).toEqual(['a.', 'b']);
|
|
19
|
+
expect(extractFilenameAndExt('a.b.c')).toEqual(['a.b.', 'c']);
|
|
20
|
+
expect(extractFilenameAndExt('aaaa.bbbb.cccc')).toEqual(['aaaa.bbbb.', 'cccc']);
|
|
21
|
+
});
|
|
22
|
+
test('should getFirstName', () => {
|
|
23
|
+
expect(getFirstName('')).toEqual('');
|
|
24
|
+
expect(getFirstName('A')).toEqual('A');
|
|
25
|
+
expect(getFirstName('AB')).toEqual('AB');
|
|
26
|
+
expect(getFirstName('abcd')).toEqual('abcd');
|
|
27
|
+
expect(getFirstName(' abcd ')).toEqual('abcd');
|
|
28
|
+
expect(getFirstName(' a b c ')).toEqual('a');
|
|
29
|
+
expect(getFirstName('abcd ef')).toEqual('abcd');
|
|
30
|
+
expect(getFirstName('a b c d')).toEqual('a');
|
|
31
|
+
});
|
|
32
|
+
test('should getNameInitialsFirst', () => {
|
|
33
|
+
expect(getNameInitials('')).toEqual('');
|
|
34
|
+
expect(getNameInitials('A')).toEqual('A');
|
|
35
|
+
expect(getNameInitials('AB')).toEqual('A');
|
|
36
|
+
expect(getNameInitials('abcd')).toEqual('A');
|
|
37
|
+
expect(getNameInitials(' abcd ')).toEqual('A');
|
|
38
|
+
expect(getNameInitials(' a b c ')).toEqual('AB');
|
|
39
|
+
expect(getNameInitials('abcd ef')).toEqual('AE');
|
|
40
|
+
expect(getNameInitials('a b c d')).toEqual('AB');
|
|
41
|
+
});
|
|
42
|
+
test('should formatChatMessageDate', () => {
|
|
43
|
+
const date = new Date('2023-10-01T12:00:00Z');
|
|
44
|
+
expect(formatChatMessageDate(date)).toEqual('12:00 PM');
|
|
45
|
+
expect(formatChatMessageDate(new Date('2023-10-01T00:00:00Z'))).toEqual('12:00 AM');
|
|
46
|
+
expect(formatChatMessageDate(new Date('2023-10-01T23:59:59Z'))).toEqual('11:59 PM');
|
|
47
|
+
});
|
|
48
|
+
test('should getNameInitialsFirst', () => {
|
|
49
|
+
expect(getNameInitialsFirst('')).toEqual('');
|
|
50
|
+
expect(getNameInitialsFirst('A')).toEqual('A');
|
|
51
|
+
expect(getNameInitialsFirst('AB')).toEqual('A');
|
|
52
|
+
expect(getNameInitialsFirst('abcd')).toEqual('A');
|
|
53
|
+
expect(getNameInitialsFirst(' abcd ')).toEqual('A');
|
|
54
|
+
expect(getNameInitialsFirst(' a b c ')).toEqual('A');
|
|
55
|
+
expect(getNameInitialsFirst('abcd ef')).toEqual('A');
|
|
56
|
+
expect(getNameInitialsFirst('a b c d')).toEqual('A');
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=text-utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-utils.test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/text-utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EACH,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,oBAAoB,GACvB,MAAM,eAAe,CAAC;AAEvB,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IACxB,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CA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CAAC,CAAC;QACvD,MAAM,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACzD,MAAM,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -3,9 +3,4 @@ export declare const getFirstName: (name: string) => string;
|
|
|
3
3
|
export declare const getNameInitials: (name: string) => string;
|
|
4
4
|
export declare const getNameInitialsFirst: (name: string) => string;
|
|
5
5
|
export declare const extractFilenameAndExt: (fileName: string) => [string, string];
|
|
6
|
-
export declare const ellipsisText: (text: string, lineLength: number, linesCount: number, lastLineLength?: number) => {
|
|
7
|
-
lines: string[];
|
|
8
|
-
isCut: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare function extractContentFromHtml(html: string): string;
|
|
11
6
|
//# sourceMappingURL=text-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-utils.d.ts","sourceRoot":"","sources":["../../src/utils/text-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,UAK/C;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,MAG3C,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAO9C,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,MAGnD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CASvE,CAAC
|
|
1
|
+
{"version":3,"file":"text-utils.d.ts","sourceRoot":"","sources":["../../src/utils/text-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,UAK/C;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,MAG3C,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAO9C,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,MAGnD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CASvE,CAAC"}
|
package/dist/utils/text-utils.js
CHANGED
|
@@ -5,11 +5,11 @@ export function formatChatMessageDate(date) {
|
|
|
5
5
|
});
|
|
6
6
|
}
|
|
7
7
|
export const getFirstName = (name) => {
|
|
8
|
-
const parts = name.split(' ');
|
|
8
|
+
const parts = name.trim().split(' ');
|
|
9
9
|
return parts[0];
|
|
10
10
|
};
|
|
11
11
|
export const getNameInitials = (name) => {
|
|
12
|
-
const parts = name.split(' ');
|
|
12
|
+
const parts = name.trim().split(' ');
|
|
13
13
|
return parts
|
|
14
14
|
.filter(Boolean)
|
|
15
15
|
.splice(0, 2)
|
|
@@ -30,53 +30,4 @@ export const extractFilenameAndExt = (fileName) => {
|
|
|
30
30
|
fileName.substring(lastIndex + 1, fileName.length),
|
|
31
31
|
];
|
|
32
32
|
};
|
|
33
|
-
export const ellipsisText = (text, lineLength, linesCount, lastLineLength = lineLength) => {
|
|
34
|
-
let lines = text.split('\n').map(l => l.trim());
|
|
35
|
-
let isCut = false;
|
|
36
|
-
let charsLeft = lineLength * linesCount - lastLineLength;
|
|
37
|
-
let linesLeft = linesCount;
|
|
38
|
-
for (let i = 0; i < lines.length; i++) {
|
|
39
|
-
let line = lines[i];
|
|
40
|
-
let linesInRow = Math.trunc(line.length / lineLength);
|
|
41
|
-
if (line.length % lineLength > 0) {
|
|
42
|
-
linesInRow++;
|
|
43
|
-
}
|
|
44
|
-
if (linesInRow === 0) {
|
|
45
|
-
linesInRow = 1;
|
|
46
|
-
}
|
|
47
|
-
linesLeft -= linesInRow;
|
|
48
|
-
line = line.slice(0, charsLeft);
|
|
49
|
-
lines[i] = line;
|
|
50
|
-
charsLeft = charsLeft - Math.max(lineLength, line.length);
|
|
51
|
-
if (charsLeft <= 0 || linesLeft <= 0) {
|
|
52
|
-
isCut = line.length >= lineLength - lastLineLength || i < lines.length - 1;
|
|
53
|
-
lines = lines.slice(0, i + 1);
|
|
54
|
-
if (line.length >= lineLength - lastLineLength) {
|
|
55
|
-
lines[i] = lines[i] + '...';
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
isCut,
|
|
62
|
-
lines,
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
export function extractContentFromHtml(html) {
|
|
66
|
-
const span = document.createElement('span');
|
|
67
|
-
span.innerHTML = html;
|
|
68
|
-
function getTextLoop(element) {
|
|
69
|
-
const texts = [];
|
|
70
|
-
Array.from(element.childNodes).forEach(node => {
|
|
71
|
-
if (node.nodeType === Node.TEXT_NODE && node.textContent) {
|
|
72
|
-
texts.push(node.textContent.trim());
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
texts.push(...getTextLoop(node));
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return texts;
|
|
79
|
-
}
|
|
80
|
-
return getTextLoop(span).join(' ');
|
|
81
|
-
}
|
|
82
33
|
//# sourceMappingURL=text-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-utils.js","sourceRoot":"","sources":["../../src/utils/text-utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,qBAAqB,CAAC,IAAU;IAC5C,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;QACpC,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;KACpB,CAAC,CAAC;AACP,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE;IACjD,MAAM,K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AAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QACnB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO;QACH,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,GAAG;QACtC,QAAQ,CAAC,SAAS,CAAC,SAAS,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;KACrD,CAAC;AACN,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/titan-chat-ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Chat experience UI package",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,12 +8,18 @@
|
|
|
8
8
|
"directory": "packages/titan-chat-ui"
|
|
9
9
|
},
|
|
10
10
|
"main": "./dist/index.js",
|
|
11
|
-
"typings":
|
|
11
|
+
"typings": [
|
|
12
|
+
"./dist/index.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./dist/index.js"
|
|
16
|
+
},
|
|
12
17
|
"scripts": {
|
|
13
18
|
"publish:local": "yalc publish",
|
|
14
19
|
"push:local": "yalc push"
|
|
15
20
|
},
|
|
16
21
|
"dependencies": {
|
|
22
|
+
"@local/utils": "^2.0.2",
|
|
17
23
|
"lodash": "4.17.21",
|
|
18
24
|
"nanoid": "^5.1.5"
|
|
19
25
|
},
|
|
@@ -48,5 +54,5 @@
|
|
|
48
54
|
"cli": {
|
|
49
55
|
"webpack": false
|
|
50
56
|
},
|
|
51
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "320b1a392e53567f8723d3d79eb66d2074df1e8e"
|
|
52
58
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChatUiSelectors } from '@local/utils';
|
|
1
2
|
import { Provider } from '@servicetitan/react-ioc';
|
|
2
3
|
import { mount } from 'cypress/react';
|
|
3
4
|
import { mockChatMessageModelText } from '../../../models';
|
|
@@ -31,8 +32,9 @@ describe('[ChatMessages]', () => {
|
|
|
31
32
|
|
|
32
33
|
it('should render default chat', () => {
|
|
33
34
|
render();
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
ChatUiSelectors.chatMessages.should('be.visible');
|
|
37
|
+
ChatUiSelectors.chatMessage.should('have.length', 2);
|
|
36
38
|
});
|
|
37
39
|
|
|
38
40
|
it('should render several consecutive agent messages without extra avatars', () => {
|
|
@@ -80,21 +82,19 @@ describe('[ChatMessages]', () => {
|
|
|
80
82
|
];
|
|
81
83
|
render();
|
|
82
84
|
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
const getUserMessages = () =>
|
|
86
|
-
cy.getCy2('chat-message-normal').filter('[data-cy="chat-message-user"]');
|
|
87
|
-
const getAvatar = (i: number) =>
|
|
88
|
-
getAgentMessages().eq(i).find('[data-cy="chat-avatar-bot"]');
|
|
89
|
-
const getTimestamp = (i: number, isUser = false) =>
|
|
90
|
-
(isUser ? getUserMessages() : getAgentMessages())
|
|
85
|
+
const getTimestamp = (i: number) =>
|
|
86
|
+
ChatUiSelectors.chatMessage
|
|
91
87
|
.eq(i)
|
|
92
|
-
.find(`[data-cy="
|
|
88
|
+
.find(`[data-cy="${ChatUiSelectors.cy.chatMessageFooter}"]`);
|
|
93
89
|
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
ChatUiSelectors.chatMessageAgent.should('have.length', 4);
|
|
91
|
+
ChatUiSelectors.chatMessageUser.should('have.length', 4);
|
|
96
92
|
|
|
97
93
|
// Agent avatar should be visible only for the first message in group
|
|
94
|
+
const getAvatar = (i: number) =>
|
|
95
|
+
ChatUiSelectors.chatMessageAgent
|
|
96
|
+
.find(`[data-cy="${ChatUiSelectors.cy.chatAvatar}"]`)
|
|
97
|
+
.eq(i);
|
|
98
98
|
getAvatar(0).should('be.visible');
|
|
99
99
|
getAvatar(1).should('not.exist');
|
|
100
100
|
getAvatar(2).should('not.exist');
|
|
@@ -105,9 +105,9 @@ describe('[ChatMessages]', () => {
|
|
|
105
105
|
getTimestamp(1).should('be.visible').should('contain.text', 'agent • 10:10 AM');
|
|
106
106
|
getTimestamp(2).should('not.exist');
|
|
107
107
|
getTimestamp(3).should('be.visible').should('contain.text', 'agent • 10:11 AM');
|
|
108
|
-
getTimestamp(
|
|
109
|
-
getTimestamp(
|
|
110
|
-
getTimestamp(
|
|
111
|
-
getTimestamp(
|
|
108
|
+
getTimestamp(4).should('be.visible').should('contain.text', '11:10 AM');
|
|
109
|
+
getTimestamp(5).should('be.visible').should('contain.text', '11:11 AM');
|
|
110
|
+
getTimestamp(6).should('not.exist');
|
|
111
|
+
getTimestamp(7).should('be.visible').should('contain.text', '11:12 AM');
|
|
112
112
|
});
|
|
113
113
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChatUiSelectors } from '@local/utils';
|
|
1
2
|
import { Container, provide, useDependencies } from '@servicetitan/react-ioc';
|
|
2
3
|
import { mount } from 'cypress/react';
|
|
3
4
|
import { useEffect } from 'react';
|
|
@@ -71,7 +72,7 @@ describe('[Chat]', () => {
|
|
|
71
72
|
cy.spy(chatUiStore, 'run').as('runSpy');
|
|
72
73
|
mount(<ChatWrapper />);
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
ChatUiSelectors.chatConnecting.should('be.visible');
|
|
75
76
|
cy.tick(1000);
|
|
76
77
|
return cy.wrap(
|
|
77
78
|
new Promise(resolve => {
|
|
@@ -88,37 +89,37 @@ describe('[Chat]', () => {
|
|
|
88
89
|
};
|
|
89
90
|
|
|
90
91
|
const ask = (message: string) => {
|
|
91
|
-
|
|
92
|
+
ChatUiSelectors.chatInput.type(`${message}{enter}`);
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
it('should render default chat', () => {
|
|
95
96
|
render().then(() => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
ChatUiSelectors.chatMessages.should('be.visible');
|
|
98
|
+
ChatUiSelectors.chatMessageAgent.should('have.length', 1).should('be.visible');
|
|
99
|
+
ChatUiSelectors.chatMessageContentAgent
|
|
99
100
|
.should('be.visible')
|
|
100
101
|
.should(
|
|
101
102
|
'contain.text',
|
|
102
103
|
"Hello! I'm generic echo bot. I can echo your messages. Try it out!"
|
|
103
104
|
);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
ChatUiSelectors.chatNotifications.should('exist');
|
|
106
|
+
ChatUiSelectors.chatSend.should('be.visible').should('be.disabled');
|
|
107
|
+
ChatUiSelectors.chatInput.should('be.visible').should('not.be.disabled');
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
ChatUiSelectors.chatInput.type('Hello');
|
|
110
|
+
ChatUiSelectors.chatSend.click();
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
ChatUiSelectors.chatMessageUser
|
|
112
113
|
.should('be.visible')
|
|
113
114
|
.should('have.length', 1)
|
|
114
115
|
.should('contain.text', 'Hello');
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
ChatUiSelectors.chatMessageTyping.should('be.visible');
|
|
117
|
+
ChatUiSelectors.chatMessageAgent.should('have.length', 1);
|
|
117
118
|
|
|
118
119
|
cy.tick(1000);
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
ChatUiSelectors.chatMessageTyping.should('not.exist');
|
|
122
|
+
ChatUiSelectors.chatMessageAgent.should('have.length', 2);
|
|
122
123
|
});
|
|
123
124
|
});
|
|
124
125
|
|
|
@@ -132,8 +133,8 @@ describe('[Chat]', () => {
|
|
|
132
133
|
},
|
|
133
134
|
});
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
ChatUiSelectors.chatTimer.should('not.exist');
|
|
137
|
+
ChatUiSelectors.chatError.should('be.visible');
|
|
137
138
|
});
|
|
138
139
|
});
|
|
139
140
|
|
|
@@ -143,15 +144,15 @@ describe('[Chat]', () => {
|
|
|
143
144
|
cy.tick(1000);
|
|
144
145
|
|
|
145
146
|
// Check error message
|
|
146
|
-
|
|
147
|
+
ChatUiSelectors.chatMessageError
|
|
147
148
|
.should('be.visible')
|
|
148
149
|
.should('contain.text', 'Message not delivered. Retry');
|
|
149
|
-
|
|
150
|
+
ChatUiSelectors.chatError
|
|
150
151
|
.should('be.visible')
|
|
151
152
|
.should('contain.text', ['Custom Error Title', 'Custom error message'].join(''));
|
|
152
153
|
|
|
153
154
|
// Retry message
|
|
154
|
-
|
|
155
|
+
ChatUiSelectors.chatMessageErrorRetry.should('be.visible').click();
|
|
155
156
|
cy.tick(1000);
|
|
156
157
|
});
|
|
157
158
|
});
|
|
@@ -25,7 +25,7 @@ export const ChatError: FC = observer(() => {
|
|
|
25
25
|
className={Styles.banner}
|
|
26
26
|
data-cy="titan-chat-error"
|
|
27
27
|
>
|
|
28
|
-
<MultilineText text={error.message} />
|
|
28
|
+
<MultilineText text={error.message} data-cy="titan-chat-error-text" />
|
|
29
29
|
{error.recoverStrategy && (
|
|
30
30
|
<Button
|
|
31
31
|
className="m-t-2 bg-white-i"
|
|
@@ -22,7 +22,7 @@ export const ChatMessageTemplateUser: FC<PropsWithChildren<IChatMessageProps>> =
|
|
|
22
22
|
isError={isError}
|
|
23
23
|
messageFooter={
|
|
24
24
|
isError ? (
|
|
25
|
-
<Eyebrow className="c-red-600" data-cy="titan-chat-message-
|
|
25
|
+
<Eyebrow className="c-red-600" data-cy="titan-chat-message-error">
|
|
26
26
|
Message not delivered. Retry
|
|
27
27
|
<Button
|
|
28
28
|
iconName="refresh"
|
|
@@ -31,7 +31,7 @@ export const ChatMessageTemplateUser: FC<PropsWithChildren<IChatMessageProps>> =
|
|
|
31
31
|
negative
|
|
32
32
|
aria-label="Retry send message"
|
|
33
33
|
onClick={handleRetry}
|
|
34
|
-
data-cy="titan-chat-message-
|
|
34
|
+
data-cy="titan-chat-message-error-retry"
|
|
35
35
|
/>
|
|
36
36
|
</Eyebrow>
|
|
37
37
|
) : !omitTimestamp ? (
|
|
@@ -49,7 +49,7 @@ export const Chat: FC<IChatProps> = observer(({ className, customizations }) =>
|
|
|
49
49
|
<ChatNotifications />
|
|
50
50
|
{!chatUiStore.customizations?.input?.isDisabled && (
|
|
51
51
|
<Stack className="p-x-3 p-y-2" direction="column" spacing="2">
|
|
52
|
-
<ChatInputFile className="box-sizing-border-box border-radius-1 border border-style-dashed" />
|
|
52
|
+
<ChatInputFile className="p-2 box-sizing-border-box border-radius-1 border border-style-dashed" />
|
|
53
53
|
<ChatInput />
|
|
54
54
|
{Boolean(footerComponent) && footerComponent}
|
|
55
55
|
</Stack>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line spaced-comment
|
|
2
2
|
/// <reference types="../../../cypress" />
|
|
3
|
+
import { ChatUiSelectors } from '@local/utils';
|
|
3
4
|
import { BodyText, Button, Stack } from '@servicetitan/design-system';
|
|
4
5
|
import { mount } from 'cypress/react';
|
|
5
6
|
import { ChatParticipantIcon } from '../../../models/support-chat';
|
|
@@ -24,12 +25,9 @@ describe('[MessageAgent]', () => {
|
|
|
24
25
|
<BodyText data-cy="content">message agent content</BodyText>
|
|
25
26
|
</MessageAgent>
|
|
26
27
|
);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.should('contain.text', 'message agent content');
|
|
32
|
-
cy.getCy('content').should('contain.text', 'message agent content');
|
|
28
|
+
ChatUiSelectors.chatMessageAgent.should('be.visible').children().should('have.length', 2);
|
|
29
|
+
ChatUiSelectors.chatAvatarBot.should('be.visible').should('have.class', 'custom-class');
|
|
30
|
+
ChatUiSelectors.chatMessageContentAgent.should('contain.text', 'message agent content');
|
|
33
31
|
});
|
|
34
32
|
|
|
35
33
|
it('should be full width', () => {
|
|
@@ -44,13 +42,13 @@ describe('[MessageAgent]', () => {
|
|
|
44
42
|
<BodyText>message agent content</BodyText>
|
|
45
43
|
</MessageAgent>
|
|
46
44
|
);
|
|
47
|
-
|
|
45
|
+
ChatUiSelectors.chatMessageContentAgent.should('contain.text', 'message agent content');
|
|
48
46
|
});
|
|
49
47
|
|
|
50
48
|
it('should render with custom data-cy', () => {
|
|
51
49
|
mount(
|
|
52
50
|
<MessageAgent
|
|
53
|
-
data-
|
|
51
|
+
data-cy2="custom-data-cy"
|
|
54
52
|
avatar={{
|
|
55
53
|
name: 'Test User Name',
|
|
56
54
|
icon: ChatParticipantIcon.Bot,
|
|
@@ -59,8 +57,7 @@ describe('[MessageAgent]', () => {
|
|
|
59
57
|
<BodyText>message agent content</BodyText>
|
|
60
58
|
</MessageAgent>
|
|
61
59
|
);
|
|
62
|
-
cy.
|
|
63
|
-
cy.getCy('custom-data-cy-content').should('be.visible');
|
|
60
|
+
cy.getCy2('custom-data-cy').should('be.visible');
|
|
64
61
|
});
|
|
65
62
|
|
|
66
63
|
it('should render custom message footer', () => {
|
|
@@ -83,27 +80,12 @@ describe('[MessageAgent]', () => {
|
|
|
83
80
|
<BodyText>message agent content</BodyText>
|
|
84
81
|
</MessageAgent>
|
|
85
82
|
);
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
ChatUiSelectors.chatMessageAgent.should('be.visible').children().should('have.length', 2);
|
|
84
|
+
ChatUiSelectors.chatMessageFooter
|
|
88
85
|
.should('be.visible')
|
|
89
86
|
.should('contain.text', 'name • 10:10 AM');
|
|
90
87
|
});
|
|
91
88
|
|
|
92
|
-
it('should render error message', () => {
|
|
93
|
-
mount(
|
|
94
|
-
<MessageAgent
|
|
95
|
-
isError
|
|
96
|
-
avatar={{
|
|
97
|
-
name: 'Test User Name',
|
|
98
|
-
icon: ChatParticipantIcon.Bot,
|
|
99
|
-
}}
|
|
100
|
-
>
|
|
101
|
-
<BodyText>message agent content</BodyText>
|
|
102
|
-
</MessageAgent>
|
|
103
|
-
);
|
|
104
|
-
cy.getCy2('chat-message-error').should('be.visible');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
89
|
it('should render subtle message', () => {
|
|
108
90
|
mount(
|
|
109
91
|
<MessageAgent
|
|
@@ -118,7 +100,7 @@ describe('[MessageAgent]', () => {
|
|
|
118
100
|
</Stack>
|
|
119
101
|
</MessageAgent>
|
|
120
102
|
);
|
|
121
|
-
|
|
103
|
+
ChatUiSelectors.chatAvatarBot.should('be.visible');
|
|
122
104
|
cy.getCy('custom-content')
|
|
123
105
|
.should('be.visible')
|
|
124
106
|
.should('contain.text', 'message agent content');
|
|
@@ -139,17 +121,17 @@ describe('[MessageAgent]', () => {
|
|
|
139
121
|
};
|
|
140
122
|
it('icon bot', () => {
|
|
141
123
|
render(ChatParticipantIcon.Bot);
|
|
142
|
-
|
|
124
|
+
ChatUiSelectors.chatAvatarBot.should('be.visible');
|
|
143
125
|
});
|
|
144
126
|
|
|
145
127
|
it('icon initials', () => {
|
|
146
128
|
render(ChatParticipantIcon.Initials);
|
|
147
|
-
|
|
129
|
+
ChatUiSelectors.chatAvatarInitials.should('be.visible').should('contain.text', 'T');
|
|
148
130
|
});
|
|
149
131
|
|
|
150
132
|
it('icon empty', () => {
|
|
151
133
|
render(ChatParticipantIcon.Empty);
|
|
152
|
-
|
|
134
|
+
ChatUiSelectors.chatAvatarEmpty.should('exist').should('not.be.visible');
|
|
153
135
|
});
|
|
154
136
|
});
|
|
155
137
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line spaced-comment
|
|
2
2
|
/// <reference types="../../../cypress" />
|
|
3
|
+
import { ChatUiSelectors } from '@local/utils';
|
|
3
4
|
import { BodyText, Stack } from '@servicetitan/design-system';
|
|
4
5
|
import { mount } from 'cypress/react';
|
|
5
6
|
import { MessageSystem } from '../message-system';
|
|
@@ -17,7 +18,7 @@ describe('[MessageSystem]', () => {
|
|
|
17
18
|
</Stack>
|
|
18
19
|
</MessageSystem>
|
|
19
20
|
);
|
|
20
|
-
|
|
21
|
+
ChatUiSelectors.chatMessageSystem.should('have.class', 'custom-class').should('be.visible');
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
it('should be properly rendered fullwidth', () => {
|
|
@@ -28,6 +29,6 @@ describe('[MessageSystem]', () => {
|
|
|
28
29
|
</Stack>
|
|
29
30
|
</MessageSystem>
|
|
30
31
|
);
|
|
31
|
-
|
|
32
|
+
ChatUiSelectors.chatMessageSystem.should('have.class', 'custom-class').should('be.visible');
|
|
32
33
|
});
|
|
33
34
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line spaced-comment
|
|
2
2
|
/// <reference types="../../../cypress" />
|
|
3
|
+
import { ChatUiSelectors } from '@local/utils';
|
|
3
4
|
import { mount } from 'cypress/react';
|
|
4
5
|
import { MessageTimeout } from '../message-timeout';
|
|
5
6
|
|
|
@@ -9,7 +10,7 @@ describe('MessageTimeout', () => {
|
|
|
9
10
|
const onReset = cy.spy().as('onReset');
|
|
10
11
|
mount(<MessageTimeout onResume={onResume} onReset={onReset} />);
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
ChatUiSelectors.chatMessageTimeout
|
|
13
14
|
.should('be.visible')
|
|
14
15
|
.should(
|
|
15
16
|
'contain.text',
|
|
@@ -19,20 +20,12 @@ describe('MessageTimeout', () => {
|
|
|
19
20
|
'Continue session or Start new session',
|
|
20
21
|
].join('')
|
|
21
22
|
);
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
ChatUiSelectors.chatMessageTimeoutResume.should('be.visible');
|
|
24
|
+
ChatUiSelectors.chatMessageTimeoutReset.should('be.visible');
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
ChatUiSelectors.chatMessageTimeoutResume.click();
|
|
26
27
|
cy.get('@onResume').should('have.been.calledOnce');
|
|
27
|
-
|
|
28
|
+
ChatUiSelectors.chatMessageTimeoutReset.click();
|
|
28
29
|
cy.get('@onReset').should('have.been.calledOnce');
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
-
it('should render with custom data-cy', () => {
|
|
32
|
-
mount(<MessageTimeout onResume={cy.stub()} onReset={cy.stub()} data-cy="custom-data-cy" />);
|
|
33
|
-
|
|
34
|
-
cy.getCy('custom-data-cy').should('be.visible');
|
|
35
|
-
cy.getCy('custom-data-cy-resume').should('be.visible');
|
|
36
|
-
cy.getCy('custom-data-cy-reset').should('be.visible');
|
|
37
|
-
});
|
|
38
31
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line spaced-comment
|
|
2
2
|
/// <reference types="../../../cypress" />
|
|
3
|
+
import { ChatUiSelectors } from '@local/utils';
|
|
3
4
|
import { mount } from 'cypress/react';
|
|
4
5
|
import { ChatParticipantIcon } from '../../../models/support-chat';
|
|
5
6
|
import { MessageTyping } from '../message-typing';
|
|
@@ -15,13 +16,13 @@ describe('ChatMessageTyping', () => {
|
|
|
15
16
|
}}
|
|
16
17
|
/>
|
|
17
18
|
);
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
ChatUiSelectors.chatMessageTyping.should('be.visible').children().should('have.length', 2);
|
|
20
|
+
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
it('should render message with bot icon', () => {
|
|
23
24
|
render(ChatParticipantIcon.Bot);
|
|
24
|
-
|
|
25
|
+
ChatUiSelectors.chatAvatarBot
|
|
25
26
|
.should('be.visible')
|
|
26
27
|
.should('have.class', 'custom-class')
|
|
27
28
|
.invoke('css', 'background-image')
|
|
@@ -35,24 +36,24 @@ describe('ChatMessageTyping', () => {
|
|
|
35
36
|
|
|
36
37
|
it('should render message with empty icon', () => {
|
|
37
38
|
render(ChatParticipantIcon.Empty);
|
|
38
|
-
|
|
39
|
+
ChatUiSelectors.chatAvatarEmpty.should('exist').should('not.be.visible');
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
it('should render message with initials', () => {
|
|
42
43
|
render(ChatParticipantIcon.Initials);
|
|
43
|
-
|
|
44
|
+
ChatUiSelectors.chatAvatarInitials.should('be.visible').should('contain.text', 'T');
|
|
44
45
|
});
|
|
45
46
|
|
|
46
47
|
it('should not cancel the dots animation', () => {
|
|
47
48
|
cy.clock();
|
|
48
49
|
render(ChatParticipantIcon.Initials);
|
|
49
50
|
// Verify the rendered component + check the dots animation doesn't change over the time
|
|
50
|
-
|
|
51
|
+
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
51
52
|
cy.tick(10000);
|
|
52
|
-
|
|
53
|
+
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
53
54
|
cy.tick(20000);
|
|
54
|
-
|
|
55
|
+
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
55
56
|
cy.tick(30000);
|
|
56
|
-
|
|
57
|
+
ChatUiSelectors.chatMessageTypingDots.should('be.visible');
|
|
57
58
|
});
|
|
58
59
|
});
|