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:
53
frontend/node_modules/@testing-library/user-event/dist/esm/document/trackValue.js
generated
vendored
Normal file
53
frontend/node_modules/@testing-library/user-event/dist/esm/document/trackValue.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import '../utils/dataTransfer/Clipboard.js';
|
||||
import { getWindow } from '../utils/misc/getWindow.js';
|
||||
import { setUIValueClean, setUISelection, hasUISelection } from './UI.js';
|
||||
|
||||
const TrackChanges = Symbol('Track programmatic changes for React workaround');
|
||||
// When the input event happens in the browser, React executes all event handlers
|
||||
// and if they change state of a controlled value, nothing happens.
|
||||
// But when we trigger the event handlers in test environment with React@17,
|
||||
// the changes are rolled back before the state update is applied.
|
||||
// This results in a reset cursor.
|
||||
// There might be a better way to work around if we figure out
|
||||
// why the batched update is executed differently in our test environment.
|
||||
function isReact17Element(element) {
|
||||
return Object.getOwnPropertyNames(element).some((k)=>k.startsWith('__react')) && getWindow(element).REACT_VERSION === 17;
|
||||
}
|
||||
function startTrackValue(element) {
|
||||
if (!isReact17Element(element)) {
|
||||
return;
|
||||
}
|
||||
element[TrackChanges] = {
|
||||
previousValue: String(element.value),
|
||||
tracked: []
|
||||
};
|
||||
}
|
||||
function trackOrSetValue(element, v) {
|
||||
var _element_TrackChanges_tracked, _element_TrackChanges;
|
||||
(_element_TrackChanges = element[TrackChanges]) === null || _element_TrackChanges === undefined ? undefined : (_element_TrackChanges_tracked = _element_TrackChanges.tracked) === null || _element_TrackChanges_tracked === undefined ? undefined : _element_TrackChanges_tracked.push(v);
|
||||
if (!element[TrackChanges]) {
|
||||
setUIValueClean(element);
|
||||
setUISelection(element, {
|
||||
focusOffset: v.length
|
||||
});
|
||||
}
|
||||
}
|
||||
function commitValueAfterInput(element, cursorOffset) {
|
||||
var _changes_tracked;
|
||||
const changes = element[TrackChanges];
|
||||
element[TrackChanges] = undefined;
|
||||
if (!(changes === null || changes === undefined ? undefined : (_changes_tracked = changes.tracked) === null || _changes_tracked === undefined ? undefined : _changes_tracked.length)) {
|
||||
return;
|
||||
}
|
||||
const isJustReactStateUpdate = changes.tracked.length === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === element.value;
|
||||
if (!isJustReactStateUpdate) {
|
||||
setUIValueClean(element);
|
||||
}
|
||||
if (hasUISelection(element)) {
|
||||
setUISelection(element, {
|
||||
focusOffset: isJustReactStateUpdate ? cursorOffset : element.value.length
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export { commitValueAfterInput, startTrackValue, trackOrSetValue };
|
||||
Reference in New Issue
Block a user