Files
obsidian-mcp-server/tests/__mocks__/obsidian.ts
Bill 7524271eaa Release v1.1.0: Phase 1.1 - Path Normalization & Error Handling
- Add PathUtils for cross-platform path normalization and validation
- Add ErrorMessages with context-aware, actionable error messages
- Update all tool implementations with enhanced path handling
- Improve tool descriptions for AI agents with detailed guidance
- Add Jest testing infrastructure with 43 passing tests
- Add comprehensive documentation (Tool Selection Guide, error improvements)
- Fix cross-platform path issues (Windows backslashes, case sensitivity)
- Fix delete folder error message (clear 'cannot delete folders' message)
- Fix parent folder detection with specific error messages
- All changes backward compatible with v1.0.0

New files:
- src/utils/path-utils.ts - Path normalization utilities
- src/utils/error-messages.ts - Enhanced error messages
- tests/__mocks__/obsidian.ts - Mock Obsidian API
- tests/path-utils.test.ts - 43 unit tests
- tests/README.md - Testing guide
- jest.config.js - Jest configuration
- docs/TOOL_SELECTION_GUIDE.md - Comprehensive tool guide
- docs/ERROR_MESSAGE_IMPROVEMENTS.md - Error message documentation
- docs/TOOL_DESCRIPTION_IMPROVEMENTS.md - AI agent improvements
- PHASE_1.1_IMPLEMENTATION.md - Implementation summary
- RELEASE_NOTES_v1.1.0.md - Release notes

Updated:
- CHANGELOG.md - Add v1.1.0 entry
- ROADMAP.md - Mark Phase 1.1 complete, add Phase 1.5 proposal
- manifest.json - Bump to v1.1.0
- package.json - Bump to v1.1.0, add test scripts
- src/tools/index.ts - Enhanced tool descriptions
- src/tools/note-tools.ts - Use PathUtils and ErrorMessages
- src/tools/vault-tools.ts - Use PathUtils and ErrorMessages
2025-10-16 21:27:23 -04:00

74 lines
1.6 KiB
TypeScript

/**
* Mock Obsidian API for testing
* This provides minimal mocks for the Obsidian types used in tests
*/
export class TFile {
path: string;
basename: string;
extension: string;
constructor(path: string) {
this.path = path;
const parts = path.split('/');
const filename = parts[parts.length - 1];
const dotIndex = filename.lastIndexOf('.');
this.basename = dotIndex > 0 ? filename.substring(0, dotIndex) : filename;
this.extension = dotIndex > 0 ? filename.substring(dotIndex + 1) : '';
}
}
export class TFolder {
path: string;
name: string;
constructor(path: string) {
this.path = path;
const parts = path.split('/');
this.name = parts[parts.length - 1];
}
}
export class TAbstractFile {
path: string;
name: string;
constructor(path: string) {
this.path = path;
const parts = path.split('/');
this.name = parts[parts.length - 1];
}
}
export class Vault {
private files: Map<string, TFile | TFolder> = new Map();
getAbstractFileByPath(path: string): TFile | TFolder | null {
return this.files.get(path) || null;
}
// Helper method for tests to add mock files
_addMockFile(path: string, isFolder = false) {
this.files.set(path, isFolder ? new TFolder(path) : new TFile(path));
}
// Helper method for tests to clear mock files
_clearMockFiles() {
this.files.clear();
}
}
export class App {
vault: Vault;
constructor() {
this.vault = new Vault();
}
}
// Export other commonly used types as empty classes/interfaces
export class Plugin {}
export class Notice {}
export class PluginSettingTab {}
export class Setting {}