diff --git a/src/utils/__tests__/xml.spec.ts b/src/utils/__tests__/xml.spec.ts
index f7a282b0c0..7e4b3e291f 100644
--- a/src/utils/__tests__/xml.spec.ts
+++ b/src/utils/__tests__/xml.spec.ts
@@ -1,6 +1,115 @@
import { parseXml, parseXmlForDiff } from "../xml"
describe("parseXml", () => {
+ describe("whitespace handling", () => {
+ it("should handle spaces between XML tags", () => {
+ const xml = `
+
+ ./test/file.ts
+
+ `
+
+ const result = parseXml(xml) as any
+
+ expect(result.read_file).toBeDefined()
+ expect(result.read_file.path).toBe("./test/file.ts")
+ })
+
+ it("should handle newlines and spaces in nested XML", () => {
+ const xml = `
+
+
+
+ ./src/main.ts
+
+
+
+ `
+
+ const result = parseXml(xml) as any
+
+ expect(result.args).toBeDefined()
+ expect(result.args.file).toBeDefined()
+ expect(result.args.file.path).toBe("./src/main.ts")
+ })
+
+ it("should handle multiple files with whitespace", () => {
+ const xml = `
+
+
+ ./file1.ts
+
+
+
+ ./file2.ts
+
+
+
+ `
+
+ const result = parseXml(xml) as any
+
+ expect(result.args).toBeDefined()
+ expect(Array.isArray(result.args.file)).toBe(true)
+ expect(result.args.file).toHaveLength(2)
+ expect(result.args.file[0].path).toBe("./file1.ts")
+ expect(result.args.file[1].path).toBe("./file2.ts")
+ })
+
+ it("should handle mixed content with whitespace", () => {
+ const xml = `
+
+
+ ./output.txt
+
+
+ Some content here
+
+
+ `
+
+ const result = parseXml(xml) as any
+
+ expect(result.write_to_file).toBeDefined()
+ expect(result.write_to_file.path).toBe("./output.txt")
+ expect(result.write_to_file.content).toBe("Some content here")
+ })
+
+ it("should handle empty tags with whitespace", () => {
+ const xml = `
+
+
+
+
+
+
+ `
+
+ const result = parseXml(xml) as any
+
+ expect(result.test).toBeDefined()
+ expect(result.test.empty).toBe("")
+ expect(result.test.another).toBe("")
+ })
+
+ it("should handle tabs and mixed whitespace", () => {
+ const xml = `
+
+ ./file.ts
+
+ arg1 arg2
+
+
+ `
+
+ const result = parseXml(xml) as any
+
+ expect(result.command).toBeDefined()
+ expect(result.command.path).toBe("./file.ts")
+ expect(result.command.args).toBe("arg1 arg2")
+ })
+ })
+
describe("type conversion", () => {
// Test the main change from the commit: no automatic type conversion
it("should not convert string numbers to numbers", () => {