Testing

jott has 478 tests covering task management, command handling, UI components, and integrations.

Running Tests

# Run all tests
make test

# Run with coverage report
make test-cov

# Run a specific test file
pytest tests/test_jot.py -v

# Run a specific test class
pytest tests/test_jot.py::TestTaskManager -v

# Run a specific test
pytest tests/test_jot.py::TestTaskManager::test_add_task -v

Test Files

File

Coverage

test_jot.py

Core TaskManager, App, end-to-end flows

test_dispatch.py

Dispatch table and key mapping

test_picker.py

Fuzzy-search picker widget

test_input.py

Keyboard input handling

test_command_handler.py

CommandHandler and its mixins

test_styles.py

Color and style definitions

test_edit_edge_cases.py

Task editing edge cases

test_today_filter.py

Today filter and date-based features

test_fuzzy_search.py

Fuzzy match algorithm

test_highlight.py

Highlight color picker and task ID highlighting

test_gcal_notes.py

Google Calendar notes import

test_subtask_notes.py

Subtask sync, parent/child indicators, collapse/expand

test_terminal_wrap.py

Terminal-width-aware text wrapping

Writing Tests

  • Write tests for all new features

  • Update existing tests when modifying functionality

  • Aim for meaningful coverage (project target: 60%+)

  • Use descriptive test names:

def test_task_manager_prevents_duplicate_ids():
    """Ensure TaskManager generates unique IDs even with collisions."""

Test Isolation for ProjectRegistry

Warning

Always pre-create an empty registry file before constructing ProjectRegistry in tests. Otherwise _auto_discover() loads all real projects from ~/projects/ and tests can write to real .jot.json files.

def test_project_registry(tmp_path):
    reg_file = tmp_path / '.jot-projects.json'
    reg_file.write_text('{}')  # CRITICAL: prevents auto-discovery
    registry = ProjectRegistry(registry_file=str(reg_file))
    # ... test logic ...

This pattern is mandatory for any test that instantiates ProjectRegistry.

Test Requirements for Pull Requests

All pull requests must:

  • Include tests for new functionality

  • Pass all existing tests

  • Maintain or improve code coverage

  • Not introduce test warnings

Bug Fix Workflow

  1. Write a test that reproduces the bug (should fail)

  2. Fix the code

  3. Run the test (should pass)

  4. Only then claim the fix is complete