 aacb45156b
			
		
	
	aacb45156b
	
	
	
		
			
			- 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>
		
			
				
	
	
		
			70 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| "use strict";
 | |
| 
 | |
| Object.defineProperty(exports, "__esModule", {
 | |
|   value: true
 | |
| });
 | |
| exports.fireEvent = void 0;
 | |
| var _dom = require("@testing-library/dom");
 | |
| // react-testing-library's version of fireEvent will call
 | |
| // dom-testing-library's version of fireEvent. The reason
 | |
| // we make this distinction however is because we have
 | |
| // a few extra events that work a bit differently
 | |
| const fireEvent = (...args) => (0, _dom.fireEvent)(...args);
 | |
| exports.fireEvent = fireEvent;
 | |
| Object.keys(_dom.fireEvent).forEach(key => {
 | |
|   fireEvent[key] = (...args) => _dom.fireEvent[key](...args);
 | |
| });
 | |
| 
 | |
| // React event system tracks native mouseOver/mouseOut events for
 | |
| // running onMouseEnter/onMouseLeave handlers
 | |
| // @link https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/events/EnterLeaveEventPlugin.js#L24-L31
 | |
| const mouseEnter = fireEvent.mouseEnter;
 | |
| const mouseLeave = fireEvent.mouseLeave;
 | |
| fireEvent.mouseEnter = (...args) => {
 | |
|   mouseEnter(...args);
 | |
|   return fireEvent.mouseOver(...args);
 | |
| };
 | |
| fireEvent.mouseLeave = (...args) => {
 | |
|   mouseLeave(...args);
 | |
|   return fireEvent.mouseOut(...args);
 | |
| };
 | |
| const pointerEnter = fireEvent.pointerEnter;
 | |
| const pointerLeave = fireEvent.pointerLeave;
 | |
| fireEvent.pointerEnter = (...args) => {
 | |
|   pointerEnter(...args);
 | |
|   return fireEvent.pointerOver(...args);
 | |
| };
 | |
| fireEvent.pointerLeave = (...args) => {
 | |
|   pointerLeave(...args);
 | |
|   return fireEvent.pointerOut(...args);
 | |
| };
 | |
| const select = fireEvent.select;
 | |
| fireEvent.select = (node, init) => {
 | |
|   select(node, init);
 | |
|   // React tracks this event only on focused inputs
 | |
|   node.focus();
 | |
| 
 | |
|   // React creates this event when one of the following native events happens
 | |
|   // - contextMenu
 | |
|   // - mouseUp
 | |
|   // - dragEnd
 | |
|   // - keyUp
 | |
|   // - keyDown
 | |
|   // so we can use any here
 | |
|   // @link https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/events/SelectEventPlugin.js#L203-L224
 | |
|   fireEvent.keyUp(node, init);
 | |
| };
 | |
| 
 | |
| // React event system tracks native focusout/focusin events for
 | |
| // running blur/focus handlers
 | |
| // @link https://github.com/facebook/react/pull/19186
 | |
| const blur = fireEvent.blur;
 | |
| const focus = fireEvent.focus;
 | |
| fireEvent.blur = (...args) => {
 | |
|   fireEvent.focusOut(...args);
 | |
|   return blur(...args);
 | |
| };
 | |
| fireEvent.focus = (...args) => {
 | |
|   fireEvent.focusIn(...args);
 | |
|   return focus(...args);
 | |
| }; |