Skip to content

Refactor: Extract autocomplete filter logic to service class - #356

Merged
malibio merged 2 commits into
mainfrom
feature/issue-204-extract-autocomplete-filter-logic
Oct 30, 2025
Merged

malibio merged 2 commits into
mainfrom
feature/issue-204-extract-autocomplete-filter-logic

Conversation

@malibio

@malibio malibio commented Oct 30, 2025

Copy link
Copy Markdown
Collaborator

Closes #204

malibio and others added 2 commits October 30, 2025 15:13
Extracted @mention autocomplete filter logic from base-node.svelte into
a dedicated NodeSearchService class for better maintainability and
testability.

Changes:
- Created NodeSearchService with filterMentionableNodes() method
- Implemented comprehensive unit tests (18 test cases)
- Updated base-node.svelte to use the new service
- All filtering rules preserved and tested:
  1. Exclude date nodes (accessible via date shortcuts)
  2. Match query in title/content (case-insensitive)
  3. Include ALL non-text nodes regardless of hierarchy
  4. Include ONLY container text nodes (top-level)

Benefits:
- ✅ Unit testable - 18 comprehensive test cases
- ✅ Centralized business logic - Single source of truth
- ✅ Easy to extend - Ready for Issue #201 date shortcuts
- ✅ Self-documenting - Clear rules with explicit methods
- ✅ Reusable - Other components can use the same filtering

Related: #199 (introduced @mention system), #201 (date shortcuts)
Closes #204

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

Co-Authored-By: Claude <[email protected]>
Updated test comment at line 142 to accurately reflect the test behavior.
The comment previously stated "Whitespace-only query matches everything"
but the assertion correctly expects 0 results.

Changed to: "Whitespace-only query returns no results (whitespace doesn't
naturally occur in content)"

Addresses code review feedback (Nit 1) from #204 review.

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

Co-Authored-By: Claude <[email protected]>
@malibio
malibio merged commit 84847a6 into main Oct 30, 2025
@malibio
malibio deleted the feature/issue-204-extract-autocomplete-filter-logic branch October 30, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Extract autocomplete filter logic to service class

1 participant