Complete cleanup and modernization of JavaScript testing infrastructure with comprehensive automated test coverage and improved output formatting. JavaScript Development Files Cleanup: - Moved 53 manual development/debugging test files to history/javascript-dev-tests/ - Added comprehensive README documenting archived files and their purposes - Cleaned main project directory of development artifacts New Automated Test Suite (68 tests): - keyboard-shortcuts.test.js: Tests Ctrl+Enter, Escape, accessibility features (8 tests) - section-splitting.test.js: Tests heading detection, content parsing, ID generation (14 tests) - image-editing.test.js: Tests dialog positioning, alt text, reset functionality (19 tests) - button-events.test.js: Tests click handling, state management, event delegation (21 tests) Integration Test Fixes: - Fixed 13 failing integration tests by properly mocking component dependencies - Updated tests to match actual component APIs instead of assumed interfaces - Improved error handling and test reliability Enhanced Test Output Formatting: - Updated testdrive-jsui-test-all target to show clear test count summaries - Separated JavaScript (68 tests) and Python (11 tests) results distinctly - Added combined summary showing total coverage (79 tests) - Improved error handling and visual formatting Main Makefile Improvements: - Fixed default target issue by adding .DEFAULT_GOAL := help - Restored proper make help behavior when called without arguments Key Achievements: - Replaced 53 manual test files with 68 automated tests - Achieved 100% test pass rate (79/79 tests passing) - Enhanced CI/CD integration with clear test reporting - Preserved all critical UI functionality in automated test coverage - Improved developer experience with clearer test output Testing Status: - ✅ 68 JavaScript tests (Jest) - Core UI functionality - ✅ 11 Python tests (pytest) - Integration bridge testing - ✅ 100% automated test coverage for critical functionality - ✅ Clean, maintainable test codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
158 lines
6.0 KiB
JavaScript
158 lines
6.0 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* TDD Tests for Real-time Status Tracking Recovery
|
|
*/
|
|
|
|
const { TestRunner } = require('./test_runner.js');
|
|
const runner = new TestRunner();
|
|
|
|
// Test real-time status tracking functionality
|
|
runner.describe('Real-time Status Tracking System', () => {
|
|
|
|
runner.it('should have updateGlobalStatus 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 hasUpdateGlobalStatus = typeof manager.updateGlobalStatus === 'function';
|
|
runner.expect(hasUpdateGlobalStatus).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
runner.it('should have startStatusTracking method', async () => {
|
|
if (global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
const hasStartStatusTracking = typeof manager.startStatusTracking === 'function';
|
|
runner.expect(hasStartStatusTracking).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
runner.it('should have stopStatusTracking method', async () => {
|
|
if (global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
const hasStopStatusTracking = typeof manager.stopStatusTracking === 'function';
|
|
runner.expect(hasStopStatusTracking).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
runner.it('should track status changes when sections are modified', async () => {
|
|
if (global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
|
|
// Create a test section
|
|
manager.createSectionsFromMarkdown('# Test\n\nContent');
|
|
const sections = manager.getAllSections();
|
|
|
|
if (sections.length > 0) {
|
|
const sectionId = sections[0].id;
|
|
|
|
// Start editing
|
|
manager.startEditing(sectionId);
|
|
manager.updateContent(sectionId, '# Modified\n\nNew content');
|
|
|
|
// Status should reflect changes
|
|
const status = manager.getGlobalStatus();
|
|
runner.expect(status.hasModifications).toBeTruthy();
|
|
runner.expect(status.editingSections).toContain(sectionId);
|
|
}
|
|
}
|
|
});
|
|
|
|
runner.it('should provide global status information', async () => {
|
|
if (global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
|
|
const status = manager.getGlobalStatus();
|
|
runner.expect(status).toBeTruthy();
|
|
runner.expect(typeof status.totalSections).toBe('number');
|
|
runner.expect(typeof status.hasModifications).toBe('boolean');
|
|
runner.expect(Array.isArray(status.editingSections)).toBeTruthy();
|
|
runner.expect(typeof status.lastUpdate).toBe('string');
|
|
}
|
|
});
|
|
|
|
runner.it('should emit status-updated events periodically', async () => {
|
|
if (global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
|
|
let eventEmitted = false;
|
|
manager.on('status-updated', (status) => {
|
|
eventEmitted = true;
|
|
runner.expect(status.totalSections).toBeDefined();
|
|
runner.expect(status.lastUpdate).toBeDefined();
|
|
});
|
|
|
|
// Start status tracking
|
|
if (typeof manager.startStatusTracking === 'function') {
|
|
manager.startStatusTracking();
|
|
|
|
// Trigger an update
|
|
if (typeof manager.updateGlobalStatus === 'function') {
|
|
manager.updateGlobalStatus();
|
|
runner.expect(eventEmitted).toBeTruthy();
|
|
}
|
|
|
|
// Stop tracking
|
|
if (typeof manager.stopStatusTracking === 'function') {
|
|
manager.stopStatusTracking();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
runner.it('should have visual status indicators in DOMRenderer', async () => {
|
|
if (global.DOMRenderer) {
|
|
const manager = new global.SectionManager();
|
|
const renderer = new global.DOMRenderer(manager, document.createElement('div'));
|
|
|
|
const hasUpdateStatusDisplay = typeof renderer.updateStatusDisplay === 'function';
|
|
runner.expect(hasUpdateStatusDisplay).toBeTruthy();
|
|
|
|
const hasCreateStatusPanel = typeof renderer.createStatusPanel === 'function';
|
|
runner.expect(hasCreateStatusPanel).toBeTruthy();
|
|
}
|
|
});
|
|
|
|
runner.it('should display different status states (Ready, Modified, Editing)', async () => {
|
|
if (global.DOMRenderer && global.SectionManager) {
|
|
const manager = new global.SectionManager();
|
|
const renderer = new global.DOMRenderer(manager, document.createElement('div'));
|
|
|
|
// Test ready state
|
|
let status = { state: 'ready', totalSections: 0, hasModifications: false };
|
|
if (typeof renderer.updateStatusDisplay === 'function') {
|
|
// Should not throw error
|
|
try {
|
|
renderer.updateStatusDisplay(status);
|
|
runner.expect(true).toBeTruthy();
|
|
} catch (error) {
|
|
runner.expect(false).toBeTruthy();
|
|
}
|
|
}
|
|
|
|
// Test modified state
|
|
status = { state: 'modified', totalSections: 1, hasModifications: true };
|
|
if (typeof renderer.updateStatusDisplay === 'function') {
|
|
try {
|
|
renderer.updateStatusDisplay(status);
|
|
runner.expect(true).toBeTruthy();
|
|
} catch (error) {
|
|
runner.expect(false).toBeTruthy();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// Run the tests
|
|
if (require.main === module) {
|
|
console.log('📊 Running TDD Tests for Real-time Status Tracking Recovery');
|
|
runner.run().then(() => {
|
|
console.log('✅ Test run complete - now implement status tracking!');
|
|
});
|
|
}
|
|
|
|
module.exports = runner; |