mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-09 22:31:08 +00:00
Fixes for prompts suite unit tests on windows (#1879)
* Fixes for prompts suite unit tests on windows * unixLike -> toPosix Fix naming, and re-use code that already provides this function
This commit is contained in:
parent
87b9b72b32
commit
2ab5aad183
3 changed files with 17 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ import { SYSTEM_PROMPT } from "../system"
|
|||
import { defaultModeSlug, modes } from "../../../shared/modes"
|
||||
import * as vscode from "vscode"
|
||||
import * as fs from "fs/promises"
|
||||
import { toPosix } from "./utils"
|
||||
|
||||
// Mock the fs/promises module
|
||||
jest.mock("fs/promises", () => ({
|
||||
|
|
@ -89,7 +90,7 @@ describe("File-Based Custom System Prompt", () => {
|
|||
const fileCustomSystemPrompt = "Custom system prompt from file"
|
||||
// When called with utf-8 encoding, return a string
|
||||
mockedFs.readFile.mockImplementation((filePath, options) => {
|
||||
if (filePath.toString().includes(`.roo/system-prompt-${defaultModeSlug}`) && options === "utf-8") {
|
||||
if (toPosix(filePath).includes(`.roo/system-prompt-${defaultModeSlug}`) && options === "utf-8") {
|
||||
return Promise.resolve(fileCustomSystemPrompt)
|
||||
}
|
||||
return Promise.reject({ code: "ENOENT" })
|
||||
|
|
@ -124,7 +125,7 @@ describe("File-Based Custom System Prompt", () => {
|
|||
// Mock the readFile to return content from a file
|
||||
const fileCustomSystemPrompt = "Custom system prompt from file"
|
||||
mockedFs.readFile.mockImplementation((filePath, options) => {
|
||||
if (filePath.toString().includes(`.roo/system-prompt-${defaultModeSlug}`) && options === "utf-8") {
|
||||
if (toPosix(filePath).includes(`.roo/system-prompt-${defaultModeSlug}`) && options === "utf-8") {
|
||||
return Promise.resolve(fileCustomSystemPrompt)
|
||||
}
|
||||
return Promise.reject({ code: "ENOENT" })
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
import { formatResponse } from "../responses"
|
||||
import { RooIgnoreController, LOCK_TEXT_SYMBOL } from "../../ignore/RooIgnoreController"
|
||||
import * as path from "path"
|
||||
import { fileExistsAtPath } from "../../../utils/fs"
|
||||
import * as fs from "fs/promises"
|
||||
import { toPosix } from "./utils"
|
||||
|
||||
// Mock dependencies
|
||||
jest.mock("../../../utils/fs")
|
||||
|
|
@ -82,7 +82,9 @@ describe("RooIgnore Response Formatting", () => {
|
|||
controller.validateAccess = jest.fn().mockImplementation((filePath: string) => {
|
||||
// Only allow files not matching these patterns
|
||||
return (
|
||||
!filePath.includes("node_modules") && !filePath.includes(".git") && !filePath.includes("secrets/")
|
||||
!filePath.includes("node_modules") &&
|
||||
!filePath.includes(".git") &&
|
||||
!toPosix(filePath).includes("secrets/")
|
||||
)
|
||||
})
|
||||
|
||||
|
|
@ -124,7 +126,9 @@ describe("RooIgnore Response Formatting", () => {
|
|||
controller.validateAccess = jest.fn().mockImplementation((filePath: string) => {
|
||||
// Only allow files not matching these patterns
|
||||
return (
|
||||
!filePath.includes("node_modules") && !filePath.includes(".git") && !filePath.includes("secrets/")
|
||||
!filePath.includes("node_modules") &&
|
||||
!filePath.includes(".git") &&
|
||||
!toPosix(filePath).includes("secrets/")
|
||||
)
|
||||
})
|
||||
|
||||
|
|
|
|||
7
src/core/prompts/__tests__/utils.ts
Normal file
7
src/core/prompts/__tests__/utils.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import * as fs from "fs/promises"
|
||||
import { PathLike } from "fs"
|
||||
|
||||
// Make a path take a unix-like form. Useful for making path comparisons.
|
||||
export function toPosix(filePath: PathLike | fs.FileHandle) {
|
||||
return filePath.toString().toPosix()
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue