Skip to content

Commit 3aa08be

Browse files
test(file-safety,mcp): pin the DACL fallback outcome and the deleteServer teardown
Review follow-ups: - the win32 DACL-failure fallback test asserted only that a rename happened; it now pins the commit rename onto the target path and that a failed icacls save skips the restore step (execFile exactly once). Renaming elsewhere or restoring after a failed save reddens the test. - the deleteServer symlink-policy fixture gave the connection empty client/transport doubles: deleteConnection's close calls raised a swallowed TypeError, so the teardown silently did nothing. Typed close doubles now run to completion and the test asserts both closes happened; reverting to empty doubles reddens exactly it.
1 parent f9a7746 commit 3aa08be

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎src/services/file-safety/__tests__/safeWriteText.spec.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,12 @@ describe("safeWriteText", () => {
316316

317317
await safeWriteText(targetPath, "data", { platform: "win32" })
318318

319-
// write succeeded despite icacls failure (fallback to plain rename)
320-
expect(fs.rename).toHaveBeenCalled()
319+
// write succeeded despite icacls failure (fallback to plain rename):
320+
// pin the commit rename onto the target - a rename to any other path
321+
// would silently publish elsewhere - and pin that a failed save skips
322+
// the restore step entirely.
323+
expect(fs.rename).toHaveBeenCalledWith(expect.stringContaining("safeWriteText_"), targetPath)
324+
expect(execFile).toHaveBeenCalledTimes(1)
321325
})
322326

323327
it("win32 DACL: a partial dump left by a failed save is still unlinked", async () => {

‎src/services/mcp/__tests__/McpHub.spec.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,12 @@ describe("McpHub", () => {
10511051
mcpServers: { "test-server": { type: "stdio", command: "node", args: ["test.js"] } },
10521052
}),
10531053
)
1054+
// Typed close doubles: updateServerConnections tears the connection
1055+
// down through transport.close() and client.close(). Empty doubles
1056+
// raise a TypeError that deleteConnection swallows, so the teardown
1057+
// would silently do nothing and the test would still pass.
1058+
const transportClose = vi.fn(async () => {})
1059+
const clientClose = vi.fn(async () => {})
10541060
mcpHub.connections = [
10551061
{
10561062
type: "connected",
@@ -1061,8 +1067,8 @@ describe("McpHub", () => {
10611067
args: ["test.js"],
10621068
source: "project",
10631069
},
1064-
client: {},
1065-
transport: {},
1070+
client: { close: clientClose },
1071+
transport: { close: transportClose },
10661072
} as unknown as ConnectedMcpConnection,
10671073
]
10681074

@@ -1071,6 +1077,10 @@ describe("McpHub", () => {
10711077
// value, or a project server reached through an omitted argument loses symlink refusal.
10721078
await mcpHub.deleteServer("test-server")
10731079

1080+
// The teardown ran to completion rather than dying on a TypeError.
1081+
expect(transportClose).toHaveBeenCalledTimes(1)
1082+
expect(clientClose).toHaveBeenCalledTimes(1)
1083+
10741084
const write = vi.mocked(safeWriteJson).mock.calls.at(-1)
10751085
expect(write && write[2]).toEqual(expect.objectContaining({ refuseSymlinkTarget: true }))
10761086
})

0 commit comments

Comments
 (0)