chore(ci): fix cross-platform symlink path assertions in agents file tests

This commit is contained in:
Gustavo Madeira Santana
2026-02-26 00:39:18 -05:00
parent 91a3f0a3fe
commit 39a1c13635

View File

@@ -1,3 +1,4 @@
import path from "node:path";
import { describe, expect, it, vi, beforeEach } from "vitest";
/* ------------------------------------------------------------------ */
@@ -515,7 +516,7 @@ describe("agents.files.get/set symlink safety", () => {
it("rejects agents.files.get when allowlisted file symlink escapes workspace", async () => {
const workspace = "/workspace/test-agent";
const candidate = `${workspace}/AGENTS.md`;
const candidate = path.resolve(workspace, "AGENTS.md");
mocks.fsRealpath.mockImplementation(async (p: string) => {
if (p === workspace) {
return workspace;
@@ -548,7 +549,7 @@ describe("agents.files.get/set symlink safety", () => {
it("rejects agents.files.set when allowlisted file symlink escapes workspace", async () => {
const workspace = "/workspace/test-agent";
const candidate = `${workspace}/AGENTS.md`;
const candidate = path.resolve(workspace, "AGENTS.md");
mocks.fsRealpath.mockImplementation(async (p: string) => {
if (p === workspace) {
return workspace;
@@ -583,8 +584,8 @@ describe("agents.files.get/set symlink safety", () => {
it("allows in-workspace symlink targets for get/set", async () => {
const workspace = "/workspace/test-agent";
const candidate = `${workspace}/AGENTS.md`;
const target = `${workspace}/policies/AGENTS.md`;
const candidate = path.resolve(workspace, "AGENTS.md");
const target = path.resolve(workspace, "policies", "AGENTS.md");
const targetStat = makeFileStat({ size: 7, mtimeMs: 1700, dev: 9, ino: 42 });
mocks.fsRealpath.mockImplementation(async (p: string) => {