Set up comprehensive frontend testing infrastructure
- 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>
This commit is contained in:
32
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/clear.js
generated
vendored
Normal file
32
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/clear.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
require('../event/behavior/click.js');
|
||||
require('../event/behavior/cut.js');
|
||||
require('../event/behavior/keydown.js');
|
||||
require('../event/behavior/keypress.js');
|
||||
require('../event/behavior/keyup.js');
|
||||
require('../event/behavior/paste.js');
|
||||
require('@testing-library/dom');
|
||||
require('../utils/dataTransfer/Clipboard.js');
|
||||
var isEditable = require('../utils/edit/isEditable.js');
|
||||
var isDisabled = require('../utils/misc/isDisabled.js');
|
||||
var focus = require('../event/focus.js');
|
||||
var input = require('../event/input.js');
|
||||
var selectAll = require('../event/selection/selectAll.js');
|
||||
|
||||
async function clear(element) {
|
||||
if (!isEditable.isEditable(element) || isDisabled.isDisabled(element)) {
|
||||
throw new Error('clear()` is only supported on editable elements.');
|
||||
}
|
||||
focus.focusElement(element);
|
||||
if (element.ownerDocument.activeElement !== element) {
|
||||
throw new Error('The element to be cleared could not be focused.');
|
||||
}
|
||||
selectAll.selectAll(element);
|
||||
if (!selectAll.isAllSelected(element)) {
|
||||
throw new Error('The element content to be cleared could not be selected.');
|
||||
}
|
||||
input.input(this, element, '', 'deleteContentBackward');
|
||||
}
|
||||
|
||||
exports.clear = clear;
|
||||
14
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/index.js
generated
vendored
Normal file
14
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/index.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var clear = require('./clear.js');
|
||||
var selectOptions = require('./selectOptions.js');
|
||||
var type = require('./type.js');
|
||||
var upload = require('./upload.js');
|
||||
|
||||
|
||||
|
||||
exports.clear = clear.clear;
|
||||
exports.deselectOptions = selectOptions.deselectOptions;
|
||||
exports.selectOptions = selectOptions.selectOptions;
|
||||
exports.type = type.type;
|
||||
exports.upload = upload.upload;
|
||||
114
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/selectOptions.js
generated
vendored
Normal file
114
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/selectOptions.js
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
'use strict';
|
||||
|
||||
var dom = require('@testing-library/dom');
|
||||
var isElementType = require('../utils/misc/isElementType.js');
|
||||
require('../utils/dataTransfer/Clipboard.js');
|
||||
var isDisabled = require('../utils/misc/isDisabled.js');
|
||||
var wait = require('../utils/misc/wait.js');
|
||||
var cssPointerEvents = require('../utils/pointer/cssPointerEvents.js');
|
||||
require('../event/behavior/click.js');
|
||||
require('../event/behavior/cut.js');
|
||||
require('../event/behavior/keydown.js');
|
||||
require('../event/behavior/keypress.js');
|
||||
require('../event/behavior/keyup.js');
|
||||
require('../event/behavior/paste.js');
|
||||
var focus = require('../event/focus.js');
|
||||
|
||||
async function selectOptions(select, values) {
|
||||
return selectOptionsBase.call(this, true, select, values);
|
||||
}
|
||||
async function deselectOptions(select, values) {
|
||||
return selectOptionsBase.call(this, false, select, values);
|
||||
}
|
||||
async function selectOptionsBase(newValue, select, values) {
|
||||
if (!newValue && !select.multiple) {
|
||||
throw dom.getConfig().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
|
||||
}
|
||||
const valArray = Array.isArray(values) ? values : [
|
||||
values
|
||||
];
|
||||
const allOptions = Array.from(select.querySelectorAll('option, [role="option"]'));
|
||||
const selectedOptions = valArray.map((val)=>{
|
||||
if (typeof val !== 'string' && allOptions.includes(val)) {
|
||||
return val;
|
||||
} else {
|
||||
const matchingOption = allOptions.find((o)=>o.value === val || o.innerHTML === val);
|
||||
if (matchingOption) {
|
||||
return matchingOption;
|
||||
} else {
|
||||
throw dom.getConfig().getElementError(`Value "${String(val)}" not found in options`, select);
|
||||
}
|
||||
}
|
||||
}).filter((option)=>!isDisabled.isDisabled(option));
|
||||
if (isDisabled.isDisabled(select) || !selectedOptions.length) return;
|
||||
const selectOption = (option)=>{
|
||||
option.selected = newValue;
|
||||
this.dispatchUIEvent(select, 'input', {
|
||||
bubbles: true,
|
||||
cancelable: false,
|
||||
composed: true
|
||||
});
|
||||
this.dispatchUIEvent(select, 'change');
|
||||
};
|
||||
if (isElementType.isElementType(select, 'select')) {
|
||||
if (select.multiple) {
|
||||
for (const option of selectedOptions){
|
||||
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, option);
|
||||
// events fired for multiple select are weird. Can't use hover...
|
||||
if (withPointerEvents) {
|
||||
this.dispatchUIEvent(option, 'pointerover');
|
||||
this.dispatchUIEvent(select, 'pointerenter');
|
||||
this.dispatchUIEvent(option, 'mouseover');
|
||||
this.dispatchUIEvent(select, 'mouseenter');
|
||||
this.dispatchUIEvent(option, 'pointermove');
|
||||
this.dispatchUIEvent(option, 'mousemove');
|
||||
this.dispatchUIEvent(option, 'pointerdown');
|
||||
this.dispatchUIEvent(option, 'mousedown');
|
||||
}
|
||||
focus.focusElement(select);
|
||||
if (withPointerEvents) {
|
||||
this.dispatchUIEvent(option, 'pointerup');
|
||||
this.dispatchUIEvent(option, 'mouseup');
|
||||
}
|
||||
selectOption(option);
|
||||
if (withPointerEvents) {
|
||||
this.dispatchUIEvent(option, 'click');
|
||||
}
|
||||
await wait.wait(this.config);
|
||||
}
|
||||
} else if (selectedOptions.length === 1) {
|
||||
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, select);
|
||||
// the click to open the select options
|
||||
if (withPointerEvents) {
|
||||
await this.click(select);
|
||||
} else {
|
||||
focus.focusElement(select);
|
||||
}
|
||||
selectOption(selectedOptions[0]);
|
||||
if (withPointerEvents) {
|
||||
// the browser triggers another click event on the select for the click on the option
|
||||
// this second click has no 'down' phase
|
||||
this.dispatchUIEvent(select, 'pointerover');
|
||||
this.dispatchUIEvent(select, 'pointerenter');
|
||||
this.dispatchUIEvent(select, 'mouseover');
|
||||
this.dispatchUIEvent(select, 'mouseenter');
|
||||
this.dispatchUIEvent(select, 'pointerup');
|
||||
this.dispatchUIEvent(select, 'mouseup');
|
||||
this.dispatchUIEvent(select, 'click');
|
||||
}
|
||||
await wait.wait(this.config);
|
||||
} else {
|
||||
throw dom.getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
|
||||
}
|
||||
} else if (select.getAttribute('role') === 'listbox') {
|
||||
for (const option of selectedOptions){
|
||||
await this.click(option);
|
||||
await this.unhover(option);
|
||||
}
|
||||
} else {
|
||||
throw dom.getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
|
||||
}
|
||||
}
|
||||
|
||||
exports.deselectOptions = deselectOptions;
|
||||
exports.selectOptions = selectOptions;
|
||||
23
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/type.js
generated
vendored
Normal file
23
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/type.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var index = require('../keyboard/index.js');
|
||||
require('../utils/dataTransfer/Clipboard.js');
|
||||
var setSelectionRange = require('../event/selection/setSelectionRange.js');
|
||||
|
||||
async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
|
||||
// TODO: properly type guard
|
||||
// we use this workaround for now to prevent changing behavior
|
||||
if (element.disabled) return;
|
||||
if (!skipClick) {
|
||||
await this.click(element);
|
||||
}
|
||||
if (initialSelectionStart !== undefined) {
|
||||
setSelectionRange.setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== undefined ? initialSelectionEnd : initialSelectionStart);
|
||||
}
|
||||
await this.keyboard(text);
|
||||
if (!skipAutoClose) {
|
||||
await index.releaseAllKeys(this);
|
||||
}
|
||||
}
|
||||
|
||||
exports.type = type;
|
||||
62
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/upload.js
generated
vendored
Normal file
62
frontend/node_modules/@testing-library/user-event/dist/cjs/utility/upload.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
var isElementType = require('../utils/misc/isElementType.js');
|
||||
var FileList = require('../utils/dataTransfer/FileList.js');
|
||||
require('../utils/dataTransfer/Clipboard.js');
|
||||
var setFiles = require('../utils/edit/setFiles.js');
|
||||
var isDisabled = require('../utils/misc/isDisabled.js');
|
||||
var getWindow = require('../utils/misc/getWindow.js');
|
||||
|
||||
async function upload(element, fileOrFiles) {
|
||||
const input = isElementType.isElementType(element, 'label') ? element.control : element;
|
||||
if (!input || !isElementType.isElementType(input, 'input', {
|
||||
type: 'file'
|
||||
})) {
|
||||
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === undefined ? undefined : input.tagName} element does not accept file uploads`);
|
||||
}
|
||||
if (isDisabled.isDisabled(element)) return;
|
||||
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
|
||||
fileOrFiles
|
||||
]).filter((file)=>!this.config.applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1);
|
||||
const fileDialog = ()=>{
|
||||
var _input_files;
|
||||
// do not fire an input event if the file selection does not change
|
||||
if (files.length === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.length) && files.every((f, i)=>{
|
||||
var _input_files;
|
||||
return f === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.item(i));
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
setFiles.setFiles(input, FileList.createFileList(getWindow.getWindow(element), files));
|
||||
this.dispatchUIEvent(input, 'input');
|
||||
this.dispatchUIEvent(input, 'change');
|
||||
};
|
||||
input.addEventListener('fileDialog', fileDialog);
|
||||
await this.click(element);
|
||||
input.removeEventListener('fileDialog', fileDialog);
|
||||
}
|
||||
// When matching files, browsers ignore case and consider jpeg/jpg interchangeable.
|
||||
function normalize(nameOrType) {
|
||||
return nameOrType.toLowerCase().replace(/(\.|\/)jpg\b/g, '$1jpeg');
|
||||
}
|
||||
function isAcceptableFile(file, accept) {
|
||||
if (!accept) {
|
||||
return true;
|
||||
}
|
||||
const wildcards = [
|
||||
'audio/*',
|
||||
'image/*',
|
||||
'video/*'
|
||||
];
|
||||
return normalize(accept).trim().split(/\s*,\s*/).some((acceptToken)=>{
|
||||
// tokens starting with a dot represent a file extension
|
||||
if (acceptToken.startsWith('.')) {
|
||||
return normalize(file.name).endsWith(acceptToken);
|
||||
} else if (wildcards.includes(acceptToken)) {
|
||||
return normalize(file.type).startsWith(acceptToken.replace('*', ''));
|
||||
}
|
||||
return normalize(file.type) === acceptToken;
|
||||
});
|
||||
}
|
||||
|
||||
exports.upload = upload;
|
||||
Reference in New Issue
Block a user