This commit implements 5 major JavaScript features that were lost during refactoring, using systematic Test-Driven Development methodology: **Core Features Implemented:** - Advanced EditState enum with pending changes preservation - Keyboard shortcuts (Ctrl+Enter accept, Escape cancel) - Section splitting with dynamic heading detection - Real-time status tracking with 2-second periodic updates - Intelligent filename generation with 4-method fallback system **Technical Improvements:** - Comprehensive TDD test suites for all functionality - Professional status panel with color-coded indicators - Smart filename generation (options→title→URL→heading→timestamp) - Event-driven architecture with custom event emission - State preservation during editing transitions **Files Added:** - markitect/static/editor.js - Complete JavaScript functionality - test_*.js - Comprehensive TDD test suites - LOST_FUNCTIONALITY_ANALYSIS.md - Detailed feature comparison - TEST_ENVIRONMENT.md - TDD setup documentation **Updated Documentation:** - TODO.md - Status tracking and progress documentation All features are fully tested and integrated into the existing codebase. The TDD approach proved highly effective for systematic functionality recovery. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
82 lines
2.9 KiB
JavaScript
Executable File
82 lines
2.9 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
/**
|
|
* TDD Tests for getAllSections Method Recovery
|
|
*/
|
|
|
|
const { TestRunner } = require('./test_runner.js');
|
|
const runner = new TestRunner();
|
|
|
|
// Test getAllSections functionality
|
|
runner.describe('SectionManager getAllSections method', () => {
|
|
|
|
runner.it('should have getAllSections method in SectionManager', async () => {
|
|
// Load editor
|
|
delete require.cache[require.resolve('/home/worsch/markitect_project/markitect/static/editor.js')];
|
|
require('/home/worsch/markitect_project/markitect/static/editor.js');
|
|
|
|
if (global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
const hasGetAllSections = typeof manager.getAllSections === 'function';
|
|
runner.expect(hasGetAllSections).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
runner.it('should return array of all sections', async () => {
|
|
if (global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
|
|
// Create some test sections
|
|
const sections = manager.createSectionsFromMarkdown('# Test\n\nContent\n\n## Another\n\nMore content');
|
|
|
|
// getAllSections should return an array
|
|
const allSections = manager.getAllSections();
|
|
runner.expect(Array.isArray(allSections)).toBeTruthy();
|
|
runner.expect(allSections.length).toBe(sections.length);
|
|
}
|
|
});
|
|
|
|
runner.it('should return all sections from the sections Map', async () => {
|
|
if (global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
|
|
// Create sections
|
|
manager.createSectionsFromMarkdown('# Test\n\nContent');
|
|
|
|
const allSections = manager.getAllSections();
|
|
const mapSize = manager.sections.size;
|
|
|
|
runner.expect(allSections.length).toBe(mapSize);
|
|
}
|
|
});
|
|
|
|
runner.it('should return sections with proper properties', async () => {
|
|
if (global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
|
|
// Create sections
|
|
manager.createSectionsFromMarkdown('# Test\n\nContent');
|
|
|
|
const allSections = manager.getAllSections();
|
|
|
|
if (allSections.length > 0) {
|
|
const firstSection = allSections[0];
|
|
runner.expect(firstSection.id).toBeTruthy();
|
|
runner.expect(firstSection.currentMarkdown).toBeTruthy();
|
|
runner.expect(typeof firstSection.hasChanges).toBe('function');
|
|
runner.expect(typeof firstSection.isEditing).toBe('function');
|
|
runner.expect(typeof firstSection.getStatus).toBe('function');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// Run the tests
|
|
if (require.main === module) {
|
|
console.log('📊 Running TDD Tests for getAllSections Method Recovery');
|
|
runner.run().then(() => {
|
|
console.log('✅ Test run complete - now implement getAllSections!');
|
|
});
|
|
}
|
|
|
|
module.exports = runner; |