diff --git a/tests/fs-create-file.spec.ts b/tests/fs-create-file.spec.ts index 1c939900..0503aa5b 100644 --- a/tests/fs-create-file.spec.ts +++ b/tests/fs-create-file.spec.ts @@ -91,7 +91,9 @@ describe('createWorkspaceFile', () => { for (const name of ['console.txt', 'conx', 'COM10', 'LPT', 'null.md', 'auxiliary']) { await expect(createWorkspaceFile({ cwd: root, path: root, name })).resolves.toEqual({ path: join(root, name) }) } - expect(await readdir(root)).toEqual(['COM10', 'LPT', 'auxiliary', 'console.txt', 'conx', 'null.md']) + // `readdir` order is filesystem-defined (Windows returns a different order than + // ext4/APFS), so compare the sorted name set instead of the raw listing. + expect((await readdir(root)).sort()).toEqual(['COM10', 'LPT', 'auxiliary', 'console.txt', 'conx', 'null.md']) }) it('refuses an existing destination with the same conflict code as rename and mkdir', async () => { diff --git a/tests/open-external.spec.ts b/tests/open-external.spec.ts index e1160a00..4959370a 100644 --- a/tests/open-external.spec.ts +++ b/tests/open-external.spec.ts @@ -4,6 +4,7 @@ * OS handlers are not launched in unit tests. */ import { EventEmitter } from 'node:events' +import { dirname, resolve } from 'node:path' import { describe, expect, it, vi } from 'vitest' import { launchExternal, @@ -284,10 +285,11 @@ describe('launchExternal Windows branch order and failure reporting', () => { it('reports a reveal failure with the same shape (one branch, `path` subject)', async () => { const fake = recordingSpawn() - // Path absoluteness is checked with the HOST path module, so this case uses - // the linux branch (an absolute POSIX path) to pin the aggregated message - // of the reveal half. - const pending = launchExternal('reveal', '/a/b.txt', { + // The path is normalized and its parent derived with the HOST path module, + // so the fixture must be host-absolute too — a literal `/a/b.txt` is not an + // absolute path on Windows (win32 resolves it against the current drive). + const file = resolve('/', 'a', 'b.txt') + const pending = launchExternal('reveal', file, { platform: 'linux', wsl: false, spawn: fake.spawn, @@ -296,7 +298,7 @@ describe('launchExternal Windows branch order and failure reporting', () => { const error = await pending.then(() => null, (reason: unknown) => reason) expect(fake.calls.map(call => ({ command: call.command, args: call.args }))).toEqual([ - { command: 'xdg-open', args: ['/a'] }, + { command: 'xdg-open', args: [dirname(file)] }, ]) expect((error as SidebarError).message).toBe( 'failed to launch external opener for the path: "xdg-open" (spawn xdg-open ENOENT)',