Add test suite for remove.lua note deletion logic
Overview
The remove.lua module (~122 lines) handles note deletion with trash support. This is critical functionality with no test coverage.
Functions Needing Tests
Note Deletion
-
remove(cmdopts)- Delete current note- Test: prompts for confirmation by default
- Test: skips confirmation with bang (!)
- Test: handles unsaved changes with save prompt
- Test: moves to trash when available
- Test: falls back to hard delete when no trash
- Test: closes buffer after deletion
- Test: handles no file in buffer
- Test: handles deletion failure
- Test: reopens buffer if deletion fails
- Test: shows success notification
- Test: shows error notification on failure
-
remove_pick(cmdopts)- Pick and delete note- Test: shows note picker
- Test: displays note titles correctly
- Test: handles note selection
- Test: confirms deletion
- Test: skips confirmation with bang (!)
- Test: handles no notes found
- Test: handles .zk directory not found
- Test: closes correct buffer
- Test: handles user cancellation
Trash Integration Tests
- Test: uses gio when available
- Test: uses trash-put when available
- Test: hard deletes when no trash utility
- Test: handles trash command failures
Buffer Management Tests
- Test: closes buffer for deleted file
- Test: switches to alternate buffer
- Test: handles last buffer deletion
- Test: handles multiple buffers for same file
Edge Cases
- File doesn't exist on disk
- No write permission for file
- File in use by another process
- Symlink to note file
- Read-only buffer
Test File Location
tests/zk-extras/remove_spec.lua
Priority
High - Data loss prevention requires thorough testing
Notes
Consider adding tests for:
- Trash full scenarios
- Permissions errors
- Network filesystem edge cases