Skip to content

Commit 01c15cb

Browse files
committed
test(chat): improve test coverage
1 parent 8ba2290 commit 01c15cb

16 files changed

+1879
-11
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ module.exports = {
1111
'\\.(css|scss|less)$': '<rootDir>/tests/styleMock.js',
1212
// make tests access in [email protected]
1313
'@babel/polyfill/lib/noConflict': '<rootDir>/tests/styleMock.js',
14+
'react-markdown': '<rootDir>/node_modules/react-markdown/react-markdown.min.js',
1415
},
1516
};

src/chat/__tests__/__snapshots__/content.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Test Content Match snapshot: normal 1`] = `
3+
exports[`Test Chat Content Match snapshot: normal 1`] = `
44
<DocumentFragment>
55
<div
66
class="dtc__aigc__content__container dtc__aigc__content__container--valid"
@@ -40,7 +40,7 @@ exports[`Test Content Match snapshot: normal 1`] = `
4040
</DocumentFragment>
4141
`;
4242

43-
exports[`Test Content Match snapshot: placeholder 1`] = `
43+
exports[`Test Chat Content Match snapshot: placeholder 1`] = `
4444
<DocumentFragment>
4545
<div
4646
class="dtc__aigc__content__container"

src/chat/__tests__/__snapshots__/icon.test.tsx.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Test Icon Match Snapshots: AssistantAvatarIcon 1`] = `
3+
exports[`Test Chat Icon Match Snapshots: AssistantAvatarIcon 1`] = `
44
<DocumentFragment>
55
<span
66
class="dtc__icon"
@@ -45,7 +45,7 @@ exports[`Test Icon Match Snapshots: AssistantAvatarIcon 1`] = `
4545
</DocumentFragment>
4646
`;
4747

48-
exports[`Test Icon Match Snapshots: CopyIcon 1`] = `
48+
exports[`Test Chat Icon Match Snapshots: CopyIcon 1`] = `
4949
<DocumentFragment>
5050
<span
5151
class="dtc__icon"
@@ -84,7 +84,7 @@ exports[`Test Icon Match Snapshots: CopyIcon 1`] = `
8484
</DocumentFragment>
8585
`;
8686

87-
exports[`Test Icon Match Snapshots: GradientDotIcon 1`] = `
87+
exports[`Test Chat Icon Match Snapshots: GradientDotIcon 1`] = `
8888
<DocumentFragment>
8989
<span
9090
class="dtc__icon"
@@ -153,7 +153,7 @@ exports[`Test Icon Match Snapshots: GradientDotIcon 1`] = `
153153
</DocumentFragment>
154154
`;
155155

156-
exports[`Test Icon Match Snapshots: PauseIcon 1`] = `
156+
exports[`Test Chat Icon Match Snapshots: PauseIcon 1`] = `
157157
<DocumentFragment>
158158
<span
159159
class="dtc__icon"
@@ -176,7 +176,7 @@ exports[`Test Icon Match Snapshots: PauseIcon 1`] = `
176176
</DocumentFragment>
177177
`;
178178

179-
exports[`Test Icon Match Snapshots: ReloadIcon 1`] = `
179+
exports[`Test Chat Icon Match Snapshots: ReloadIcon 1`] = `
180180
<DocumentFragment>
181181
<span
182182
class="dtc__icon"
@@ -199,7 +199,7 @@ exports[`Test Icon Match Snapshots: ReloadIcon 1`] = `
199199
</DocumentFragment>
200200
`;
201201

202-
exports[`Test Icon Match Snapshots: RobotIcon 1`] = `
202+
exports[`Test Chat Icon Match Snapshots: RobotIcon 1`] = `
203203
<DocumentFragment>
204204
<span
205205
class="dtc__icon"
@@ -245,7 +245,7 @@ exports[`Test Icon Match Snapshots: RobotIcon 1`] = `
245245
</DocumentFragment>
246246
`;
247247

248-
exports[`Test Icon Match Snapshots: SendIcon 1`] = `
248+
exports[`Test Chat Icon Match Snapshots: SendIcon 1`] = `
249249
<DocumentFragment>
250250
<span
251251
class="dtc__icon"
@@ -270,7 +270,7 @@ exports[`Test Icon Match Snapshots: SendIcon 1`] = `
270270
</DocumentFragment>
271271
`;
272272

273-
exports[`Test Icon Match Snapshots: SendIcon with gradient 1`] = `
273+
exports[`Test Chat Icon Match Snapshots: SendIcon with gradient 1`] = `
274274
<DocumentFragment>
275275
<span
276276
class="dtc__icon"
@@ -295,7 +295,7 @@ exports[`Test Icon Match Snapshots: SendIcon with gradient 1`] = `
295295
</DocumentFragment>
296296
`;
297297

298-
exports[`Test Icon Match Snapshots: ShiningIcon 1`] = `
298+
exports[`Test Chat Icon Match Snapshots: ShiningIcon 1`] = `
299299
<DocumentFragment>
300300
<span
301301
class="dtc__icon"
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Test Chat Markdown Match Snapshots: default 1`] = `
4+
<DocumentFragment>
5+
<div
6+
class="dtc__aigc__markdown"
7+
>
8+
<h1>
9+
title
10+
</h1>
11+
</div>
12+
</DocumentFragment>
13+
`;
14+
15+
exports[`Test Chat Markdown Match Snapshots: typing 1`] = `
16+
<DocumentFragment>
17+
<div
18+
class="dtc__aigc__markdown dtc__aigc__markdown--blink test"
19+
>
20+
<p>
21+
<code
22+
class="dtc__aigc__markdown__inlineCode"
23+
>
24+
inline code test
25+
</code>
26+
</p>
27+
28+
29+
<div
30+
class="dtc__aigc__codeblock"
31+
>
32+
<div
33+
class="dtc__aigc__codeblock__header"
34+
>
35+
<span
36+
class="dtc__aigc__codeblock__language"
37+
>
38+
sql
39+
</span>
40+
<div
41+
class="dtc__aigc__codeblock__tool"
42+
>
43+
<span
44+
class="dtc-copy"
45+
>
46+
<span
47+
class="dtc__icon"
48+
>
49+
<svg
50+
height="1em"
51+
viewBox="0 0 16 16"
52+
width="1em"
53+
xmlns="http://www.w3.org/2000/svg"
54+
>
55+
<g
56+
fill="none"
57+
fill-rule="evenodd"
58+
stroke="none"
59+
stroke-width="1"
60+
>
61+
<g
62+
transform="translate(-340 -367)"
63+
>
64+
<g
65+
transform="translate(201 320)"
66+
>
67+
<g
68+
transform="translate(139 47)"
69+
>
70+
<path
71+
d="M11 1.5A1.5 1.5 0 0112.5 3v.25h.5a1.5 1.5 0 011.5 1.5v8a1.5 1.5 0 01-1.5 1.5H5a1.5 1.5 0 01-1.5-1.5v-.25H3a1.5 1.5 0 01-1.493-1.356L1.5 11V3A1.5 1.5 0 013 1.5zm1.5 9.5a1.5 1.5 0 01-1.5 1.5H4.5v.25a.5.5 0 00.5.5h8a.5.5 0 00.5-.5v-8a.5.5 0 00-.5-.5h-.5zM11 2.5H3a.5.5 0 00-.5.5v8a.5.5 0 00.5.5h8a.5.5 0 00.5-.5V3a.5.5 0 00-.5-.5zm-4 1a.5.5 0 01.5.5v2.5H10a.5.5 0 110 1H7.5V10a.5.5 0 11-1 0V7.5H4a.5.5 0 010-1h2.5V4a.5.5 0 01.5-.5z"
72+
fill="currentColor"
73+
/>
74+
</g>
75+
</g>
76+
</g>
77+
</g>
78+
</svg>
79+
</span>
80+
</span>
81+
</div>
82+
</div>
83+
<pre
84+
style="background: rgb(255, 255, 255); color: rgb(56, 56, 56); font-family: "Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; direction: ltr; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; line-height: 1.5; tab-size: 2; hyphens: none; padding: 1em; margin: 0px; overflow: auto; border-radius: 0 0 4px 4px; max-height: 270px;"
85+
>
86+
<code
87+
class="language-sql"
88+
style="background: rgb(255, 255, 255); color: rgb(56, 56, 56); font-family: "Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; direction: ltr; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; line-height: 1.5; tab-size: 2; hyphens: none;"
89+
>
90+
<span>
91+
<span
92+
class="linenumber react-syntax-highlighter-line-number"
93+
style="display: inline-block; min-width: 1.25em; padding-right: 1em; text-align: right; user-select: none; font-style: italic; color: rgb(160, 160, 160);"
94+
>
95+
1
96+
</span>
97+
<span>
98+
99+
</span>
100+
<span
101+
class="token identifier"
102+
style="color: rgb(56, 56, 56);"
103+
>
104+
\`
105+
</span>
106+
<span
107+
class="token identifier"
108+
style="color: rgb(56, 56, 56);"
109+
>
110+
\`
111+
</span>
112+
<span
113+
class="token identifier"
114+
style="color: rgb(56, 56, 56);"
115+
>
116+
\`
117+
</span>
118+
<span
119+
class="token identifier"
120+
>
121+
sql
122+
123+
</span>
124+
</span>
125+
<span>
126+
<span
127+
class="linenumber react-syntax-highlighter-line-number"
128+
style="display: inline-block; min-width: 1.25em; padding-right: 1em; text-align: right; user-select: none; font-style: italic; color: rgb(160, 160, 160);"
129+
>
130+
2
131+
</span>
132+
SELECT * FROM table;
133+
134+
</span>
135+
<span>
136+
<span
137+
class="linenumber react-syntax-highlighter-line-number"
138+
style="display: inline-block; min-width: 1.25em; padding-right: 1em; text-align: right; user-select: none; font-style: italic; color: rgb(160, 160, 160);"
139+
>
140+
3
141+
</span>
142+
<span
143+
class="token identifier"
144+
>
145+
\`\`
146+
</span>
147+
<span
148+
class="token identifier"
149+
style="color: rgb(56, 56, 56);"
150+
>
151+
\`
152+
</span>
153+
<span>
154+
155+
156+
</span>
157+
</span>
158+
<span>
159+
<span
160+
class="linenumber react-syntax-highlighter-line-number"
161+
style="display: inline-block; min-width: 1.25em; padding-right: 1em; text-align: right; user-select: none; font-style: italic; color: rgb(160, 160, 160);"
162+
>
163+
4
164+
</span>
165+
166+
</span>
167+
</code>
168+
</pre>
169+
</div>
170+
</div>
171+
</DocumentFragment>
172+
`;

0 commit comments

Comments
 (0)