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:
84
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/buttons.js
generated
vendored
Normal file
84
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/buttons.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
function _define_property(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class Buttons {
|
||||
getButtons() {
|
||||
let v = 0;
|
||||
for (const button of Object.keys(this.pressed)){
|
||||
// eslint-disable-next-line no-bitwise
|
||||
v |= 2 ** Number(button);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
down(keyDef) {
|
||||
const button = getMouseButtonId(keyDef.button);
|
||||
if (button in this.pressed) {
|
||||
this.pressed[button].push(keyDef);
|
||||
return undefined;
|
||||
}
|
||||
this.pressed[button] = [
|
||||
keyDef
|
||||
];
|
||||
return button;
|
||||
}
|
||||
up(keyDef) {
|
||||
const button = getMouseButtonId(keyDef.button);
|
||||
if (button in this.pressed) {
|
||||
this.pressed[button] = this.pressed[button].filter((k)=>k.name !== keyDef.name);
|
||||
if (this.pressed[button].length === 0) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete this.pressed[button];
|
||||
return button;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
constructor(){
|
||||
_define_property(this, "pressed", {});
|
||||
}
|
||||
}
|
||||
const MouseButton = {
|
||||
primary: 0,
|
||||
secondary: 1,
|
||||
auxiliary: 2,
|
||||
back: 3,
|
||||
X1: 3,
|
||||
forward: 4,
|
||||
X2: 4
|
||||
};
|
||||
function getMouseButtonId(button = 0) {
|
||||
if (button in MouseButton) {
|
||||
return MouseButton[button];
|
||||
}
|
||||
return Number(button);
|
||||
}
|
||||
// On the `MouseEvent.button` property auxiliary and secondary button are flipped compared to `MouseEvent.buttons`.
|
||||
const MouseButtonFlip = {
|
||||
1: 2,
|
||||
2: 1
|
||||
};
|
||||
function getMouseEventButton(button) {
|
||||
button = getMouseButtonId(button);
|
||||
if (button in MouseButtonFlip) {
|
||||
return MouseButtonFlip[button];
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
||||
exports.Buttons = Buttons;
|
||||
exports.MouseButton = MouseButton;
|
||||
exports.MouseButtonFlip = MouseButtonFlip;
|
||||
exports.getMouseButtonId = getMouseButtonId;
|
||||
exports.getMouseEventButton = getMouseEventButton;
|
||||
34
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/device.js
generated
vendored
Normal file
34
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/device.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
function _define_property(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class Device {
|
||||
get countPressed() {
|
||||
return this.pressedKeys.size;
|
||||
}
|
||||
isPressed(keyDef) {
|
||||
return this.pressedKeys.has(keyDef.name);
|
||||
}
|
||||
addPressed(keyDef) {
|
||||
return this.pressedKeys.add(keyDef.name);
|
||||
}
|
||||
removePressed(keyDef) {
|
||||
return this.pressedKeys.delete(keyDef.name);
|
||||
}
|
||||
constructor(){
|
||||
_define_property(this, "pressedKeys", new Set());
|
||||
}
|
||||
}
|
||||
|
||||
exports.Device = Device;
|
||||
159
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/index.js
generated
vendored
Normal file
159
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/index.js
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
'use strict';
|
||||
|
||||
var buttons = require('./buttons.js');
|
||||
var device = require('./device.js');
|
||||
var mouse = require('./mouse.js');
|
||||
var pointer = require('./pointer.js');
|
||||
|
||||
function _define_property(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class PointerHost {
|
||||
isKeyPressed(keyDef) {
|
||||
return this.devices.get(keyDef.pointerType).isPressed(keyDef);
|
||||
}
|
||||
async press(instance, keyDef, position) {
|
||||
this.devices.get(keyDef.pointerType).addPressed(keyDef);
|
||||
this.buttons.down(keyDef);
|
||||
const pointerName = this.getPointerName(keyDef);
|
||||
const pointer = keyDef.pointerType === 'touch' ? this.pointers.new(pointerName, keyDef.pointerType, this.buttons) : this.pointers.get(pointerName);
|
||||
// TODO: deprecate the following implicit setting of position
|
||||
pointer.position = position;
|
||||
if (pointer.pointerType !== 'touch') {
|
||||
this.mouse.position = position;
|
||||
}
|
||||
if (pointer.pointerType === 'touch') {
|
||||
pointer.init(instance);
|
||||
}
|
||||
pointer.down(instance, keyDef.button);
|
||||
if (pointer.pointerType !== 'touch') {
|
||||
this.mouse.down(instance, keyDef, pointer.isPrevented);
|
||||
}
|
||||
}
|
||||
async move(instance, pointerName, position) {
|
||||
const pointer = this.pointers.get(pointerName);
|
||||
// In (some?) browsers this order of events can be observed.
|
||||
// This interweaving of events is probably unnecessary.
|
||||
// While the order of mouse (or pointer) events is defined per spec,
|
||||
// the order in which they interweave/follow on a user interaction depends on the implementation.
|
||||
const pointermove = pointer.move(instance, position);
|
||||
const mousemove = pointer.pointerType === 'touch' ? undefined : this.mouse.move(instance, position, pointer.isPrevented);
|
||||
pointermove === null || pointermove === undefined ? undefined : pointermove.leave();
|
||||
mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
|
||||
pointermove === null || pointermove === undefined ? undefined : pointermove.enter();
|
||||
mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
|
||||
pointermove === null || pointermove === undefined ? undefined : pointermove.move();
|
||||
mousemove === null || mousemove === undefined ? undefined : mousemove.move();
|
||||
}
|
||||
async release(instance, keyDef, position) {
|
||||
const device = this.devices.get(keyDef.pointerType);
|
||||
device.removePressed(keyDef);
|
||||
this.buttons.up(keyDef);
|
||||
const pointer = this.pointers.get(this.getPointerName(keyDef));
|
||||
const isPrevented = pointer.isPrevented;
|
||||
// TODO: deprecate the following implicit setting of position
|
||||
pointer.position = position;
|
||||
if (pointer.pointerType !== 'touch') {
|
||||
this.mouse.position = position;
|
||||
}
|
||||
if (device.countPressed === 0) {
|
||||
pointer.up(instance, keyDef.button);
|
||||
}
|
||||
if (pointer.pointerType === 'touch') {
|
||||
pointer.release(instance);
|
||||
}
|
||||
if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
|
||||
const mousemove = this.mouse.move(instance, position, isPrevented);
|
||||
mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
|
||||
mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
|
||||
mousemove === null || mousemove === undefined ? undefined : mousemove.move();
|
||||
this.mouse.down(instance, keyDef, isPrevented);
|
||||
}
|
||||
if (!pointer.isMultitouch) {
|
||||
const mousemove = this.mouse.move(instance, position, isPrevented);
|
||||
mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
|
||||
mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
|
||||
mousemove === null || mousemove === undefined ? undefined : mousemove.move();
|
||||
this.mouse.up(instance, keyDef, isPrevented);
|
||||
}
|
||||
}
|
||||
getPointerName(keyDef) {
|
||||
return keyDef.pointerType === 'touch' ? keyDef.name : keyDef.pointerType;
|
||||
}
|
||||
getPreviousPosition(pointerName) {
|
||||
return this.pointers.has(pointerName) ? this.pointers.get(pointerName).position : undefined;
|
||||
}
|
||||
resetClickCount() {
|
||||
this.mouse.resetClickCount();
|
||||
}
|
||||
getMouseTarget(instance) {
|
||||
var _this_mouse_position_target;
|
||||
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== undefined ? _this_mouse_position_target : instance.config.document.body;
|
||||
}
|
||||
setMousePosition(position) {
|
||||
this.mouse.position = position;
|
||||
this.pointers.get('mouse').position = position;
|
||||
}
|
||||
constructor(system){
|
||||
_define_property(this, "system", undefined);
|
||||
_define_property(this, "mouse", undefined);
|
||||
_define_property(this, "buttons", undefined);
|
||||
_define_property(this, "devices", new class {
|
||||
get(k) {
|
||||
var _this_registry, _k;
|
||||
var _;
|
||||
return (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== undefined ? _ : _this_registry[_k] = new device.Device();
|
||||
}
|
||||
constructor(){
|
||||
_define_property(this, "registry", {});
|
||||
}
|
||||
}());
|
||||
_define_property(this, "pointers", new class {
|
||||
new(pointerName, pointerType, buttons) {
|
||||
const isPrimary = pointerType !== 'touch' || !Object.values(this.registry).some((p)=>p.pointerType === 'touch' && !p.isCancelled);
|
||||
if (!isPrimary) {
|
||||
Object.values(this.registry).forEach((p)=>{
|
||||
if (p.pointerType === pointerType && !p.isCancelled) {
|
||||
p.isMultitouch = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
this.registry[pointerName] = new pointer.Pointer({
|
||||
pointerId: this.nextId++,
|
||||
pointerType,
|
||||
isPrimary
|
||||
}, buttons);
|
||||
return this.registry[pointerName];
|
||||
}
|
||||
get(pointerName) {
|
||||
if (!this.has(pointerName)) {
|
||||
throw new Error(`Trying to access pointer "${pointerName}" which does not exist.`);
|
||||
}
|
||||
return this.registry[pointerName];
|
||||
}
|
||||
has(pointerName) {
|
||||
return pointerName in this.registry;
|
||||
}
|
||||
constructor(){
|
||||
_define_property(this, "registry", {});
|
||||
_define_property(this, "nextId", 1);
|
||||
}
|
||||
}());
|
||||
this.system = system;
|
||||
this.buttons = new buttons.Buttons();
|
||||
this.mouse = new mouse.Mouse();
|
||||
this.pointers.new('mouse', 'mouse', this.buttons);
|
||||
}
|
||||
}
|
||||
|
||||
exports.PointerHost = PointerHost;
|
||||
207
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/mouse.js
generated
vendored
Normal file
207
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/mouse.js
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
'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 isDisabled = require('../../utils/misc/isDisabled.js');
|
||||
var getTreeDiff = require('../../utils/misc/getTreeDiff.js');
|
||||
var focus = require('../../event/focus.js');
|
||||
var setSelectionPerMouse = require('../../event/selection/setSelectionPerMouse.js');
|
||||
var modifySelectionPerMouse = require('../../event/selection/modifySelectionPerMouse.js');
|
||||
var buttons = require('./buttons.js');
|
||||
var shared = require('./shared.js');
|
||||
|
||||
function _define_property(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
/**
|
||||
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
||||
*/ class Mouse {
|
||||
move(instance, position, /** Whether `preventDefault()` has been called on the `pointerdown` event */ isPrevented) {
|
||||
const prevPosition = this.position;
|
||||
const prevTarget = this.getTarget(instance);
|
||||
this.position = position;
|
||||
if (!shared.isDifferentPointerPosition(prevPosition, position)) {
|
||||
return;
|
||||
}
|
||||
const nextTarget = this.getTarget(instance);
|
||||
const init = this.getEventInit('mousemove');
|
||||
const [leave, enter] = getTreeDiff.getTreeDiff(prevTarget, nextTarget);
|
||||
return {
|
||||
leave: ()=>{
|
||||
if (prevTarget !== nextTarget) {
|
||||
instance.dispatchUIEvent(prevTarget, 'mouseout', init);
|
||||
leave.forEach((el)=>instance.dispatchUIEvent(el, 'mouseleave', init));
|
||||
}
|
||||
},
|
||||
enter: ()=>{
|
||||
if (prevTarget !== nextTarget) {
|
||||
instance.dispatchUIEvent(nextTarget, 'mouseover', init);
|
||||
enter.forEach((el)=>instance.dispatchUIEvent(el, 'mouseenter', init));
|
||||
}
|
||||
},
|
||||
move: ()=>{
|
||||
if (isPrevented) {
|
||||
return;
|
||||
}
|
||||
instance.dispatchUIEvent(nextTarget, 'mousemove', init);
|
||||
this.modifySelecting(instance);
|
||||
}
|
||||
};
|
||||
}
|
||||
down(instance, keyDef, /** Whether `preventDefault()` has been called on the `pointerdown` event */ isPrevented) {
|
||||
const button = this.buttons.down(keyDef);
|
||||
if (button === undefined) {
|
||||
return;
|
||||
}
|
||||
const target = this.getTarget(instance);
|
||||
this.buttonDownTarget[button] = target;
|
||||
const init = this.getEventInit('mousedown', keyDef.button);
|
||||
const disabled = isDisabled.isDisabled(target);
|
||||
if (!isPrevented && (disabled || instance.dispatchUIEvent(target, 'mousedown', init))) {
|
||||
this.startSelecting(instance, init.detail);
|
||||
focus.focusElement(target);
|
||||
}
|
||||
if (!disabled && buttons.getMouseEventButton(keyDef.button) === 2) {
|
||||
instance.dispatchUIEvent(target, 'contextmenu', this.getEventInit('contextmenu', keyDef.button));
|
||||
}
|
||||
}
|
||||
up(instance, keyDef, /** Whether `preventDefault()` has been called on the `pointerdown` event */ isPrevented) {
|
||||
const button = this.buttons.up(keyDef);
|
||||
if (button === undefined) {
|
||||
return;
|
||||
}
|
||||
const target = this.getTarget(instance);
|
||||
if (!isDisabled.isDisabled(target)) {
|
||||
if (!isPrevented) {
|
||||
const mouseUpInit = this.getEventInit('mouseup', keyDef.button);
|
||||
instance.dispatchUIEvent(target, 'mouseup', mouseUpInit);
|
||||
this.endSelecting();
|
||||
}
|
||||
const clickTarget = getTreeDiff.getTreeDiff(this.buttonDownTarget[button], target)[2][0];
|
||||
if (clickTarget) {
|
||||
const init = this.getEventInit('click', keyDef.button);
|
||||
if (init.detail) {
|
||||
instance.dispatchUIEvent(clickTarget, init.button === 0 ? 'click' : 'auxclick', init);
|
||||
if (init.button === 0 && init.detail === 2) {
|
||||
instance.dispatchUIEvent(clickTarget, 'dblclick', {
|
||||
...this.getEventInit('dblclick', keyDef.button),
|
||||
detail: init.detail
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resetClickCount() {
|
||||
this.clickCount.reset();
|
||||
}
|
||||
getEventInit(type, button) {
|
||||
const init = {
|
||||
...this.position.coords
|
||||
};
|
||||
init.button = buttons.getMouseEventButton(button);
|
||||
init.buttons = this.buttons.getButtons();
|
||||
if (type === 'mousedown') {
|
||||
init.detail = this.clickCount.getOnDown(init.button);
|
||||
} else if (type === 'mouseup') {
|
||||
init.detail = this.clickCount.getOnUp(init.button);
|
||||
} else if (type === 'click' || type === 'auxclick') {
|
||||
init.detail = this.clickCount.incOnClick(init.button);
|
||||
}
|
||||
return init;
|
||||
}
|
||||
getTarget(instance) {
|
||||
var _this_position_target;
|
||||
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
|
||||
}
|
||||
startSelecting(instance, clickCount) {
|
||||
var _this_position_caret, _this_position_caret1;
|
||||
// TODO: support extending range (shift)
|
||||
this.selecting = setSelectionPerMouse.setSelectionPerMouseDown({
|
||||
document: instance.config.document,
|
||||
target: this.getTarget(instance),
|
||||
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node,
|
||||
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset,
|
||||
clickCount
|
||||
});
|
||||
}
|
||||
modifySelecting(instance) {
|
||||
var _this_position_caret, _this_position_caret1;
|
||||
if (!this.selecting) {
|
||||
return;
|
||||
}
|
||||
modifySelectionPerMouse.modifySelectionPerMouseMove(this.selecting, {
|
||||
document: instance.config.document,
|
||||
target: this.getTarget(instance),
|
||||
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node,
|
||||
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset
|
||||
});
|
||||
}
|
||||
endSelecting() {
|
||||
this.selecting = undefined;
|
||||
}
|
||||
constructor(){
|
||||
_define_property(this, "position", {});
|
||||
_define_property(this, "buttons", new buttons.Buttons());
|
||||
_define_property(this, "selecting", undefined);
|
||||
_define_property(this, "buttonDownTarget", {});
|
||||
// According to spec the `detail` on click events should be the number
|
||||
// of *consecutive* clicks with a specific button.
|
||||
// On `mousedown` and `mouseup` it should be this number increased by one.
|
||||
// But the browsers don't implement it this way.
|
||||
// If another button is pressed,
|
||||
// in Webkit: the `mouseup` on the previously pressed button has `detail: 0` and no `click`/`auxclick`.
|
||||
// in Gecko: the `mouseup` and click events have the same detail as the `mousedown`.
|
||||
// If there is a delay while a button is pressed,
|
||||
// the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
|
||||
// We'll follow the minimal implementation of Webkit.
|
||||
_define_property(this, "clickCount", new class {
|
||||
incOnClick(button) {
|
||||
const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
||||
this.count = this.count[button] === undefined ? {} : {
|
||||
[button]: Number(this.count[button]) + 1
|
||||
};
|
||||
return current;
|
||||
}
|
||||
getOnDown(button) {
|
||||
var _this_count_button;
|
||||
this.down = {
|
||||
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== undefined ? _this_count_button : 0
|
||||
};
|
||||
var _this_count_button1;
|
||||
this.count = {
|
||||
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== undefined ? _this_count_button1 : 0
|
||||
};
|
||||
return Number(this.count[button]) + 1;
|
||||
}
|
||||
getOnUp(button) {
|
||||
return this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
||||
}
|
||||
reset() {
|
||||
this.count = {};
|
||||
}
|
||||
constructor(){
|
||||
_define_property(this, "down", {});
|
||||
_define_property(this, "count", {});
|
||||
}
|
||||
}());
|
||||
}
|
||||
}
|
||||
|
||||
exports.Mouse = Mouse;
|
||||
131
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/pointer.js
generated
vendored
Normal file
131
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/pointer.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
'use strict';
|
||||
|
||||
require('../../utils/dataTransfer/Clipboard.js');
|
||||
var getTreeDiff = require('../../utils/misc/getTreeDiff.js');
|
||||
var cssPointerEvents = require('../../utils/pointer/cssPointerEvents.js');
|
||||
var shared = require('./shared.js');
|
||||
var buttons = require('./buttons.js');
|
||||
|
||||
function _define_property(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
class Pointer {
|
||||
init(instance) {
|
||||
const target = this.getTarget(instance);
|
||||
const [, enter] = getTreeDiff.getTreeDiff(null, target);
|
||||
const init = this.getEventInit();
|
||||
cssPointerEvents.assertPointerEvents(instance, target);
|
||||
instance.dispatchUIEvent(target, 'pointerover', init);
|
||||
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
||||
return this;
|
||||
}
|
||||
move(instance, position) {
|
||||
const prevPosition = this.position;
|
||||
const prevTarget = this.getTarget(instance);
|
||||
this.position = position;
|
||||
if (!shared.isDifferentPointerPosition(prevPosition, position)) {
|
||||
return;
|
||||
}
|
||||
const nextTarget = this.getTarget(instance);
|
||||
const init = this.getEventInit(-1);
|
||||
const [leave, enter] = getTreeDiff.getTreeDiff(prevTarget, nextTarget);
|
||||
return {
|
||||
leave: ()=>{
|
||||
if (cssPointerEvents.hasPointerEvents(instance, prevTarget)) {
|
||||
if (prevTarget !== nextTarget) {
|
||||
instance.dispatchUIEvent(prevTarget, 'pointerout', init);
|
||||
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
||||
}
|
||||
}
|
||||
},
|
||||
enter: ()=>{
|
||||
cssPointerEvents.assertPointerEvents(instance, nextTarget);
|
||||
if (prevTarget !== nextTarget) {
|
||||
instance.dispatchUIEvent(nextTarget, 'pointerover', init);
|
||||
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
||||
}
|
||||
},
|
||||
move: ()=>{
|
||||
instance.dispatchUIEvent(nextTarget, 'pointermove', init);
|
||||
}
|
||||
};
|
||||
}
|
||||
down(instance, button = 0) {
|
||||
if (this.isDown) {
|
||||
return;
|
||||
}
|
||||
const target = this.getTarget(instance);
|
||||
cssPointerEvents.assertPointerEvents(instance, target);
|
||||
this.isDown = true;
|
||||
this.isPrevented = !instance.dispatchUIEvent(target, 'pointerdown', this.getEventInit(button));
|
||||
}
|
||||
up(instance, button = 0) {
|
||||
if (!this.isDown) {
|
||||
return;
|
||||
}
|
||||
const target = this.getTarget(instance);
|
||||
cssPointerEvents.assertPointerEvents(instance, target);
|
||||
this.isPrevented = false;
|
||||
this.isDown = false;
|
||||
instance.dispatchUIEvent(target, 'pointerup', this.getEventInit(button));
|
||||
}
|
||||
release(instance) {
|
||||
const target = this.getTarget(instance);
|
||||
const [leave] = getTreeDiff.getTreeDiff(target, null);
|
||||
const init = this.getEventInit();
|
||||
// Currently there is no PointerEventsCheckLevel that would
|
||||
// make this check not use the *asserted* cached value from `up`.
|
||||
/* istanbul ignore else */ if (cssPointerEvents.hasPointerEvents(instance, target)) {
|
||||
instance.dispatchUIEvent(target, 'pointerout', init);
|
||||
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
||||
}
|
||||
this.isCancelled = true;
|
||||
}
|
||||
getTarget(instance) {
|
||||
var _this_position_target;
|
||||
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
|
||||
}
|
||||
getEventInit(/**
|
||||
* The `button` that caused the event.
|
||||
*
|
||||
* This should be `-1` if the event is not caused by a button or touch/pen contact,
|
||||
* e.g. a moving pointer.
|
||||
*/ button) {
|
||||
return {
|
||||
...this.position.coords,
|
||||
pointerId: this.pointerId,
|
||||
pointerType: this.pointerType,
|
||||
isPrimary: this.isPrimary,
|
||||
button: buttons.getMouseEventButton(button),
|
||||
buttons: this.buttons.getButtons()
|
||||
};
|
||||
}
|
||||
constructor({ pointerId, pointerType, isPrimary }, buttons){
|
||||
_define_property(this, "pointerId", undefined);
|
||||
_define_property(this, "pointerType", undefined);
|
||||
_define_property(this, "isPrimary", undefined);
|
||||
_define_property(this, "buttons", undefined);
|
||||
_define_property(this, "isMultitouch", false);
|
||||
_define_property(this, "isCancelled", false);
|
||||
_define_property(this, "isDown", false);
|
||||
_define_property(this, "isPrevented", false);
|
||||
_define_property(this, "position", {});
|
||||
this.pointerId = pointerId;
|
||||
this.pointerType = pointerType;
|
||||
this.isPrimary = isPrimary;
|
||||
this.isMultitouch = !isPrimary;
|
||||
this.buttons = buttons;
|
||||
}
|
||||
}
|
||||
|
||||
exports.Pointer = Pointer;
|
||||
8
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/shared.js
generated
vendored
Normal file
8
frontend/node_modules/@testing-library/user-event/dist/cjs/system/pointer/shared.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
function isDifferentPointerPosition(positionA, positionB) {
|
||||
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_coords2, _positionB_coords2, _positionA_coords3, _positionB_coords3, _positionA_coords4, _positionB_coords4, _positionA_coords5, _positionB_coords5, _positionA_coords6, _positionB_coords6, _positionA_coords7, _positionB_coords7, _positionA_coords8, _positionB_coords8, _positionA_coords9, _positionB_coords9, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
|
||||
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === undefined ? undefined : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === undefined ? undefined : _positionB_coords.x) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === undefined ? undefined : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === undefined ? undefined : _positionB_coords1.y) || ((_positionA_coords2 = positionA.coords) === null || _positionA_coords2 === undefined ? undefined : _positionA_coords2.clientX) !== ((_positionB_coords2 = positionB.coords) === null || _positionB_coords2 === undefined ? undefined : _positionB_coords2.clientX) || ((_positionA_coords3 = positionA.coords) === null || _positionA_coords3 === undefined ? undefined : _positionA_coords3.clientY) !== ((_positionB_coords3 = positionB.coords) === null || _positionB_coords3 === undefined ? undefined : _positionB_coords3.clientY) || ((_positionA_coords4 = positionA.coords) === null || _positionA_coords4 === undefined ? undefined : _positionA_coords4.offsetX) !== ((_positionB_coords4 = positionB.coords) === null || _positionB_coords4 === undefined ? undefined : _positionB_coords4.offsetX) || ((_positionA_coords5 = positionA.coords) === null || _positionA_coords5 === undefined ? undefined : _positionA_coords5.offsetY) !== ((_positionB_coords5 = positionB.coords) === null || _positionB_coords5 === undefined ? undefined : _positionB_coords5.offsetY) || ((_positionA_coords6 = positionA.coords) === null || _positionA_coords6 === undefined ? undefined : _positionA_coords6.pageX) !== ((_positionB_coords6 = positionB.coords) === null || _positionB_coords6 === undefined ? undefined : _positionB_coords6.pageX) || ((_positionA_coords7 = positionA.coords) === null || _positionA_coords7 === undefined ? undefined : _positionA_coords7.pageY) !== ((_positionB_coords7 = positionB.coords) === null || _positionB_coords7 === undefined ? undefined : _positionB_coords7.pageY) || ((_positionA_coords8 = positionA.coords) === null || _positionA_coords8 === undefined ? undefined : _positionA_coords8.screenX) !== ((_positionB_coords8 = positionB.coords) === null || _positionB_coords8 === undefined ? undefined : _positionB_coords8.screenX) || ((_positionA_coords9 = positionA.coords) === null || _positionA_coords9 === undefined ? undefined : _positionA_coords9.screenY) !== ((_positionB_coords9 = positionB.coords) === null || _positionB_coords9 === undefined ? undefined : _positionB_coords9.screenY) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === undefined ? undefined : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === undefined ? undefined : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === undefined ? undefined : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === undefined ? undefined : _positionB_caret1.offset);
|
||||
}
|
||||
|
||||
exports.isDifferentPointerPosition = isDifferentPointerPosition;
|
||||
Reference in New Issue
Block a user