From b6de1506ff16b8f11baaf9837e37d731101233c9 Mon Sep 17 00:00:00 2001 From: Jason Hyde Date: Tue, 15 Sep 2026 23:03:26 +0200 Subject: [PATCH 1/2] build the test vault paths with node:path so they match on windows --- source/cli.test.ts | 9 +++++---- source/connection.test.ts | 22 ++++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/source/cli.test.ts b/source/cli.test.ts index 6976511..b4cd87b 100644 --- a/source/cli.test.ts +++ b/source/cli.test.ts @@ -1,11 +1,12 @@ +import { join, resolve } from 'node:path' import { createRouter } from '@dotpm/api' import { FakeApi } from '@dotpm/api/testing' import { beforeEach, describe, expect, it } from 'vitest' import { runCli, type CliDeps } from './cli.ts' const TOKEN = 'secret-token-0123456789' -const VAULT = '/vault' -const SETTINGS = `${VAULT}/.obsidian/plugins/project-manager/data.json` +const VAULT = resolve('/vault') +const SETTINGS = join(VAULT, '.obsidian', 'plugins', 'project-manager', 'data.json') interface Run { code: number @@ -40,10 +41,10 @@ describe('runCli', () => { } const deps: CliDeps = { env, - cwd: `${VAULT}/Projects`, + cwd: join(VAULT, 'Projects'), tty, version: '1.2.3', - exists: (path) => path === `${VAULT}/.obsidian` || path in files, + exists: (path) => path === join(VAULT, '.obsidian') || path in files, readFile: (path) => files[path] ?? null, readStdin: async () => stdin, stdinLines: async function* () {}, diff --git a/source/connection.test.ts b/source/connection.test.ts index a9e323d..4a96a98 100644 --- a/source/connection.test.ts +++ b/source/connection.test.ts @@ -1,14 +1,16 @@ +import { join, resolve } from 'node:path' import { describe, expect, it } from 'vitest' import { resolveConnection, type ConnectionInput } from './connection.ts' -const VAULT = '/home/me/Notes' -const SETTINGS = `${VAULT}/.obsidian/plugins/project-manager/data.json` +const VAULT = resolve('/home/me/Notes') +const SETTINGS = join(VAULT, '.obsidian', 'plugins', 'project-manager', 'data.json') +const ELSEWHERE = resolve('/elsewhere') function input(overrides: Partial = {}, files: Record = {}): ConnectionInput { - const present = new Set([`${VAULT}/.obsidian`, ...Object.keys(files)]) + const present = new Set([join(VAULT, '.obsidian'), ...Object.keys(files)]) return { env: {}, - cwd: `${VAULT}/Projects/Website_tasks`, + cwd: join(VAULT, 'Projects', 'Website_tasks'), exists: (path) => present.has(path), readFile: (path) => files[path] ?? null, ...overrides @@ -40,13 +42,17 @@ describe('resolveConnection', () => { }) it('reads a vault named by flag or environment', () => { - expect(resolveConnection(input({ vault: VAULT, cwd: '/elsewhere' }, { [SETTINGS]: ON })).token).toBe('tok') - expect(resolveConnection(input({ env: { DOTPM_VAULT: VAULT }, cwd: '/' }, { [SETTINGS]: ON })).token).toBe('tok') - expect(() => resolveConnection(input({ vault: '/nope' }, { [SETTINGS]: ON }))).toThrow('not an Obsidian vault') + expect(resolveConnection(input({ vault: VAULT, cwd: ELSEWHERE }, { [SETTINGS]: ON })).token).toBe('tok') + expect(resolveConnection(input({ env: { DOTPM_VAULT: VAULT }, cwd: resolve('/') }, { [SETTINGS]: ON })).token).toBe( + 'tok' + ) + expect(() => resolveConnection(input({ vault: resolve('/nope') }, { [SETTINGS]: ON }))).toThrow( + 'not an Obsidian vault' + ) }) it('explains what is missing in a vault', () => { - expect(() => resolveConnection(input({ cwd: '/tmp' }))).toThrow('no Obsidian vault holds /tmp') + expect(() => resolveConnection(input({ cwd: ELSEWHERE }))).toThrow(`no Obsidian vault holds ${ELSEWHERE}`) expect(() => resolveConnection(input())).toThrow('dotpm is not installed') expect(() => resolveConnection(input({}, { [SETTINGS]: '{oops' }))).toThrow('could not be read') expect(() => resolveConnection(input({}, { [SETTINGS]: '{"localApiEnabled":false}' }))).toThrow( From 12af1d3074dc2ed56e81ac0be3180abd398276e9 Mon Sep 17 00:00:00 2001 From: Jason Hyde Date: Tue, 15 Sep 2026 23:05:30 +0200 Subject: [PATCH 2/2] expect the resolved vault path in the status table --- source/cli.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/cli.test.ts b/source/cli.test.ts index b4cd87b..3d1b534 100644 --- a/source/cli.test.ts +++ b/source/cli.test.ts @@ -97,7 +97,7 @@ describe('runCli', () => { expect(task.out).toContain('title First') const status = await run(['status']) expect(status.out).toContain('server dotpm 9.9.9') - expect(status.out).toContain('from the vault at /vault') + expect(status.out).toContain(`from the vault at ${VAULT}`) expect((await run(['--json', 'status'])).json).toMatchObject({ ok: true, url: 'http://127.0.0.1:27151' }) })