# Integration Tests Cleanup Plan

## Objective
Make integration tests evergreen by removing all architectural hints about the software building process while maintaining test quality and coverage.

## Categories of Issues

### 1. Duplicate Test Files (CONSOLIDATE)
Merge duplicate test files into single, comprehensive test files:

#### Field Authorization Tests (auth/)
- **KEEP**: `test_field_authorization.py` (rename to remove version hint)
- **MERGE INTO ABOVE**:
  - `test_field_authorization_simple.py`
  - `test_field_authorization_fixed.py`
  - `test_field_auth_complex.py`
- **ACTION**: Consolidate all field auth tests into one well-organized file

#### Error Array Tests (graphql/mutations/)
- **KEEP**: `test_native_error_arrays.py` (rename to `test_error_arrays.py`)
- **DELETE**: `test_error_arrays.py` (only has placeholders)
- **ACTION**: Remove WP-034 references and phase markers from kept file

#### Decorator Tests (auth/)
- **KEEP**: `test_decorators_extended.py` (rename to `test_decorators.py`)
- **CHECK**: Does `test_decorators.py` exist in auth/? If yes, merge them
- **ACTION**: Consolidate into single decorator test file

#### Validator Tests (auth/)
- **KEEP**: `test_validators_extended.py` (rename to `test_validators.py`)
- **CHECK**: Verify `test_validators.py` isn't being duplicated
- **ACTION**: Consolidate into single validator test file

### 2. File Renames (Remove Process Hints)

#### Files with "_fix" suffix
- `test_json_passthrough_config_fix.py` → `test_json_passthrough.py`
- `test_enum_conversion_fix.py` → `test_enum_conversion.py`
- `test_similar_mutation_names_collision_fix.py` → `test_mutation_name_resolution.py`
- `test_graphql_where_repository_fix.py` → `test_graphql_where_repository.py`
- `test_nested_object_tenant_id_fix.py` → `test_nested_object_tenant_id.py`
- `test_nested_tenant_fix_real_db.py` → `test_nested_tenant_integration.py`
- `test_network_fixes.py` → `test_network_filtering.py`

#### Files with "_regression" suffix
- `test_simple_mutation_regression.py` → `test_simple_mutations.py`
- `test_order_by_list_dict_regression.py` → `test_order_by_list_dict.py`
- `test_performance_regression.py` → `test_performance.py`

#### Files with "_simple/_extended/_complex" suffix
- `test_field_authorization_simple.py` → MERGE
- `test_field_authorization_fixed.py` → MERGE
- `test_field_auth_complex.py` → MERGE
- `test_enum_parameter_simple.py` → `test_enum_parameters.py`
- `test_blog_simple_integration.py` → `test_blog_integration.py`
- `test_db_integration_simple.py` → `test_db_integration.py`
- `test_orderby_complex_scenarios.py` → `test_orderby_scenarios.py`
- `test_where_generator_extended.py` → `test_where_generator.py`
- `test_n_plus_one_detector_extended.py` → `test_n_plus_one_detector.py`
- `test_decorators_extended.py` → MERGE into `test_decorators.py`
- `test_validators_extended.py` → MERGE into `test_validators.py`

### 3. Content Cleanup (Remove Development Markers)

For ALL test files, remove:
- ✅ "WP-XXX" work package references
- ✅ "Phase X" development phase mentions
- ✅ "RED/GREEN/REFACTOR" TDD phase markers
- ✅ "Regression test for..." comments
- ✅ "This test verifies the fix for..." comments
- ✅ "Fixed version" in docstrings
- ✅ Version numbers and dates ("v1.8.0-beta.4 (2025-12-09)")
- ✅ "TODO" comments in test implementations
- ✅ "Before the fix..." / "After the fix..." comments
- ✅ References to "old behavior" vs "new behavior"
- ✅ Historical architectural decision explanations

Replace with:
- ✅ Clear description of WHAT the test validates
- ✅ Expected behavior documentation
- ✅ Domain-focused test names and descriptions

### 4. Incomplete Tests (REMOVE or COMPLETE)

Files with placeholder tests (`assert True`):
- `test_error_arrays.py` - DELETE (duplicate of native_error_arrays)
- Any other incomplete tests - either complete or remove

### 5. Class/Function Naming Cleanup

Remove process hints from test class/function names:
- `TestXxxFix` → `TestXxx`
- `test_xxx_fix` → `test_xxx`
- `test_xxx_regression` → `test_xxx`
- `TestPhaseX` → `TestXxx` (descriptive name)

## Implementation Steps

1. ✅ Identify all duplicate files
2. ✅ Create consolidation plan for duplicates
3. ⏳ Execute file consolidations (merge content)
4. ⏳ Execute file renames
5. ⏳ Clean content (remove process hints)
6. ⏳ Verify all tests still pass
7. ⏳ Commit changes

## Example Transformations

### Before (Bad - shows process)
```python
"""Regression test for mutation name collision fix.

This test verifies that the bug where createItemComponent was incorrectly
requiring item_serial_number (from CreateItemInput) has been fixed.

Before the fix, mutations with similar names would interfere.
After the fix, each mutation has its own input validation.
"""

class TestMutationNameCollisionFix:
    def test_resolver_names_use_function_names(self):
        """Test that resolver names are based on function name (fixed in v1.2)."""
```

### After (Good - evergreen)
```python
"""Tests for mutation name resolution and parameter binding.

Validates that mutations with similar names (like create_item and
create_item_component) maintain independent parameter validation
and don't interfere with each other's input types.
"""

class TestMutationNameResolution:
    def test_resolver_names_match_function_names(self):
        """Test that resolver names correctly correspond to their function names."""
```

## Files Requiring Special Attention

1. **test_native_error_arrays.py** - Heavy WP-034 and phase references
2. **test_fastapi_jsonb_integration.py** - Multiple phase references
3. **test_graphql_cascade.py** - Phase 3 validation references
4. **Meta tests** - test_phase0_validation.py needs renaming

## QA Checklist

After cleanup:
- [ ] No file names contain: _fix, _regression, _simple, _extended, _fixed, _complex
- [ ] No content contains: WP-, Phase, RED/GREEN, "regression test", "fix for"
- [ ] No duplicate test files exist
- [ ] No placeholder/incomplete tests exist
- [ ] All tests have clear, domain-focused descriptions
- [ ] All tests pass
- [ ] Test coverage is maintained or improved
