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:
30
frontend/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
generated
vendored
Normal file
30
frontend/node_modules/@testing-library/user-event/dist/esm/utility/clear.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import '../event/behavior/click.js';
|
||||
import '../event/behavior/cut.js';
|
||||
import '../event/behavior/keydown.js';
|
||||
import '../event/behavior/keypress.js';
|
||||
import '../event/behavior/keyup.js';
|
||||
import '../event/behavior/paste.js';
|
||||
import '@testing-library/dom';
|
||||
import '../utils/dataTransfer/Clipboard.js';
|
||||
import { isEditable } from '../utils/edit/isEditable.js';
|
||||
import { isDisabled } from '../utils/misc/isDisabled.js';
|
||||
import { focusElement } from '../event/focus.js';
|
||||
import { input } from '../event/input.js';
|
||||
import { selectAll, isAllSelected } from '../event/selection/selectAll.js';
|
||||
|
||||
async function clear(element) {
|
||||
if (!isEditable(element) || isDisabled(element)) {
|
||||
throw new Error('clear()` is only supported on editable elements.');
|
||||
}
|
||||
focusElement(element);
|
||||
if (element.ownerDocument.activeElement !== element) {
|
||||
throw new Error('The element to be cleared could not be focused.');
|
||||
}
|
||||
selectAll(element);
|
||||
if (!isAllSelected(element)) {
|
||||
throw new Error('The element content to be cleared could not be selected.');
|
||||
}
|
||||
input(this, element, '', 'deleteContentBackward');
|
||||
}
|
||||
|
||||
export { clear };
|
||||
4
frontend/node_modules/@testing-library/user-event/dist/esm/utility/index.js
generated
vendored
Normal file
4
frontend/node_modules/@testing-library/user-event/dist/esm/utility/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export { clear } from './clear.js';
|
||||
export { deselectOptions, selectOptions } from './selectOptions.js';
|
||||
export { type } from './type.js';
|
||||
export { upload } from './upload.js';
|
||||
111
frontend/node_modules/@testing-library/user-event/dist/esm/utility/selectOptions.js
generated
vendored
Normal file
111
frontend/node_modules/@testing-library/user-event/dist/esm/utility/selectOptions.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
import { getConfig } from '@testing-library/dom';
|
||||
import { isElementType } from '../utils/misc/isElementType.js';
|
||||
import '../utils/dataTransfer/Clipboard.js';
|
||||
import { isDisabled } from '../utils/misc/isDisabled.js';
|
||||
import { wait } from '../utils/misc/wait.js';
|
||||
import { hasPointerEvents } from '../utils/pointer/cssPointerEvents.js';
|
||||
import '../event/behavior/click.js';
|
||||
import '../event/behavior/cut.js';
|
||||
import '../event/behavior/keydown.js';
|
||||
import '../event/behavior/keypress.js';
|
||||
import '../event/behavior/keyup.js';
|
||||
import '../event/behavior/paste.js';
|
||||
import { focusElement } from '../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 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 getConfig().getElementError(`Value "${String(val)}" not found in options`, select);
|
||||
}
|
||||
}
|
||||
}).filter((option)=>!isDisabled(option));
|
||||
if (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(select, 'select')) {
|
||||
if (select.multiple) {
|
||||
for (const option of selectedOptions){
|
||||
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : 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');
|
||||
}
|
||||
focusElement(select);
|
||||
if (withPointerEvents) {
|
||||
this.dispatchUIEvent(option, 'pointerup');
|
||||
this.dispatchUIEvent(option, 'mouseup');
|
||||
}
|
||||
selectOption(option);
|
||||
if (withPointerEvents) {
|
||||
this.dispatchUIEvent(option, 'click');
|
||||
}
|
||||
await wait(this.config);
|
||||
}
|
||||
} else if (selectedOptions.length === 1) {
|
||||
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, select);
|
||||
// the click to open the select options
|
||||
if (withPointerEvents) {
|
||||
await this.click(select);
|
||||
} else {
|
||||
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(this.config);
|
||||
} else {
|
||||
throw 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 getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
|
||||
}
|
||||
}
|
||||
|
||||
export { deselectOptions, selectOptions };
|
||||
21
frontend/node_modules/@testing-library/user-event/dist/esm/utility/type.js
generated
vendored
Normal file
21
frontend/node_modules/@testing-library/user-event/dist/esm/utility/type.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { releaseAllKeys } from '../keyboard/index.js';
|
||||
import '../utils/dataTransfer/Clipboard.js';
|
||||
import { setSelectionRange } from '../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(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== undefined ? initialSelectionEnd : initialSelectionStart);
|
||||
}
|
||||
await this.keyboard(text);
|
||||
if (!skipAutoClose) {
|
||||
await releaseAllKeys(this);
|
||||
}
|
||||
}
|
||||
|
||||
export { type };
|
||||
60
frontend/node_modules/@testing-library/user-event/dist/esm/utility/upload.js
generated
vendored
Normal file
60
frontend/node_modules/@testing-library/user-event/dist/esm/utility/upload.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import { isElementType } from '../utils/misc/isElementType.js';
|
||||
import { createFileList } from '../utils/dataTransfer/FileList.js';
|
||||
import '../utils/dataTransfer/Clipboard.js';
|
||||
import { setFiles } from '../utils/edit/setFiles.js';
|
||||
import { isDisabled } from '../utils/misc/isDisabled.js';
|
||||
import { getWindow } from '../utils/misc/getWindow.js';
|
||||
|
||||
async function upload(element, fileOrFiles) {
|
||||
const input = isElementType(element, 'label') ? element.control : element;
|
||||
if (!input || !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(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(input, createFileList(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;
|
||||
});
|
||||
}
|
||||
|
||||
export { upload };
|
||||
Reference in New Issue
Block a user