mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 14:42:11 -03:00
fix(test): add PointerEvent polyfills and update drag interaction test to match implementation
This commit is contained in:
@@ -1,6 +1,35 @@
|
||||
import { afterEach, beforeEach } from 'vitest';
|
||||
import { resetDom } from './utils/domFixtures.js';
|
||||
|
||||
// Polyfill PointerEvent for jsdom environment
|
||||
if (typeof window !== 'undefined' && !window.PointerEvent) {
|
||||
class PointerEvent extends MouseEvent {
|
||||
constructor(type, eventInit = {}) {
|
||||
super(type, eventInit);
|
||||
this.pointerId = eventInit.pointerId || 0;
|
||||
this.pointerType = eventInit.pointerType || 'mouse';
|
||||
this.isPrimary = eventInit.isPrimary !== undefined ? eventInit.isPrimary : true;
|
||||
}
|
||||
}
|
||||
window.PointerEvent = PointerEvent;
|
||||
}
|
||||
|
||||
// Polyfill setPointerCapture and releasePointerCapture for jsdom elements
|
||||
if (typeof Element !== 'undefined') {
|
||||
const capturedPointers = new Map();
|
||||
|
||||
Element.prototype.setPointerCapture = function(pointerId) {
|
||||
capturedPointers.set(pointerId, this);
|
||||
};
|
||||
|
||||
Element.prototype.releasePointerCapture = function(pointerId) {
|
||||
capturedPointers.delete(pointerId);
|
||||
};
|
||||
|
||||
// Store captured pointers for potential use in tests
|
||||
window.__testCapturedPointers = capturedPointers;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
// Ensure storage is clean before each test to avoid cross-test pollution
|
||||
localStorage.clear();
|
||||
|
||||
Reference in New Issue
Block a user