@@ -205,6 +205,115 @@ async def test_move_note_invalid_destination_path(client, test_project):
205205 assert "/absolute/path.md" in result or "Invalid" in result or "path" in result
206206
207207
208+ @pytest .mark .asyncio
209+ async def test_move_note_missing_file_extension (client , test_project ):
210+ """Test moving note without file extension in destination path."""
211+ # Create initial note
212+ await write_note .fn (
213+ project = test_project .name ,
214+ title = "ExtensionTest" ,
215+ folder = "source" ,
216+ content = "# Extension Test\n Testing extension validation." ,
217+ )
218+
219+ # Test path without extension
220+ result = await move_note .fn (
221+ project = test_project .name ,
222+ identifier = "source/extension-test" ,
223+ destination_path = "target/renamed-note" ,
224+ )
225+
226+ # Should return error about missing extension
227+ assert isinstance (result , str )
228+ assert "# Move Failed - File Extension Required" in result
229+ assert "must include a file extension" in result
230+ assert ".md" in result
231+ assert "renamed-note.md" in result # Should suggest adding .md
232+
233+ # Test path with empty extension (edge case)
234+ result = await move_note .fn (
235+ project = test_project .name ,
236+ identifier = "source/extension-test" ,
237+ destination_path = "target/renamed-note." ,
238+ )
239+
240+ assert isinstance (result , str )
241+ assert "# Move Failed - File Extension Required" in result
242+ assert "must include a file extension" in result
243+
244+ # Test that note still exists at original location
245+ content = await read_note .fn ("source/extension-test" , project = test_project .name )
246+ assert "# Extension Test" in content
247+ assert "Testing extension validation" in content
248+
249+
250+ @pytest .mark .asyncio
251+ async def test_move_note_file_extension_mismatch (client , test_project ):
252+ """Test that moving note with different extension is blocked."""
253+ # Create initial note with .md extension
254+ await write_note .fn (
255+ project = test_project .name ,
256+ title = "MarkdownNote" ,
257+ folder = "source" ,
258+ content = "# Markdown Note\n This is a markdown file." ,
259+ )
260+
261+ # Try to move with .txt extension
262+ result = await move_note .fn (
263+ project = test_project .name ,
264+ identifier = "source/markdown-note" ,
265+ destination_path = "target/renamed-note.txt" ,
266+ )
267+
268+ # Should return error about extension mismatch
269+ assert isinstance (result , str )
270+ assert "# Move Failed - File Extension Mismatch" in result
271+ assert "does not match the source file extension" in result
272+ assert ".md" in result
273+ assert ".txt" in result
274+ assert "renamed-note.md" in result # Should suggest correct extension
275+
276+ # Test that note still exists at original location with original extension
277+ content = await read_note .fn ("source/markdown-note" , project = test_project .name )
278+ assert "# Markdown Note" in content
279+ assert "This is a markdown file" in content
280+
281+
282+ @pytest .mark .asyncio
283+ async def test_move_note_preserves_file_extension (client , test_project ):
284+ """Test that moving note with matching extension succeeds."""
285+ # Create initial note with .md extension
286+ await write_note .fn (
287+ project = test_project .name ,
288+ title = "PreserveExtension" ,
289+ folder = "source" ,
290+ content = "# Preserve Extension\n Testing that extension is preserved." ,
291+ )
292+
293+ # Move with same .md extension
294+ result = await move_note .fn (
295+ project = test_project .name ,
296+ identifier = "source/preserve-extension" ,
297+ destination_path = "target/preserved-note.md" ,
298+ )
299+
300+ # Should succeed
301+ assert isinstance (result , str )
302+ assert "✅ Note moved successfully" in result
303+
304+ # Verify note exists at new location with same extension
305+ content = await read_note .fn ("target/preserved-note" , project = test_project .name )
306+ assert "# Preserve Extension" in content
307+ assert "Testing that extension is preserved" in content
308+
309+ # Verify old location no longer exists
310+ try :
311+ await read_note .fn ("source/preserve-extension" )
312+ assert False , "Original note should not exist after move"
313+ except Exception :
314+ pass # Expected
315+
316+
208317@pytest .mark .asyncio
209318async def test_move_note_destination_exists (client , test_project ):
210319 """Test moving note to existing destination."""
0 commit comments