1+ """Test for issue #72 - notes with wikilinks staying in modified status."""
2+
3+ import pytest
4+ from pathlib import Path
5+
6+ from basic_memory .sync .sync_service import SyncService
7+
8+
9+ async def create_test_file (path : Path , content : str ) -> None :
10+ """Create a test file with given content."""
11+ path .parent .mkdir (parents = True , exist_ok = True )
12+ path .write_text (content )
13+
14+
15+ @pytest .mark .asyncio
16+ async def test_wikilink_modified_status_issue (sync_service : SyncService , test_config ):
17+ """Test that files with wikilinks don't remain in modified status after sync."""
18+ project_dir = test_config .home
19+
20+ # Create a file with a wikilink
21+ content = """---
22+ title: Test Wikilink
23+ type: note
24+ ---
25+ # Test File
26+
27+ This file contains a wikilink to [[another-file]].
28+ """
29+ test_file_path = project_dir / "test_wikilink.md"
30+ await create_test_file (test_file_path , content )
31+
32+ # Initial sync
33+ report1 = await sync_service .sync (test_config .home , show_progress = False )
34+ assert "test_wikilink.md" in report1 .new
35+ assert "test_wikilink.md" not in report1 .modified
36+
37+ # Sync again without changing the file - should not be modified
38+ report2 = await sync_service .sync (test_config .home , show_progress = False )
39+ assert "test_wikilink.md" not in report2 .new
40+ assert "test_wikilink.md" not in report2 .modified
41+
42+ # Create the target file
43+ target_content = """---
44+ title: Another File
45+ type: note
46+ ---
47+ # Another File
48+
49+ This is the target file.
50+ """
51+ target_file_path = project_dir / "another_file.md"
52+ await create_test_file (target_file_path , content )
53+
54+ # Sync again after adding target file
55+ report3 = await sync_service .sync (test_config .home , show_progress = False )
56+ assert "another_file.md" in report3 .new
57+ assert "test_wikilink.md" not in report3 .modified
58+
59+ # Sync one more time - both files should now be stable
60+ report4 = await sync_service .sync (test_config .home , show_progress = False )
61+ assert "test_wikilink.md" not in report4 .modified
62+ assert "another_file.md" not in report4 .modified
0 commit comments