Files
automaker/apps/server/tests/unit/lib/automaker-paths.test.ts
Kacper dd58b70730 fix: resolve critical package issues and update imports
CRITICAL FIXES:
- Fix dependency-resolver ES module failure by reverting to CommonJS
  - Removed "type": "module" from package.json
  - Changed tsconfig.json module from "ESNext" to "commonjs"
  - Added exports field for better module resolution
  - Package now works correctly at runtime

- Fix Feature type incompatibility between server and UI
  - Added FeatureImagePath interface to @automaker/types
  - Made imagePaths property accept multiple formats
  - Added index signature for backward compatibility

HIGH PRIORITY FIXES:
- Remove duplicate model-resolver.ts from apps/server/src/lib/
  - Update sdk-options.ts to import from @automaker/model-resolver
  - Use @automaker/types for CLAUDE_MODEL_MAP and DEFAULT_MODELS

- Remove duplicate session types from apps/ui/src/types/
  - Deleted identical session.ts file
  - Use @automaker/types for session type definitions

- Update source file Feature imports
  - Fix create.ts and update.ts to import Feature from @automaker/types
  - Separate Feature type import from FeatureLoader class import

MEDIUM PRIORITY FIXES:
- Remove unused imports
  - Remove unused AbortError from agent-service.ts
  - Remove unused MessageSquare icon from kanban-card.tsx
  - Consolidate duplicate React imports in hotkey-button.tsx

- Update test file imports to use @automaker/* packages
  - Update 12 test files to import from @automaker/utils
  - Update 2 test files to import from @automaker/platform
  - Update 1 test file to import from @automaker/model-resolver
  - Update dependency-resolver.test.ts imports
  - Update providers/types imports to @automaker/types

VERIFICATION:
- Server builds successfully ✓
- All 6 shared packages build correctly ✓
- Test imports updated and verified ✓

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-20 00:16:00 +01:00

140 lines
4.0 KiB
TypeScript

import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import path from "path";
import fs from "fs/promises";
import os from "os";
import {
getAutomakerDir,
getFeaturesDir,
getFeatureDir,
getFeatureImagesDir,
getBoardDir,
getImagesDir,
getWorktreesDir,
getAppSpecPath,
getBranchTrackingPath,
ensureAutomakerDir,
} from "@automaker/platform";
describe("automaker-paths.ts", () => {
const projectPath = path.join("/test", "project");
describe("getAutomakerDir", () => {
it("should return path to .automaker directory", () => {
expect(getAutomakerDir(projectPath)).toBe(
path.join(projectPath, ".automaker")
);
});
it("should handle paths with trailing slashes", () => {
const pathWithSlash = path.join("/test", "project") + path.sep;
expect(getAutomakerDir(pathWithSlash)).toBe(
path.join(pathWithSlash, ".automaker")
);
});
});
describe("getFeaturesDir", () => {
it("should return path to features directory", () => {
expect(getFeaturesDir(projectPath)).toBe(
path.join(projectPath, ".automaker", "features")
);
});
});
describe("getFeatureDir", () => {
it("should return path to specific feature directory", () => {
expect(getFeatureDir(projectPath, "feature-123")).toBe(
path.join(projectPath, ".automaker", "features", "feature-123")
);
});
it("should handle feature IDs with special characters", () => {
expect(getFeatureDir(projectPath, "my-feature_v2")).toBe(
path.join(projectPath, ".automaker", "features", "my-feature_v2")
);
});
});
describe("getFeatureImagesDir", () => {
it("should return path to feature images directory", () => {
expect(getFeatureImagesDir(projectPath, "feature-123")).toBe(
path.join(projectPath, ".automaker", "features", "feature-123", "images")
);
});
});
describe("getBoardDir", () => {
it("should return path to board directory", () => {
expect(getBoardDir(projectPath)).toBe(
path.join(projectPath, ".automaker", "board")
);
});
});
describe("getImagesDir", () => {
it("should return path to images directory", () => {
expect(getImagesDir(projectPath)).toBe(
path.join(projectPath, ".automaker", "images")
);
});
});
describe("getWorktreesDir", () => {
it("should return path to worktrees directory", () => {
expect(getWorktreesDir(projectPath)).toBe(
path.join(projectPath, ".automaker", "worktrees")
);
});
});
describe("getAppSpecPath", () => {
it("should return path to app_spec.txt file", () => {
expect(getAppSpecPath(projectPath)).toBe(
path.join(projectPath, ".automaker", "app_spec.txt")
);
});
});
describe("getBranchTrackingPath", () => {
it("should return path to active-branches.json file", () => {
expect(getBranchTrackingPath(projectPath)).toBe(
path.join(projectPath, ".automaker", "active-branches.json")
);
});
});
describe("ensureAutomakerDir", () => {
let testDir: string;
beforeEach(async () => {
testDir = path.join(os.tmpdir(), `automaker-paths-test-${Date.now()}`);
await fs.mkdir(testDir, { recursive: true });
});
afterEach(async () => {
try {
await fs.rm(testDir, { recursive: true, force: true });
} catch {
// Ignore cleanup errors
}
});
it("should create automaker directory and return path", async () => {
const result = await ensureAutomakerDir(testDir);
expect(result).toBe(path.join(testDir, ".automaker"));
const stats = await fs.stat(result);
expect(stats.isDirectory()).toBe(true);
});
it("should succeed if directory already exists", async () => {
const automakerDir = path.join(testDir, ".automaker");
await fs.mkdir(automakerDir, { recursive: true });
const result = await ensureAutomakerDir(testDir);
expect(result).toBe(automakerDir);
});
});
});