Add integration tests for complete user workflows
Problem
While integration_spec.lua has some good tests, the test suite lacks comprehensive end-to-end workflow testing. Most tests are unit tests that don't verify features work together correctly.
Current Integration Test Coverage
What EXISTS (Good) ✓
- Template discovery and expansion (lines 68-104)
- Snippet insertion with variables (lines 120-170)
- Note deletion workflows (lines 173-238)
- Plugin setup verification (lines 241-292)
- Template → Note workflow (lines 294-329)
What's MISSING
Critical Workflow Tests Needed
1. Multi-Step User Journeys
New note creation journey:
describe("new note from template complete workflow", function()
it("creates, edits, snippets, and publishes note", function()
-- User picks template
-- Creates note with title
-- Opens note in buffer
-- Inserts snippet
-- Modifies content
-- Saves note
-- Verify all steps succeeded
-- Verify note is valid and findable
Note organization journey:
it("creates, tags, finds, and deletes note", function()
-- Create note with template
// Add tags/metadata
-- Find note via picker
// Modify note
// Delete note
// Verify complete cleanup
2. Error Recovery Workflows
Missing tests:
-
Template selection → Creation fails → Retry → Success -
Snippet insertion → Undo → Redo → Save -
Delete note → Confirm → Deletion fails → File still exists → Retry -
Create note → Power loss simulation → Recovery → Complete creation
Example needed:
describe("workflow error recovery", function()
it("recovers from interrupted note creation", function()
-- Start template creation
-- Simulate interruption (mock error)
// Verify no partial state left
// Retry and complete
// Verify success
3. Cross-Feature Integration
Template + Snippet combinations:
it("uses snippet in template during creation", function()
-- Template references snippet
// Create note from template
// Verify snippet expanded in template
Picker + Multiple features:
it("template picker and snippet picker share configuration", function()
-- Configure picker (telescope/fzf)
// Verify both template and snippet pickers use same UI
4. State Consistency Tests
Multi-buffer consistency:
describe("multi-buffer workflows", function()
it("maintains consistency when same note open in multiple windows", function()
// Open note in buffer 1
// Open same note in buffer 2
// Insert snippet in buffer 1
// Verify buffer 2 updates
// Delete note
// Verify both buffers closed
it("handles concurrent snippet insertions", function()
// Open two different notes
// Insert snippets in both
// Verify no interference
// Verify both save correctly
5. Configuration Change Workflows
Missing tests:
it("handles picker change mid-session", function()
-- Use telescope picker
// Change config to fzf
// Use template picker
// Verify fzf is used
it("handles template directory change", function()
-- Use templates from dir A
// Change config to dir B
// Verify new templates appear
6. Real-World Scenario Tests
Daily note workflow:
describe("daily note workflow", function()
it("creates daily note with date template", function()
// Pick daily template
// Create note with today's date
// Insert meeting snippet
// Insert code snippet
// Tag as work
// Save and close
// Find via date search
// Verify all content correct
Knowledge base workflow:
it("builds interconnected knowledge base", function()
// Create hub note
// Create 5 linked notes
// Use templates for each
// Verify links work
// Delete hub note
// Verify orphan detection
7. Performance Under Load
Missing tests:
describe("performance with realistic data", function()
it("handles 1000 note notebook efficiently", function()
// Create 1000 notes with templates
// Measure picker response time
// Delete notes
// Verify cleanup time reasonable
it("handles complex templates without lag", function()
// Template with 100+ variables
// Multiple ENV lookups
// Multiple input prompts
// Verify expansion < 1 second
Test Organization
Organize new tests by user journey, not by code:
integration_spec.lua
├── Content Creation Journeys
│ ├── New note from template
│ ├── Quick note with snippet
│ └── Daily note routine
├── Content Management Journeys
│ ├── Find, edit, save cycle
│ ├── Note organization (tags, links)
│ └── Bulk operations
├── Error Recovery Journeys
│ ├── Interrupted operations
│ ├── Filesystem errors
│ └── Invalid state recovery
└── Performance Journeys
├── Large notebook operations
└── Complex template expansion
Success Criteria
-
All major user workflows have end-to-end tests -
Error recovery is tested for each workflow -
Multi-step journeys are tested, not just single operations -
State consistency is verified across features -
Performance under realistic load is tested -
Configuration changes mid-workflow are handled -
Tests reflect actual user behavior patterns
Implementation Plan
- Phase 1: Add 5 most common user workflows
- Phase 2: Add error recovery for each workflow
- Phase 3: Add performance tests
- Phase 4: Add cross-feature integration tests
References
-
tests/zk-extras/integration_spec.lua(existing) - User documentation for workflow examples
- Issue reports for real-world usage patterns