import test from 'node:test';
import assert from 'node:assert/strict';
import { resolveWorkServerBuildInfoFilePaths } from './work-server-build-service.js';

test('resolveWorkServerBuildInfoFilePaths includes configured dist and mirrored main-project fallback paths', () => {
  const candidates = resolveWorkServerBuildInfoFilePaths({
    workServerRootPath: '/workspace/auto_codex/repo/etc/servers/work-server',
    mainProjectRoot: '/workspace/main-project',
    configuredDistDir: '/tmp/work-server-dist',
  });

  assert.deepEqual(candidates, [
    '/tmp/work-server-dist/build-info.json',
    '/workspace/auto_codex/repo/etc/servers/work-server/dist/build-info.json',
    '/workspace/main-project/etc/servers/work-server/dist/build-info.json',
  ]);
});

test('resolveWorkServerBuildInfoFilePaths deduplicates identical configured dist paths', () => {
  const candidates = resolveWorkServerBuildInfoFilePaths({
    workServerRootPath: '/workspace/main-project/etc/servers/work-server',
    mainProjectRoot: '/workspace/main-project',
    configuredDistDir: 'dist',
  });

  assert.deepEqual(candidates, ['/workspace/main-project/etc/servers/work-server/dist/build-info.json']);
});
