Skip to content

Commit 35bb60f

Browse files
committed
feat: add test fixture Neovim configurations with utility scripts
Change-Id: Ifb146a3a6212bfc75f4a9df6e8cdc1d50caece84 Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 76cb6fb commit 35bb60f

30 files changed

+611
-1
lines changed

.envrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ fi
77
nix_direnv_manual_reload
88

99
use flake .
10+
11+
# Add fixtures/bin to PATH for nvim config aliases
12+
PATH_add fixtures/bin

ARCHITECTURE.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ lua/claudecode/
205205

206206
## Testing
207207

208+
### Automated Testing
209+
208210
Three-layer testing strategy using busted:
209211

210212
```lua
@@ -234,6 +236,30 @@ describe("full flow", function()
234236
end)
235237
```
236238

239+
### Integration Testing with Fixtures
240+
241+
Manual testing with real Neovim configurations in the `fixtures/` directory:
242+
243+
```bash
244+
# Test with different file explorers
245+
source fixtures/nvim-aliases.sh
246+
vv nvim-tree # Test with nvim-tree integration
247+
vv oil # Test with oil.nvim integration
248+
vv netrw # Test with built-in netrw
249+
250+
# Each fixture provides:
251+
# - Complete Neovim configuration
252+
# - Plugin dependencies
253+
# - Development keybindings
254+
# - Integration-specific testing scenarios
255+
```
256+
257+
**Fixture Architecture**:
258+
259+
- `fixtures/bin/` - Helper scripts (`vv`, `vve`, `list-configs`)
260+
- `fixtures/[integration]/` - Complete Neovim configs for testing
261+
- `fixtures/nvim-aliases.sh` - Shell aliases for easy testing
262+
237263
## Performance & Security
238264

239265
- **Debounced Updates**: 50ms delay on selection changes

CLAUDE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@ claudecode.nvim - A Neovim plugin that implements the same WebSocket-based MCP p
3737
- `nix develop` - Enter development shell with all dependencies
3838
- `nix fmt` - Format all files using nix formatter
3939

40+
### Integration Testing with Fixtures
41+
42+
The `fixtures/` directory contains test Neovim configurations for verifying plugin integrations:
43+
44+
- `vv <config>` - Start Neovim with a specific fixture configuration
45+
- `vve <config>` - Start Neovim with a fixture config in edit mode
46+
- `list-configs` - Show available fixture configurations
47+
- Source `fixtures/nvim-aliases.sh` to enable these commands
48+
49+
**Available Fixtures**:
50+
- `netrw` - Tests with Neovim's built-in file explorer
51+
- `nvim-tree` - Tests with nvim-tree.lua file explorer
52+
- `oil` - Tests with oil.nvim file explorer
53+
54+
**Usage**: `source fixtures/nvim-aliases.sh && vv oil` starts Neovim with oil.nvim configuration
55+
4056
## Architecture Overview
4157

4258
### Core Components
@@ -342,6 +358,22 @@ rg "0\.1\.0" . # Should only show CHANGELOG.md historical entries
342358
4. **Document Changes**: Update relevant documentation (this file, PROTOCOL.md, etc.)
343359
5. **Commit**: Only commit after successful `make` execution
344360

361+
### Integration Development Guidelines
362+
363+
**Adding New Integrations** (file explorers, terminals, etc.):
364+
365+
1. **Implement Integration**: Add support in relevant modules (e.g., `lua/claudecode/tools/`)
366+
2. **Create Fixture Configuration**: **REQUIRED** - Add a complete Neovim config in `fixtures/[integration-name]/`
367+
3. **Test Integration**: Use fixture to verify functionality with `vv [integration-name]`
368+
4. **Update Documentation**: Add integration to fixtures list and relevant tool documentation
369+
5. **Run Full Test Suite**: Ensure `make` passes with new integration
370+
371+
**Fixture Requirements**:
372+
- Complete Neovim configuration with plugin dependencies
373+
- Include `dev-claudecode.lua` with development keybindings
374+
- Test all relevant claudecode.nvim features with the integration
375+
- Document any integration-specific behaviors or limitations
376+
345377
### MCP Tool Development Guidelines
346378

347379
**Adding New Tools**:

DEVELOPMENT.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Quick guide for contributors to the claudecode.nvim project.
77
```none
88
claudecode.nvim/
99
├── .github/workflows/ # CI workflow definitions
10+
├── fixtures/ # Test Neovim configurations for integration testing
11+
│ ├── bin/ # Helper scripts (vv, vve, list-configs)
12+
│ ├── netrw/ # Neovim config testing with built-in file explorer
13+
│ ├── nvim-tree/ # Neovim config testing with nvim-tree.lua
14+
│ ├── oil/ # Neovim config testing with oil.nvim
15+
│ └── nvim-aliases.sh # Shell aliases for fixture testing
1016
├── lua/claudecode/ # Plugin implementation
1117
│ ├── server/ # WebSocket server implementation
1218
│ ├── tools/ # MCP tool implementations and schema management
@@ -118,7 +124,46 @@ make format
118124
2. Create a feature branch
119125
3. Implement your changes with tests
120126
4. Run the test suite to ensure all tests pass
121-
5. Submit a pull request
127+
5. **For integrations**: Create a fixture configuration for testing
128+
6. Submit a pull request
129+
130+
### Integration Testing with Fixtures
131+
132+
When adding support for new integrations (file explorers, terminals, etc.), you **must** provide a fixture configuration for testing:
133+
134+
**Requirements**:
135+
- Complete Neovim configuration in `fixtures/[integration-name]/`
136+
- Include plugin dependencies and proper setup
137+
- Add `dev-claudecode.lua` with development keybindings
138+
- Test all relevant claudecode.nvim features with the integration
139+
140+
**Usage**:
141+
```bash
142+
# Source fixture aliases
143+
source fixtures/nvim-aliases.sh
144+
145+
# Test with specific integration
146+
vv nvim-tree # Start Neovim with nvim-tree configuration
147+
vv oil # Start Neovim with oil.nvim configuration
148+
vv netrw # Start Neovim with built-in netrw configuration
149+
150+
# List available configurations
151+
list-configs
152+
```
153+
154+
**Example fixture structure** (`fixtures/my-integration/`):
155+
```
156+
my-integration/
157+
├── init.lua # Main Neovim config
158+
├── lua/
159+
│ ├── config/
160+
│ │ └── lazy.lua # Plugin manager setup
161+
│ └── plugins/
162+
│ ├── dev-claudecode.lua # claudecode.nvim development config
163+
│ ├── init.lua # Base plugins
164+
│ └── my-integration.lua # Integration-specific plugin config
165+
└── lazy-lock.json # Plugin lockfile (if using lazy.nvim)
166+
```
122167

123168
## Implementation Details
124169

fixtures/bin/common.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
# common.sh - Shared functions for fixture scripts
4+
5+
# Get available configurations
6+
get_configs() {
7+
local fixtures_dir="$1"
8+
find "$fixtures_dir" -maxdepth 1 -type d \
9+
! -name ".*" \
10+
! -name "fixtures" \
11+
! -name "bin" \
12+
! -path "$fixtures_dir" \
13+
-printf "%f\n" | sort
14+
}
15+
16+
# Validate config exists
17+
validate_config() {
18+
local fixtures_dir="$1"
19+
local config="$2"
20+
21+
if [[ ! -d "$fixtures_dir/$config" ]]; then
22+
echo "Error: Configuration '$config' not found in fixtures/"
23+
echo "Available configs:"
24+
get_configs "$fixtures_dir" | while read -r c; do
25+
echo "$c"
26+
done
27+
return 1
28+
fi
29+
return 0
30+
}
31+
32+
# Interactive config selection
33+
select_config() {
34+
local fixtures_dir="$1"
35+
36+
if command -v fzf >/dev/null 2>&1; then
37+
get_configs "$fixtures_dir" | fzf --prompt="Neovim Configs > " --height=~50% --layout=reverse --border --exit-0
38+
else
39+
echo "Available configs:"
40+
get_configs "$fixtures_dir" | while read -r config; do
41+
echo "$config"
42+
done
43+
echo -n "Select config: "
44+
read -r config
45+
echo "$config"
46+
fi
47+
}
48+

fixtures/bin/list-configs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# list-configs - Show available Neovim configurations
4+
5+
FIXTURES_DIR="$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd)"
6+
7+
# Source common functions
8+
source "$FIXTURES_DIR/bin/common.sh"
9+
10+
echo "Available Neovim test configurations:"
11+
get_configs "$FIXTURES_DIR" | while read -r config; do
12+
if [[ -d "$FIXTURES_DIR/$config" ]]; then
13+
echo "$config"
14+
else
15+
echo "$config (missing)"
16+
fi
17+
done

fixtures/bin/vv

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# vv - Start Neovim with fixture configuration
4+
5+
FIXTURES_DIR="$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd)"
6+
7+
# Source common functions
8+
source "$FIXTURES_DIR/bin/common.sh"
9+
10+
# Main logic
11+
if [[ $# -eq 0 ]]; then
12+
config="$(select_config "$FIXTURES_DIR")"
13+
[[ -z $config ]] && echo "No config selected" && exit 0
14+
else
15+
config="$1"
16+
fi
17+
18+
if ! validate_config "$FIXTURES_DIR" "$config"; then
19+
exit 1
20+
fi
21+
22+
# Set environment to use the config directory as if it were ~/.config/nvim
23+
config_dir="$FIXTURES_DIR/$config"
24+
init_file="$config_dir/init.lua"
25+
26+
if [[ -f "$init_file" ]]; then
27+
echo "Loading config from: $config_dir"
28+
(cd "$FIXTURES_DIR" && NVIM_APPNAME="$config" XDG_CONFIG_HOME="$FIXTURES_DIR" nvim "${@:2}")
29+
else
30+
echo "Error: $init_file not found"
31+
exit 1
32+
fi

fixtures/bin/vve

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# vve - Edit Neovim configuration for a given fixture
4+
5+
FIXTURES_DIR="$(cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" && pwd)"
6+
7+
# Source common functions
8+
source "$FIXTURES_DIR/bin/common.sh"
9+
10+
# Main logic
11+
if [[ $# -eq 0 ]]; then
12+
config="$(select_config "$FIXTURES_DIR")"
13+
[[ -z $config ]] && echo "No config selected" && exit 0
14+
# Open the config directory for editing
15+
config_path="$FIXTURES_DIR/$config"
16+
else
17+
config="$1"
18+
# Validate that config is not empty when provided as argument
19+
if [[ -z "$config" ]]; then
20+
echo "Error: Config name cannot be empty"
21+
echo "Usage: vve [config] [file]"
22+
echo "Available configs:"
23+
get_configs "$FIXTURES_DIR" | while read -r c; do
24+
echo "$c"
25+
done
26+
exit 1
27+
fi
28+
if [[ $# -gt 1 ]]; then
29+
# Specific file provided - open that file in the config directory
30+
config_path="$FIXTURES_DIR/$config/$2"
31+
else
32+
# No specific file - open the config directory
33+
config_path="$FIXTURES_DIR/$config"
34+
fi
35+
fi
36+
37+
if ! validate_config "$FIXTURES_DIR" "$config"; then
38+
exit 1
39+
fi
40+
41+
echo "Editing config: $config_path"
42+
43+
# Use Neovim to edit the configuration files
44+
nvim "$config_path"

fixtures/netrw/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("config.lazy")

fixtures/netrw/lazy-lock.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
3+
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }
4+
}

0 commit comments

Comments
 (0)