Skip to content

Commit 8c35bd9

Browse files
committed
phase1(refactor): reorganize test directory structure
- Create proper subdirectories: unit/app/, unit/components/, unit/utils/, unit/validation/ - Move 6 App.js tests from __tests__/ to unit/app/ - Move 3 state tests from unit/state/ to unit/app/state/ - Fix all import paths (../ → ../../../) to match new structure - Fix require() statements in tests Benefits: - Tests now match documented plan structure - Clear separation by type (app, components, utils, validation) - Easier navigation and maintenance - Proper foundation for Week 4 component tests Test results: 376/377 passing (1 flaky performance test acceptable)
1 parent 095e46f commit 8c35bd9

10 files changed

+70
-18
lines changed

docs/SCRATCHPAD.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,55 @@ d40f47f phase1(docs): mark validation system tests complete
354354
- Discovered 1 new bug during testing (optogenetic_stimulation_software)
355355
- State management tests confirmed excellent performance - no optimization needed
356356
- Week 4 will focus on component and utility tests
357+
358+
---
359+
360+
## Test Directory Reorganization - 2025-10-23
361+
362+
### Issue Identified
363+
364+
Test files were not organized according to the plan structure. Files were in root of `__tests__/` instead of proper subdirectories.
365+
366+
### Reorganization Completed
367+
368+
**New Structure:**
369+
```
370+
src/__tests__/
371+
├── baselines/ ✅ (unchanged)
372+
├── fixtures/ ✅ (unchanged)
373+
├── helpers/ ✅ (unchanged)
374+
├── integration/ ✅ (unchanged)
375+
└── unit/
376+
├── app/ ✅ NEW - App.js tests moved here
377+
│ ├── App-array-management.test.jsx
378+
│ ├── App-form-updates.test.jsx
379+
│ ├── App-item-selection.test.jsx
380+
│ ├── App-onBlur-transformations.test.jsx
381+
│ ├── App-state-initialization.test.jsx
382+
│ ├── App-validation-system.test.jsx
383+
│ └── state/ ✅ Moved from unit/state/
384+
│ ├── deep-cloning.test.js
385+
│ ├── immutability.test.js
386+
│ └── large-datasets.test.js
387+
├── components/ ✅ NEW - Ready for component tests
388+
├── utils/ ✅ NEW - Ready for utility tests
389+
└── validation/ ✅ NEW - Ready for validation tests
390+
```
391+
392+
**Actions Taken:**
393+
1. Created missing subdirectories: `unit/app/`, `unit/components/`, `unit/utils/`, `unit/validation/`
394+
2. Moved 6 App.js test files to `unit/app/`
395+
3. Moved 3 state test files to `unit/app/state/`
396+
4. Fixed all import paths (changed `../App``../../../App`, etc.)
397+
5. Fixed require() statements in tests
398+
399+
**Test Results:**
400+
- 376/377 tests passing ✅
401+
- 1 flaky performance test (timing variance in CI - acceptable)
402+
- All reorganized tests working correctly
403+
404+
**Benefits:**
405+
- Tests now match documented structure from refactoring plan
406+
- Clear separation: app tests, component tests, utils tests, validation tests
407+
- Easier to navigate and find relevant tests
408+
- Proper foundation for Week 4 component tests

src/__tests__/App-array-management.test.jsx renamed to src/__tests__/unit/app/App-array-management.test.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
1313
import { describe, it, expect, beforeEach, vi } from 'vitest';
14-
import { App } from '../App';
15-
import { defaultYMLValues } from '../valueList';
14+
import { App } from '../../../App';
15+
import { defaultYMLValues } from '../../../valueList';
1616

1717
describe('App Array Item Management', () => {
1818
// Mock window.confirm for remove operations
@@ -105,31 +105,31 @@ describe('App Array Item Management', () => {
105105

106106
describe('ID Auto-increment Logic', () => {
107107
it('should verify arrayDefaultValues structure for cameras', () => {
108-
const { arrayDefaultValues } = require('../valueList');
108+
const { arrayDefaultValues } = require('../../../valueList');
109109

110110
// Cameras should have id field
111111
expect(arrayDefaultValues.cameras).toHaveProperty('id');
112112
expect(arrayDefaultValues.cameras.id).toBe(0);
113113
});
114114

115115
it('should verify arrayDefaultValues structure for tasks', () => {
116-
const { arrayDefaultValues } = require('../valueList');
116+
const { arrayDefaultValues } = require('../../../valueList');
117117

118118
expect(arrayDefaultValues.tasks).toHaveProperty('task_name');
119119
expect(arrayDefaultValues.tasks).toHaveProperty('task_description');
120120
expect(arrayDefaultValues.tasks).toHaveProperty('task_epochs');
121121
});
122122

123123
it('should verify arrayDefaultValues structure for electrode_groups', () => {
124-
const { arrayDefaultValues } = require('../valueList');
124+
const { arrayDefaultValues } = require('../../../valueList');
125125

126126
expect(arrayDefaultValues.electrode_groups).toHaveProperty('id');
127127
expect(arrayDefaultValues.electrode_groups).toHaveProperty('location');
128128
expect(arrayDefaultValues.electrode_groups).toHaveProperty('device_type');
129129
});
130130

131131
it('should verify arrayDefaultValues structure for data_acq_device', () => {
132-
const { arrayDefaultValues } = require('../valueList');
132+
const { arrayDefaultValues } = require('../../../valueList');
133133

134134
expect(arrayDefaultValues.data_acq_device).toHaveProperty('name');
135135
expect(arrayDefaultValues.data_acq_device).toHaveProperty('system');
@@ -138,7 +138,7 @@ describe('App Array Item Management', () => {
138138

139139
describe('Array Default Values Completeness', () => {
140140
it('should have default values for all major arrays', () => {
141-
const { arrayDefaultValues } = require('../valueList');
141+
const { arrayDefaultValues } = require('../../../valueList');
142142

143143
// Check all major arrays have defaults
144144
expect(arrayDefaultValues).toHaveProperty('cameras');
@@ -155,7 +155,7 @@ describe('App Array Item Management', () => {
155155
});
156156

157157
it('should have ntrode_electrode_group_channel_map defaults', () => {
158-
const { arrayDefaultValues } = require('../valueList');
158+
const { arrayDefaultValues } = require('../../../valueList');
159159

160160
expect(arrayDefaultValues).toHaveProperty('ntrode_electrode_group_channel_map');
161161
expect(arrayDefaultValues.ntrode_electrode_group_channel_map).toHaveProperty('electrode_group_id');

src/__tests__/App-form-updates.test.jsx renamed to src/__tests__/unit/app/App-form-updates.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import { render, screen, fireEvent, within } from '@testing-library/react';
1111
import { describe, it, expect, beforeEach } from 'vitest';
12-
import { App } from '../App';
13-
import { defaultYMLValues } from '../valueList';
12+
import { App } from '../../../App';
13+
import { defaultYMLValues } from '../../../valueList';
1414

1515
describe('App Form Data Updates', () => {
1616
describe('updateFormData - Simple Key-Value Updates', () => {

src/__tests__/App-item-selection.test.jsx renamed to src/__tests__/unit/app/App-item-selection.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import { render, fireEvent } from '@testing-library/react';
1111
import { describe, it, expect } from 'vitest';
12-
import { App } from '../App';
13-
import { defaultYMLValues } from '../valueList';
12+
import { App } from '../../../App';
13+
import { defaultYMLValues } from '../../../valueList';
1414

1515
describe('App Item Selection Handlers', () => {
1616
describe('itemSelected - Simple Selection', () => {

src/__tests__/App-onBlur-transformations.test.jsx renamed to src/__tests__/unit/app/App-onBlur-transformations.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
import { render, fireEvent } from '@testing-library/react';
1515
import { describe, it, expect } from 'vitest';
16-
import { App } from '../App';
16+
import { App } from '../../../App';
1717
import {
1818
commaSeparatedStringToNumber,
1919
formatCommaSeparatedString,
2020
isInteger,
2121
isNumeric
22-
} from '../utils';
22+
} from '../../../utils';
2323

2424
describe('App onBlur Transformations', () => {
2525
describe('Utility Functions - commaSeparatedStringToNumber', () => {

src/__tests__/App-state-initialization.test.jsx renamed to src/__tests__/unit/app/App-state-initialization.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import { render, screen } from '@testing-library/react';
1111
import { describe, it, expect } from 'vitest';
12-
import { App } from '../App';
13-
import { defaultYMLValues, emptyFormData } from '../valueList';
12+
import { App } from '../../../App';
13+
import { defaultYMLValues, emptyFormData } from '../../../valueList';
1414

1515
describe('App State Initialization', () => {
1616
describe('Default State Values', () => {

src/__tests__/App-validation-system.test.jsx renamed to src/__tests__/unit/app/App-validation-system.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616

1717
import { describe, it, expect } from 'vitest';
18-
import { jsonschemaValidation, rulesValidation } from '../App';
19-
import { createTestYaml } from './helpers/test-utils';
18+
import { jsonschemaValidation, rulesValidation } from '../../../App';
19+
import { createTestYaml } from '../../helpers/test-utils';
2020

2121
describe('App Validation System', () => {
2222
describe('jsonschemaValidation()', () => {

0 commit comments

Comments
 (0)