mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
test(images): add CDN URI conversion tests for normalizeImageRefsToDataUrls
Add test coverage for HTTPS CDN URL conversion (e.g., https://file+.vscode-resource.vscode-cdn.net/...) to base64 data URLs. This covers the critical URI-to-base64 conversion flow that was previously only tested with legacy file:// URIs.
This commit is contained in:
parent
c445cfe4c7
commit
f3b31d7a53
1 changed files with 27 additions and 0 deletions
|
|
@ -18,6 +18,33 @@ describe("normalizeImageRefsToDataUrls", () => {
|
|||
expect(result).toEqual([dataUrl])
|
||||
})
|
||||
|
||||
it("should convert CDN webview URIs to data URLs", async () => {
|
||||
const cdnUri = "https://file+.vscode-resource.vscode-cdn.net/path/to/test.png"
|
||||
const mockBuffer = Buffer.from("test image data")
|
||||
|
||||
vi.mocked(fs.readFile).mockResolvedValue(mockBuffer)
|
||||
|
||||
const result = await normalizeImageRefsToDataUrls([cdnUri])
|
||||
|
||||
expect(result).toHaveLength(1)
|
||||
expect(result[0]).toMatch(/^data:image\/png;base64,/)
|
||||
expect(fs.readFile).toHaveBeenCalledWith("/path/to/test.png")
|
||||
})
|
||||
|
||||
it("should handle mixed arrays of data URLs and CDN URIs", async () => {
|
||||
const dataUrl = "data:image/jpeg;base64,test123"
|
||||
const cdnUri = "https://file+.vscode-resource.vscode-cdn.net/path/to/test.png"
|
||||
const mockBuffer = Buffer.from("test image data")
|
||||
|
||||
vi.mocked(fs.readFile).mockResolvedValue(mockBuffer)
|
||||
|
||||
const result = await normalizeImageRefsToDataUrls([dataUrl, cdnUri])
|
||||
|
||||
expect(result).toHaveLength(2)
|
||||
expect(result[0]).toBe(dataUrl) // Data URL unchanged
|
||||
expect(result[1]).toMatch(/^data:image\/png;base64,/) // CDN URI converted
|
||||
})
|
||||
|
||||
it("should handle errors gracefully by skipping problematic images", async () => {
|
||||
const validDataUrl = "data:image/png;base64,valid"
|
||||
const invalidCdnUri = "vscode-file://vscode-app/nonexistent/test.png"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue