Matrix-Enhanced Test-Driven Development Command
Executes matrix-driven TDD workflow with comprehensive combinatorial test coverage.
/plugin marketplace add jleechanorg/claude-commands/plugin install jleechanorg-claude-commands@jleechanorg/claude-commandsWhen this command is invoked, YOU (Claude) must execute these steps immediately: This is NOT documentation - these are COMMANDS to execute right now. Use TodoWrite to track progress through multi-phase workflows.
Action Steps:
Action Steps: BEFORE writing any tests, create comprehensive test matrix:
Action Steps:
| Empty Character | Custom Character | Special Chars | Unicode | Long Name | |
|---|---|---|---|---|---|
| Dragon Knight + Empty | [1,1,1] | [1,2,1] | [1,3,1] | [1,4,1] | [1,5,1] |
| Dragon Knight + Short | [1,1,2] | [1,2,2] | [1,3,2] | [1,4,2] | [1,5,2] |
| Custom + Empty | [2,1,1] | [2,2,1] | [2,3,1] | [2,4,1] | [2,5,1] |
| Custom + Short | [2,1,2] | [2,2,2] | [2,3,2] | [2,4,2] | [2,5,2] |
Action Steps: Implementation:
Matrix Test Structure:
// Complete Matrix-Driven Test Structure
describe('Campaign Creation - Full Field Matrix', () => {
// Matrix 1: Core Field Interactions (50 test combinations)
test.each([
// Dragon Knight combinations
['dragon-knight', '', '', 'Knight of Assiah', 'pre-filled setting'],
['dragon-knight', 'Custom Name', '', 'Knight of Assiah', 'pre-filled setting'],
['dragon-knight', '!@#$%', '', 'Knight of Assiah', 'pre-filled setting'],
['dragon-knight', '้พ้จๅฃซ', '', 'Knight of Assiah', 'pre-filled setting'],
['dragon-knight', 'Very Long Character Name That Tests UI Boundaries', '', 'Knight of Assiah', 'pre-filled setting'],
// Custom Campaign combinations
['custom', '', '', 'Your character name', 'empty setting'],
['custom', 'Custom Name', '', 'Your character name', 'empty setting'],
['custom', '!@#$%', '', 'Your character name', 'empty setting'],
['custom', '้พ้จๅฃซ', 'Custom setting', 'Your character name', 'custom setting'],
['custom', 'Long Name', 'Very long custom setting text...', 'Your character name', 'custom setting'],
])('Matrix [%s,%s,%s] โ expects %s placeholder and %s',
(campaignType, character, setting, expectedPlaceholder, expectedSetting) => {
// RED: Test fails initially
render(<CampaignCreation />);
// Select campaign type
fireEvent.click(screen.getByText(campaignType === 'dragon-knight' ? 'Dragon Knight' : 'Custom'));
// Verify dynamic placeholder
const characterInput = screen.getByLabelText(/character/i);
expect(characterInput).toHaveAttribute('placeholder', expectedPlaceholder);
// Test character input
fireEvent.change(characterInput, { target: { value: character } });
expect(characterInput.value).toBe(character);
// Verify setting behavior
const settingInput = screen.getByLabelText(/setting/i);
if (expectedSetting === 'pre-filled setting') {
expect(settingInput.value).toContain('World of Assiah');
} else {
expect(settingInput.value).toBe('');
}
});
// Matrix 2: AI Personality Combinations (16 test combinations)
test.each([
['dragon-knight', true, true, true, 'all personalities enabled'],
['dragon-knight', true, true, false, 'default + mechanical only'],
['dragon-knight', false, false, false, 'no AI personalities'],
['custom', true, true, true, 'all personalities with custom'],
['custom', false, false, false, 'minimal custom setup'],
])('AI Matrix [%s] with [%s,%s,%s] โ %s',
(campaignType, defaultWorld, mechanical, companions, expectedBehavior) => {
// RED: Test AI personality matrix combinations
render(<CampaignCreation />);
// Navigate to AI step
fireEvent.click(screen.getByText('Next'));
// Set AI personality checkboxes
const defaultCheckbox = screen.getByLabelText(/default world/i);
const mechanicalCheckbox = screen.getByLabelText(/mechanical/i);
const companionsCheckbox = screen.getByLabelText(/companions/i);
fireEvent.click(defaultCheckbox);
fireEvent.click(mechanicalCheckbox);
fireEvent.click(companionsCheckbox);
// Verify checkbox states match matrix cell
expect(defaultCheckbox.checked).toBe(defaultWorld);
expect(mechanicalCheckbox.checked).toBe(mechanical);
expect(companionsCheckbox.checked).toBe(companions);
});
// Matrix 3: State Transition Testing (8 test combinations)
test.each([
['dragon-knight', 'custom', 'Knight of Assiah', 'Your character name'],
['custom', 'dragon-knight', 'Your character name', 'Knight of Assiah'],
])('State Transition [%s โ %s] changes placeholder [%s โ %s]',
(fromType, toType, fromPlaceholder, toPlaceholder) => {
// RED: Test dynamic placeholder switching
render(<CampaignCreation />);
// Start with fromType
fireEvent.click(screen.getByText(fromType === 'dragon-knight' ? 'Dragon Knight' : 'Custom'));
let characterInput = screen.getByLabelText(/character/i);
expect(characterInput).toHaveAttribute('placeholder', fromPlaceholder);
// Switch to toType
fireEvent.click(screen.getByText(toType === 'dragon-knight' ? 'Dragon Knight' : 'Custom'));
characterInput = screen.getByLabelText(/character/i);
expect(characterInput).toHaveAttribute('placeholder', toPlaceholder);
});
});
Action Steps: Implementation:
Action Steps: Implementation:
Purpose: Test-driven development workflow with comprehensive matrix testing integration
Action: Red โ Green โ Refactor workflow enhanced with systematic path coverage
Usage: /tdd or /rg
## Campaign Creation Test Matrix - All Field Combinations
### **Matrix 2: AI Personality Testing (All Checkbox Combinations)**
| Campaign Type | Default World | Mechanical | Companions | Expected Behavior |
|---------------|---------------|------------|-------------|-------------------|
| Dragon Knight | โ
| โ
| โ
| All personalities active |
| Dragon Knight | โ
| โ
| โ | Default + Mechanical only |
| Dragon Knight | โ | โ | โ | No AI personalities |
| Custom | โ
| โ
| โ
| All personalities with custom |
| Custom | โ | โ | โ | Minimal custom setup |
### **Matrix 3: State Transition Testing**
| From State | To State | Expected Behavior |
|------------|----------|-------------------|
| Dragon Knight โ Custom | Placeholder changes, data preserved |
| Custom โ Dragon Knight | Auto-fills setting, maintains character |
| Collapsed โ Expanded | Shows textarea, preserves state |
| Expanded โ Collapsed | Hides textarea, preserves text |
**Total Matrix Tests**: 86 systematic test cases covering all field interactions
# Component analysis for matrix generation
rg "useState|props|interface" --type tsx -A 3 -B 1
rg "onClick|onChange|onSubmit" --type tsx -A 2
# Generate test matrix from component analysis
tests/
โโโ matrix_tests/
โ โโโ [component]_matrix.test.tsx # Full matrix test suite
โ โโโ [component]_paths.md # Matrix documentation
โ โโโ [component]_coverage.json # Coverage tracking
โโโ unit_tests/ # Traditional unit tests
โโโ integration_tests/ # Cross-component tests
## Complete Matrix Coverage Report
โ
**Core Field Matrix**: 50/50 tests
- Campaign Type ร Character ร Setting: All combinations covered
- Dynamic placeholder switching: Verified
- State preservation during transitions: Tested
โ
**AI Personality Matrix**: 16/16 tests
- All checkbox combinations: Covered
- Visual highlighting verification: Tested
- Campaign type compatibility: Verified
โ
**Title Variations Matrix**: 12/12 tests
- Empty, short, long, special chars, Unicode: Covered
- UI layout handling: Verified
- Text truncation behavior: Tested
โ
**State Transition Matrix**: 8/8 tests
- Type switching with data: Covered
- Description expand/collapse: Tested
- Form state persistence: Verified
**Total Matrix Coverage**: 86/86 tests
โ **Previously Failing Patterns**:
- โ
FIXED: Custom Campaign + Empty Character (Cell [2,1,1])
- โ
FIXED: Hardcoded "Ser Arion" removed
- โ
FIXED: Dynamic placeholder based on campaign type
โ ๏ธ **Edge Cases Identified**:
- Unicode character display in all browsers
- Very long text input handling and truncation
- Special character sanitization and XSS prevention
- Rapid state switching and race conditions
RULE 1: Cannot proceed to GREEN phase without complete matrix in RED RULE 2: Each matrix cell must have corresponding test case RULE 3: All matrix tests must FAIL before implementation begins RULE 4: REFACTOR phase must maintain 100% matrix test coverage RULE 5: Matrix coverage report required before completion