chore: cleanup of history file
Some checks failed
Test Suite / unit-tests (3.11) (push) Has been cancelled
Test Suite / unit-tests (3.12) (push) Has been cancelled
Test Suite / integration-tests (push) Has been cancelled
Test Suite / e2e-tests (push) Has been cancelled
Test Suite / performance-tests (push) Has been cancelled
Test Suite / code-quality (push) Has been cancelled
Test Suite / security-scan (push) Has been cancelled
Test Suite / test-summary (push) Has been cancelled
Some checks failed
Test Suite / unit-tests (3.11) (push) Has been cancelled
Test Suite / unit-tests (3.12) (push) Has been cancelled
Test Suite / integration-tests (push) Has been cancelled
Test Suite / e2e-tests (push) Has been cancelled
Test Suite / performance-tests (push) Has been cancelled
Test Suite / code-quality (push) Has been cancelled
Test Suite / security-scan (push) Has been cancelled
Test Suite / test-summary (push) Has been cancelled
This commit is contained in:
103
history/2025/251114-javascript-dev-tests/test_keyboard_shortcuts.js
Executable file
103
history/2025/251114-javascript-dev-tests/test_keyboard_shortcuts.js
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* TDD Tests for Keyboard Shortcuts Recovery
|
||||
*/
|
||||
|
||||
const { TestRunner, HTMLFileTester } = require('./test_runner.js');
|
||||
const runner = new TestRunner();
|
||||
|
||||
// Test keyboard shortcuts functionality
|
||||
runner.describe('Keyboard Shortcuts for Section Editing', () => {
|
||||
|
||||
runner.it('should have handleKeydown method in DOMRenderer', async () => {
|
||||
// Clear cache and load editor
|
||||
delete require.cache[require.resolve('/home/worsch/markitect_project/markitect/static/editor.js')];
|
||||
require('/home/worsch/markitect_project/markitect/static/editor.js');
|
||||
|
||||
// Check if DOMRenderer has handleKeydown method
|
||||
const DOMRenderer = global.DOMRenderer || require('/home/worsch/markitect_project/markitect/static/editor.js').DOMRenderer;
|
||||
|
||||
if (DOMRenderer) {
|
||||
const renderer = new DOMRenderer({}, document.createElement('div'));
|
||||
const hasHandleKeydown = typeof renderer.handleKeydown === 'function';
|
||||
runner.expect(hasHandleKeydown).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
runner.it('should bind keyboard handlers to textareas', async () => {
|
||||
// This tests the integration - will check if textareas get keydown listeners
|
||||
const { JSDOM } = require('jsdom');
|
||||
const dom = new JSDOM(`
|
||||
<div id="test-container"></div>
|
||||
`);
|
||||
|
||||
global.document = dom.window.document;
|
||||
global.window = dom.window;
|
||||
|
||||
// Load editor and create instances
|
||||
require('/home/worsch/markitect_project/markitect/static/editor.js');
|
||||
|
||||
if (global.DOMRenderer && global.SectionManager) {
|
||||
const manager = new global.SectionManager();
|
||||
const renderer = new global.DOMRenderer(manager, dom.window.document.getElementById('test-container'));
|
||||
|
||||
// The handleKeydown method should exist
|
||||
runner.expect(typeof renderer.handleKeydown).toBe('function');
|
||||
}
|
||||
});
|
||||
|
||||
runner.it('should handle Ctrl+Enter for accepting changes', async () => {
|
||||
// Mock event for Ctrl+Enter
|
||||
const mockEvent = {
|
||||
ctrlKey: true,
|
||||
key: 'Enter',
|
||||
preventDefault: () => {},
|
||||
target: { closest: () => null }
|
||||
};
|
||||
|
||||
// Test that the method exists and can be called
|
||||
if (global.DOMRenderer) {
|
||||
const renderer = new global.DOMRenderer({}, document.createElement('div'));
|
||||
|
||||
// Should not throw error when called
|
||||
try {
|
||||
renderer.handleKeydown(mockEvent);
|
||||
runner.expect(true).toBeTruthy();
|
||||
} catch (error) {
|
||||
runner.expect(false).toBeTruthy();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
runner.it('should handle Escape for canceling changes', async () => {
|
||||
// Mock event for Escape
|
||||
const mockEvent = {
|
||||
key: 'Escape',
|
||||
preventDefault: () => {},
|
||||
target: { closest: () => null }
|
||||
};
|
||||
|
||||
if (global.DOMRenderer) {
|
||||
const renderer = new global.DOMRenderer({}, document.createElement('div'));
|
||||
|
||||
// Should not throw error when called
|
||||
try {
|
||||
renderer.handleKeydown(mockEvent);
|
||||
runner.expect(true).toBeTruthy();
|
||||
} catch (error) {
|
||||
runner.expect(false).toBeTruthy();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Run the tests
|
||||
if (require.main === module) {
|
||||
console.log('⌨️ Running TDD Tests for Keyboard Shortcuts Recovery');
|
||||
runner.run().then(() => {
|
||||
console.log('✅ Test run complete - now implement keyboard shortcuts!');
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = runner;
|
||||
Reference in New Issue
Block a user