From ee714f5a420b20b99809375bd8c59c6c089fa07a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 25 Mar 2026 06:23:43 -0700 Subject: [PATCH] test(media): make local roots fixture windows-safe --- src/media/local-roots.test.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/media/local-roots.test.ts b/src/media/local-roots.test.ts index 4f6478b950a..aa34f890905 100644 --- a/src/media/local-roots.test.ts +++ b/src/media/local-roots.test.ts @@ -1,4 +1,5 @@ import path from "node:path"; +import { pathToFileURL } from "node:url"; import { afterEach, describe, expect, it, vi } from "vitest"; import { appendLocalMediaParentRoots, @@ -43,11 +44,16 @@ describe("local media roots", () => { }); it("adds concrete parent roots for local media sources without widening to filesystem root", () => { + const picturesDir = + process.platform === "win32" ? "C:\\Users\\peter\\Pictures" : "/Users/peter/Pictures"; + const moviesDir = + process.platform === "win32" ? "C:\\Users\\peter\\Movies" : "/Users/peter/Movies"; + const roots = appendLocalMediaParentRoots( ["/tmp/base"], [ - "/Users/peter/Pictures/photo.png", - "file:///Users/peter/Movies/clip.mp4", + path.join(picturesDir, "photo.png"), + pathToFileURL(path.join(moviesDir, "clip.mp4")).href, "https://example.com/remote.png", "/top-level-file.png", ], @@ -56,8 +62,8 @@ describe("local media roots", () => { expect(roots.map(normalizeHostPath)).toEqual( expect.arrayContaining([ normalizeHostPath("/tmp/base"), - normalizeHostPath("/Users/peter/Pictures"), - normalizeHostPath("/Users/peter/Movies"), + normalizeHostPath(picturesDir), + normalizeHostPath(moviesDir), ]), ); expect(roots.map(normalizeHostPath)).not.toContain(normalizeHostPath("/"));