Skip to content

Commit 1e2cedf

Browse files
committed
test: add e2e integration tests for markdown list rendering
- Add tests for unordered lists with bullet points - Add tests for ordered lists with numbers - Add tests for nested list hierarchy - Add tests for mixed ordered/unordered lists - Verify proper rendering of list styles in chat interface
1 parent 96ae8ca commit 1e2cedf

File tree

1 file changed

+168
-0
lines changed

1 file changed

+168
-0
lines changed
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
import * as assert from "assert"
2+
3+
import type { ClineMessage } from "@roo-code/types"
4+
5+
import { waitUntilCompleted } from "./utils"
6+
import { setDefaultSuiteTimeout } from "./test-utils"
7+
8+
suite("Markdown List Rendering", function () {
9+
setDefaultSuiteTimeout(this)
10+
11+
test("Should render unordered lists with bullets in chat", async () => {
12+
const api = globalThis.api
13+
14+
const messages: ClineMessage[] = []
15+
16+
api.on("message", ({ message }: { message: ClineMessage }) => {
17+
if (message.type === "say" && message.partial === false) {
18+
messages.push(message)
19+
}
20+
})
21+
22+
const taskId = await api.startNewTask({
23+
configuration: { mode: "ask", alwaysAllowModeSwitch: true, autoApprovalEnabled: true },
24+
text: "Please show me an example of an unordered list with the following items: Apple, Banana, Orange",
25+
})
26+
27+
await waitUntilCompleted({ api, taskId })
28+
29+
// Find the message containing the list
30+
const listMessage = messages.find(
31+
({ say, text }) =>
32+
(say === "completion_result" || say === "text") &&
33+
text?.includes("Apple") &&
34+
text?.includes("Banana") &&
35+
text?.includes("Orange"),
36+
)
37+
38+
assert.ok(listMessage, "Should have a message containing the list items")
39+
40+
// The rendered markdown should contain list markers
41+
const messageText = listMessage?.text || ""
42+
assert.ok(
43+
messageText.includes("- Apple") || messageText.includes("* Apple") || messageText.includes("• Apple"),
44+
"List items should be rendered with bullet points",
45+
)
46+
})
47+
48+
test("Should render ordered lists with numbers in chat", async () => {
49+
const api = globalThis.api
50+
51+
const messages: ClineMessage[] = []
52+
53+
api.on("message", ({ message }: { message: ClineMessage }) => {
54+
if (message.type === "say" && message.partial === false) {
55+
messages.push(message)
56+
}
57+
})
58+
59+
const taskId = await api.startNewTask({
60+
configuration: { mode: "ask", alwaysAllowModeSwitch: true, autoApprovalEnabled: true },
61+
text: "Please show me a numbered list with three steps: First step, Second step, Third step",
62+
})
63+
64+
await waitUntilCompleted({ api, taskId })
65+
66+
// Find the message containing the numbered list
67+
const listMessage = messages.find(
68+
({ say, text }) =>
69+
(say === "completion_result" || say === "text") &&
70+
text?.includes("First step") &&
71+
text?.includes("Second step") &&
72+
text?.includes("Third step"),
73+
)
74+
75+
assert.ok(listMessage, "Should have a message containing the numbered list")
76+
77+
// The rendered markdown should contain numbered markers
78+
const messageText = listMessage?.text || ""
79+
assert.ok(
80+
messageText.includes("1. First step") || messageText.includes("1) First step"),
81+
"List items should be rendered with numbers",
82+
)
83+
})
84+
85+
test("Should render nested lists with proper hierarchy", async () => {
86+
const api = globalThis.api
87+
88+
const messages: ClineMessage[] = []
89+
90+
api.on("message", ({ message }: { message: ClineMessage }) => {
91+
if (message.type === "say" && message.partial === false) {
92+
messages.push(message)
93+
}
94+
})
95+
96+
const taskId = await api.startNewTask({
97+
configuration: { mode: "ask", alwaysAllowModeSwitch: true, autoApprovalEnabled: true },
98+
text: "Please create a nested list with 'Main item' having two sub-items: 'Sub-item A' and 'Sub-item B'",
99+
})
100+
101+
await waitUntilCompleted({ api, taskId })
102+
103+
// Find the message containing the nested list
104+
const listMessage = messages.find(
105+
({ say, text }) =>
106+
(say === "completion_result" || say === "text") &&
107+
text?.includes("Main item") &&
108+
text?.includes("Sub-item A") &&
109+
text?.includes("Sub-item B"),
110+
)
111+
112+
assert.ok(listMessage, "Should have a message containing the nested list")
113+
114+
// The rendered markdown should show hierarchy through indentation
115+
const messageText = listMessage?.text || ""
116+
117+
// Check for main item
118+
assert.ok(
119+
messageText.includes("- Main item") ||
120+
messageText.includes("* Main item") ||
121+
messageText.includes("• Main item"),
122+
"Main list item should be rendered",
123+
)
124+
125+
// Check for sub-items with indentation (typically 2-4 spaces or a tab)
126+
assert.ok(
127+
messageText.match(/\s{2,}- Sub-item A/) ||
128+
messageText.match(/\s{2,}\* Sub-item A/) ||
129+
messageText.match(/\s{2,} Sub-item A/) ||
130+
messageText.includes("\t- Sub-item A") ||
131+
messageText.includes("\t* Sub-item A") ||
132+
messageText.includes("\t• Sub-item A"),
133+
"Sub-items should be indented",
134+
)
135+
})
136+
137+
test("Should render mixed ordered and unordered lists", async () => {
138+
const api = globalThis.api
139+
140+
const messages: ClineMessage[] = []
141+
142+
api.on("message", ({ message }: { message: ClineMessage }) => {
143+
if (message.type === "say" && message.partial === false) {
144+
messages.push(message)
145+
}
146+
})
147+
148+
const taskId = await api.startNewTask({
149+
configuration: { mode: "ask", alwaysAllowModeSwitch: true, autoApprovalEnabled: true },
150+
text: "Please create a list that has both numbered items and bullet points, mixing ordered and unordered lists",
151+
})
152+
153+
await waitUntilCompleted({ api, taskId })
154+
155+
// Find a message that contains both types of lists
156+
const listMessage = messages.find(
157+
({ say, text }) =>
158+
(say === "completion_result" || say === "text") &&
159+
text &&
160+
// Check for numbered list markers
161+
(text.includes("1.") || text.includes("1)")) &&
162+
// Check for bullet list markers
163+
(text.includes("-") || text.includes("*") || text.includes("•")),
164+
)
165+
166+
assert.ok(listMessage, "Should have a message containing mixed list types")
167+
})
168+
})

0 commit comments

Comments
 (0)