 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>
		
			
				
	
	
		
			177 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			177 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| "use strict";
 | |
| Object.defineProperty(exports, "__esModule", { value: true });
 | |
| exports.defaultTreeAdapter = void 0;
 | |
| const html_js_1 = require("../common/html.js");
 | |
| exports.defaultTreeAdapter = {
 | |
|     //Node construction
 | |
|     createDocument() {
 | |
|         return {
 | |
|             nodeName: '#document',
 | |
|             mode: html_js_1.DOCUMENT_MODE.NO_QUIRKS,
 | |
|             childNodes: [],
 | |
|         };
 | |
|     },
 | |
|     createDocumentFragment() {
 | |
|         return {
 | |
|             nodeName: '#document-fragment',
 | |
|             childNodes: [],
 | |
|         };
 | |
|     },
 | |
|     createElement(tagName, namespaceURI, attrs) {
 | |
|         return {
 | |
|             nodeName: tagName,
 | |
|             tagName,
 | |
|             attrs,
 | |
|             namespaceURI,
 | |
|             childNodes: [],
 | |
|             parentNode: null,
 | |
|         };
 | |
|     },
 | |
|     createCommentNode(data) {
 | |
|         return {
 | |
|             nodeName: '#comment',
 | |
|             data,
 | |
|             parentNode: null,
 | |
|         };
 | |
|     },
 | |
|     createTextNode(value) {
 | |
|         return {
 | |
|             nodeName: '#text',
 | |
|             value,
 | |
|             parentNode: null,
 | |
|         };
 | |
|     },
 | |
|     //Tree mutation
 | |
|     appendChild(parentNode, newNode) {
 | |
|         parentNode.childNodes.push(newNode);
 | |
|         newNode.parentNode = parentNode;
 | |
|     },
 | |
|     insertBefore(parentNode, newNode, referenceNode) {
 | |
|         const insertionIdx = parentNode.childNodes.indexOf(referenceNode);
 | |
|         parentNode.childNodes.splice(insertionIdx, 0, newNode);
 | |
|         newNode.parentNode = parentNode;
 | |
|     },
 | |
|     setTemplateContent(templateElement, contentElement) {
 | |
|         templateElement.content = contentElement;
 | |
|     },
 | |
|     getTemplateContent(templateElement) {
 | |
|         return templateElement.content;
 | |
|     },
 | |
|     setDocumentType(document, name, publicId, systemId) {
 | |
|         const doctypeNode = document.childNodes.find((node) => node.nodeName === '#documentType');
 | |
|         if (doctypeNode) {
 | |
|             doctypeNode.name = name;
 | |
|             doctypeNode.publicId = publicId;
 | |
|             doctypeNode.systemId = systemId;
 | |
|         }
 | |
|         else {
 | |
|             const node = {
 | |
|                 nodeName: '#documentType',
 | |
|                 name,
 | |
|                 publicId,
 | |
|                 systemId,
 | |
|                 parentNode: null,
 | |
|             };
 | |
|             exports.defaultTreeAdapter.appendChild(document, node);
 | |
|         }
 | |
|     },
 | |
|     setDocumentMode(document, mode) {
 | |
|         document.mode = mode;
 | |
|     },
 | |
|     getDocumentMode(document) {
 | |
|         return document.mode;
 | |
|     },
 | |
|     detachNode(node) {
 | |
|         if (node.parentNode) {
 | |
|             const idx = node.parentNode.childNodes.indexOf(node);
 | |
|             node.parentNode.childNodes.splice(idx, 1);
 | |
|             node.parentNode = null;
 | |
|         }
 | |
|     },
 | |
|     insertText(parentNode, text) {
 | |
|         if (parentNode.childNodes.length > 0) {
 | |
|             const prevNode = parentNode.childNodes[parentNode.childNodes.length - 1];
 | |
|             if (exports.defaultTreeAdapter.isTextNode(prevNode)) {
 | |
|                 prevNode.value += text;
 | |
|                 return;
 | |
|             }
 | |
|         }
 | |
|         exports.defaultTreeAdapter.appendChild(parentNode, exports.defaultTreeAdapter.createTextNode(text));
 | |
|     },
 | |
|     insertTextBefore(parentNode, text, referenceNode) {
 | |
|         const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
 | |
|         if (prevNode && exports.defaultTreeAdapter.isTextNode(prevNode)) {
 | |
|             prevNode.value += text;
 | |
|         }
 | |
|         else {
 | |
|             exports.defaultTreeAdapter.insertBefore(parentNode, exports.defaultTreeAdapter.createTextNode(text), referenceNode);
 | |
|         }
 | |
|     },
 | |
|     adoptAttributes(recipient, attrs) {
 | |
|         const recipientAttrsMap = new Set(recipient.attrs.map((attr) => attr.name));
 | |
|         for (let j = 0; j < attrs.length; j++) {
 | |
|             if (!recipientAttrsMap.has(attrs[j].name)) {
 | |
|                 recipient.attrs.push(attrs[j]);
 | |
|             }
 | |
|         }
 | |
|     },
 | |
|     //Tree traversing
 | |
|     getFirstChild(node) {
 | |
|         return node.childNodes[0];
 | |
|     },
 | |
|     getChildNodes(node) {
 | |
|         return node.childNodes;
 | |
|     },
 | |
|     getParentNode(node) {
 | |
|         return node.parentNode;
 | |
|     },
 | |
|     getAttrList(element) {
 | |
|         return element.attrs;
 | |
|     },
 | |
|     //Node data
 | |
|     getTagName(element) {
 | |
|         return element.tagName;
 | |
|     },
 | |
|     getNamespaceURI(element) {
 | |
|         return element.namespaceURI;
 | |
|     },
 | |
|     getTextNodeContent(textNode) {
 | |
|         return textNode.value;
 | |
|     },
 | |
|     getCommentNodeContent(commentNode) {
 | |
|         return commentNode.data;
 | |
|     },
 | |
|     getDocumentTypeNodeName(doctypeNode) {
 | |
|         return doctypeNode.name;
 | |
|     },
 | |
|     getDocumentTypeNodePublicId(doctypeNode) {
 | |
|         return doctypeNode.publicId;
 | |
|     },
 | |
|     getDocumentTypeNodeSystemId(doctypeNode) {
 | |
|         return doctypeNode.systemId;
 | |
|     },
 | |
|     //Node types
 | |
|     isTextNode(node) {
 | |
|         return node.nodeName === '#text';
 | |
|     },
 | |
|     isCommentNode(node) {
 | |
|         return node.nodeName === '#comment';
 | |
|     },
 | |
|     isDocumentTypeNode(node) {
 | |
|         return node.nodeName === '#documentType';
 | |
|     },
 | |
|     isElementNode(node) {
 | |
|         return Object.prototype.hasOwnProperty.call(node, 'tagName');
 | |
|     },
 | |
|     // Source code location
 | |
|     setNodeSourceCodeLocation(node, location) {
 | |
|         node.sourceCodeLocation = location;
 | |
|     },
 | |
|     getNodeSourceCodeLocation(node) {
 | |
|         return node.sourceCodeLocation;
 | |
|     },
 | |
|     updateNodeSourceCodeLocation(node, endLocation) {
 | |
|         node.sourceCodeLocation = Object.assign(Object.assign({}, node.sourceCodeLocation), endLocation);
 | |
|     },
 | |
| };
 |