Skip to content

Commit 57e6c1b

Browse files
committed
test(server): cover symlinks in the Files tree listing
1 parent fea0460 commit 57e6c1b

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎apps/server/src/workspace/WorkspaceEntries.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,38 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceEntries", (it) => {
134134
}),
135135
);
136136

137+
it.effect("lists symlinks as what they point to, hiding ones that cannot be opened", () =>
138+
Effect.gen(function* () {
139+
const platform = yield* HostProcess.Platform;
140+
if (platform === "win32") return;
141+
const cwd = yield* makeTempDir({ git: true });
142+
const outside = yield* makeTempDir();
143+
const fileSystem = yield* FileSystem.FileSystem;
144+
const path = yield* Path.Path;
145+
yield* writeTextFile(cwd, "real.txt");
146+
yield* writeTextFile(cwd, "realdir/nested.txt");
147+
yield* writeTextFile(outside, "outside.txt");
148+
yield* fileSystem.symlink("real.txt", path.join(cwd, "link.txt"));
149+
yield* fileSystem.symlink("realdir", path.join(cwd, "linkdir"));
150+
yield* fileSystem.symlink(outside, path.join(cwd, "outside-link"));
151+
yield* fileSystem.symlink(".git", path.join(cwd, "git-link"));
152+
yield* fileSystem.symlink("missing", path.join(cwd, "dangling"));
153+
154+
const workspaceEntries = yield* WorkspaceEntries.WorkspaceEntries;
155+
const root = yield* workspaceEntries.list({ cwd, directoryPath: "" });
156+
expect(root.entries.toSorted((a, b) => a.path.localeCompare(b.path))).toEqual([
157+
{ path: "link.txt", kind: "file" },
158+
{ path: "linkdir", kind: "directory" },
159+
{ path: "real.txt", kind: "file" },
160+
{ path: "realdir", kind: "directory" },
161+
]);
162+
expect(yield* workspaceEntries.list({ cwd, directoryPath: "linkdir" })).toEqual({
163+
entries: [{ path: "linkdir/nested.txt", kind: "file" }],
164+
truncated: false,
165+
});
166+
}),
167+
);
168+
137169
it.effect("labels the children of wide folders exactly as git does for each child", () =>
138170
Effect.gen(function* () {
139171
// Above 1,000 children, listing first asks whether the whole folder is ignored.

0 commit comments

Comments
 (0)