Skip to content

Commit 35d22e0

Browse files
author
Eric Wheeler
committed
test: update environment details tests to match XML format
Updated the getEnvironmentDetails.spec.ts tests to expect XML format instead of markdown headings. The implementation was changed to use XML format with the fast-xml-parser library, but the tests were still expecting markdown format. This change updates the tests to match the new XML structure while preserving the same semantic checks. Signed-off-by: Eric Wheeler <[email protected]>
1 parent 8734faf commit 35d22e0

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

src/core/environment/__tests__/getEnvironmentDetails.spec.ts

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,13 @@ describe("getEnvironmentDetails", () => {
141141
it("should return basic environment details", async () => {
142142
const result = await getEnvironmentDetails(mockCline as Task)
143143

144-
expect(result).toContain("<environment_details>")
145-
expect(result).toContain("</environment_details>")
146-
expect(result).toContain("# VSCode Visible Files")
147-
expect(result).toContain("# VSCode Open Tabs")
148-
expect(result).toContain("# Current Time")
149-
expect(result).toContain("# Current Cost")
150-
expect(result).toContain("# Current Mode")
151-
expect(result).toContain("<model>test-model</model>")
144+
expect(result).toContain("<environment_details")
145+
expect(result).toContain("<time")
146+
expect(result).toContain("<cost")
147+
expect(result).toContain("<mode")
148+
expect(result).toContain('t="0.25"')
149+
expect(result).toContain('c="USD"')
150+
expect(result).toContain('model="test-model"')
152151

153152
expect(mockProvider.getState).toHaveBeenCalled()
154153

@@ -163,8 +162,8 @@ describe("getEnvironmentDetails", () => {
163162

164163
it("should include file details when includeFileDetails is true", async () => {
165164
const result = await getEnvironmentDetails(mockCline as Task, true)
166-
expect(result).toContain("# Current Workspace Directory")
167-
expect(result).toContain("Files")
165+
expect(result).toContain("<workspace")
166+
expect(result).toContain("directory=")
168167

169168
expect(listFiles).toHaveBeenCalledWith(mockCwd, true, 50)
170169

@@ -211,9 +210,9 @@ describe("getEnvironmentDetails", () => {
211210

212211
const result = await getEnvironmentDetails(mockCline as Task)
213212

214-
expect(result).toContain("# Recently Modified Files")
215-
expect(result).toContain("modified1.ts")
216-
expect(result).toContain("modified2.ts")
213+
expect(result).toContain("<recentlyModified>")
214+
expect(result).toContain('path="modified1.ts"')
215+
expect(result).toContain('path="modified2.ts"')
217216
})
218217

219218
it("should include active terminal information", async () => {
@@ -229,10 +228,11 @@ describe("getEnvironmentDetails", () => {
229228

230229
const result = await getEnvironmentDetails(mockCline as Task)
231230

232-
expect(result).toContain("# Actively Running Terminals")
233-
expect(result).toContain("## Terminal terminal-1 (Active)")
234-
expect(result).toContain("### Working Directory: `/test/path/src`")
235-
expect(result).toContain("### Original command: `npm test`")
231+
expect(result).toContain("<terminal")
232+
expect(result).toContain('id="terminal-1"')
233+
expect(result).toContain('status="Active"')
234+
expect(result).toContain('cwd="/test/path/src"')
235+
expect(result).toContain('command="npm test"')
236236
expect(result).toContain("Test output")
237237

238238
mockCline.didEditFile = true
@@ -262,10 +262,11 @@ describe("getEnvironmentDetails", () => {
262262

263263
const result = await getEnvironmentDetails(mockCline as Task)
264264

265-
expect(result).toContain("# Inactive Terminals with Completed Process Output")
266-
expect(result).toContain("## Terminal terminal-2 (Inactive)")
267-
expect(result).toContain("### Working Directory: `/test/path/build`")
268-
expect(result).toContain("Command: `npm build`")
265+
expect(result).toContain("<terminal")
266+
expect(result).toContain('id="terminal-2"')
267+
expect(result).toContain('status="Inactive"')
268+
expect(result).toContain('cwd="/test/path/build"')
269+
expect(result).toContain('command="npm build"')
269270
expect(result).toContain("Build output")
270271

271272
expect(mockInactiveTerminal.cleanCompletedProcessQueue).toHaveBeenCalled()
@@ -300,13 +301,15 @@ describe("getEnvironmentDetails", () => {
300301
const result = await getEnvironmentDetails(mockCline as Task)
301302

302303
// Check active terminal working directory
303-
expect(result).toContain("## Terminal terminal-1 (Active)")
304-
expect(result).toContain("### Working Directory: `/some/path`")
305-
expect(result).toContain("### Original command: `cd /some/path && npm start`")
304+
expect(result).toContain('id="terminal-1"')
305+
expect(result).toContain('status="Active"')
306+
expect(result).toContain('cwd="/some/path"')
307+
expect(result).toContain('command="cd /some/path &amp;&amp; npm start"')
306308

307309
// Check inactive terminal working directory
308-
expect(result).toContain("## Terminal terminal-2 (Inactive)")
309-
expect(result).toContain("### Working Directory: `/another/path`")
310+
expect(result).toContain('id="terminal-2"')
311+
expect(result).toContain('status="Inactive"')
312+
expect(result).toContain('cwd="/another/path"')
310313

311314
// Verify the methods were called
312315
expect(mockActiveTerminal.getCurrentWorkingDirectory).toHaveBeenCalled()
@@ -319,8 +322,9 @@ describe("getEnvironmentDetails", () => {
319322

320323
const result = await getEnvironmentDetails(mockCline as Task)
321324

322-
expect(result).toContain("<role>You are a code assistant</role>")
323-
expect(result).toContain("<custom_instructions>Custom instructions</custom_instructions>")
325+
expect(result).toContain("<mode")
326+
expect(result).toContain('role="You are a code assistant"')
327+
expect(result).toContain('customInstructions="Custom instructions"')
324328
})
325329

326330
it("should handle missing provider or state", async () => {
@@ -341,8 +345,7 @@ describe("getEnvironmentDetails", () => {
341345
const result2 = await getEnvironmentDetails(mockCline as Task)
342346

343347
// Verify the function still returns a result.
344-
expect(result2).toContain("<environment_details>")
345-
expect(result2).toContain("</environment_details>")
348+
expect(result2).toContain("<environment_details")
346349
})
347350

348351
it("should handle errors gracefully", async () => {

0 commit comments

Comments
 (0)