- Install Jest for unit testing with React Testing Library - Install Playwright for end-to-end testing - Configure Jest with proper TypeScript support and module mapping - Create test setup files and utilities for both unit and e2e tests Components: * Jest configuration with coverage thresholds * Playwright configuration with browser automation * Unit tests for LoginForm, AuthContext, and useSocketIO hook * E2E tests for authentication, dashboard, and agents workflows * GitHub Actions workflow for automated testing * Mock data and API utilities for consistent testing * Test documentation with best practices Testing features: - Unit tests with 70% coverage threshold - E2E tests with API mocking and user journey testing - CI/CD integration for automated test runs - Cross-browser testing support with Playwright - Authentication system testing end-to-end 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
55 lines
2.0 KiB
JavaScript
55 lines
2.0 KiB
JavaScript
'use strict';
|
|
|
|
require('./behavior/click.js');
|
|
require('./behavior/cut.js');
|
|
require('./behavior/keydown.js');
|
|
require('./behavior/keypress.js');
|
|
require('./behavior/keyup.js');
|
|
require('./behavior/paste.js');
|
|
var registry = require('./behavior/registry.js');
|
|
var wrapEvent = require('./wrapEvent.js');
|
|
var eventMap = require('./eventMap.js');
|
|
var createEvent = require('./createEvent.js');
|
|
|
|
function dispatchUIEvent(target, type, init, preventDefault = false) {
|
|
if (eventMap.isMouseEvent(type) || eventMap.isKeyboardEvent(type)) {
|
|
init = {
|
|
...init,
|
|
...this.system.getUIEventModifiers()
|
|
};
|
|
}
|
|
const event = createEvent.createEvent(type, target, init);
|
|
return dispatchEvent.call(this, target, event, preventDefault);
|
|
}
|
|
function dispatchEvent(target, event, preventDefault = false) {
|
|
var _behavior_type;
|
|
const type = event.type;
|
|
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = registry.behavior[type]) === null || _behavior_type === undefined ? undefined : _behavior_type.call(registry.behavior, event, target, this);
|
|
if (behaviorImplementation) {
|
|
event.preventDefault();
|
|
let defaultPrevented = false;
|
|
Object.defineProperty(event, 'defaultPrevented', {
|
|
get: ()=>defaultPrevented
|
|
});
|
|
Object.defineProperty(event, 'preventDefault', {
|
|
value: ()=>{
|
|
defaultPrevented = event.cancelable;
|
|
}
|
|
});
|
|
wrapEvent.wrapEvent(()=>target.dispatchEvent(event));
|
|
if (!defaultPrevented) {
|
|
behaviorImplementation();
|
|
}
|
|
return !defaultPrevented;
|
|
}
|
|
return wrapEvent.wrapEvent(()=>target.dispatchEvent(event));
|
|
}
|
|
function dispatchDOMEvent(target, type, init) {
|
|
const event = createEvent.createEvent(type, target, init);
|
|
wrapEvent.wrapEvent(()=>target.dispatchEvent(event));
|
|
}
|
|
|
|
exports.dispatchDOMEvent = dispatchDOMEvent;
|
|
exports.dispatchEvent = dispatchEvent;
|
|
exports.dispatchUIEvent = dispatchUIEvent;
|