cypress-real-events
Advanced tools
Comparing version 1.6.0 to 1.7.0
/// <reference types="cypress" /> | ||
import { ScrollBehaviorOptions, Position } from "../getCypressElementCoordinates"; | ||
import { mouseButtonNumbers } from "../mouseButtonNumbers"; | ||
export interface realMouseDownOptions { | ||
@@ -16,4 +17,8 @@ /** Pointer type for realMouseDown, if "pen" touch simulated */ | ||
scrollBehavior?: ScrollBehaviorOptions; | ||
/** | ||
* @default "left" | ||
*/ | ||
button?: keyof typeof mouseButtonNumbers; | ||
} | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
export declare function realMouseDown(subject: JQuery, options?: realMouseDownOptions): Promise<JQuery<HTMLElement>>; |
@@ -15,5 +15,6 @@ "use strict"; | ||
const getCypressElementCoordinates_1 = require("../getCypressElementCoordinates"); | ||
const mouseButtonNumbers_1 = require("../mouseButtonNumbers"); | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
function realMouseDown(subject, options = {}) { | ||
var _a; | ||
var _a, _b, _c; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -35,5 +36,5 @@ const { x, y } = (0, getCypressElementCoordinates_1.getCypressElementCoordinates)(subject, options.position, options.scrollBehavior); | ||
clickCount: 1, | ||
buttons: 1, | ||
pointerType: (_a = options.pointer) !== null && _a !== void 0 ? _a : "mouse", | ||
button: "left", | ||
buttons: mouseButtonNumbers_1.mouseButtonNumbers[(_a = options.button) !== null && _a !== void 0 ? _a : "left"], | ||
pointerType: (_b = options.pointer) !== null && _b !== void 0 ? _b : "mouse", | ||
button: (_c = options.button) !== null && _c !== void 0 ? _c : "left", | ||
}); | ||
@@ -40,0 +41,0 @@ log.snapshot("after").end(); |
/// <reference types="cypress" /> | ||
import { ScrollBehaviorOptions, Position } from "../getCypressElementCoordinates"; | ||
import { mouseButtonNumbers } from "../mouseButtonNumbers"; | ||
export interface realMouseUpOptions { | ||
@@ -16,4 +17,8 @@ /** Pointer type for realMouseUp, if "pen" touch simulated */ | ||
scrollBehavior?: ScrollBehaviorOptions; | ||
/** | ||
* @default "left" | ||
*/ | ||
button?: keyof typeof mouseButtonNumbers; | ||
} | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
export declare function realMouseUp(subject: JQuery, options?: realMouseUpOptions): Promise<JQuery<HTMLElement>>; |
@@ -15,5 +15,6 @@ "use strict"; | ||
const getCypressElementCoordinates_1 = require("../getCypressElementCoordinates"); | ||
const mouseButtonNumbers_1 = require("../mouseButtonNumbers"); | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
function realMouseUp(subject, options = {}) { | ||
var _a; | ||
var _a, _b, _c; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -35,5 +36,5 @@ const { x, y } = (0, getCypressElementCoordinates_1.getCypressElementCoordinates)(subject, options.position, options.scrollBehavior); | ||
clickCount: 1, | ||
buttons: 1, | ||
pointerType: (_a = options.pointer) !== null && _a !== void 0 ? _a : "mouse", | ||
button: "left", | ||
buttons: mouseButtonNumbers_1.mouseButtonNumbers[(_a = options.button) !== null && _a !== void 0 ? _a : "left"], | ||
pointerType: (_b = options.pointer) !== null && _b !== void 0 ? _b : "mouse", | ||
button: (_c = options.button) !== null && _c !== void 0 ? _c : "left", | ||
}); | ||
@@ -40,0 +41,0 @@ log.snapshot("after").end(); |
@@ -17,3 +17,3 @@ "use strict"; | ||
function realClick(subject, options = {}) { | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -34,20 +34,23 @@ // prettier-ignore | ||
log.snapshot("before"); | ||
yield (0, fireCdpCommand_1.fireCdpCommand)("Input.dispatchMouseEvent", { | ||
type: "mousePressed", | ||
x, | ||
y, | ||
clickCount: (_a = options.clickCount) !== null && _a !== void 0 ? _a : 1, | ||
buttons: 1, | ||
pointerType: (_b = options.pointer) !== null && _b !== void 0 ? _b : "mouse", | ||
button: (_c = options.button) !== null && _c !== void 0 ? _c : "left", | ||
}); | ||
yield (0, fireCdpCommand_1.fireCdpCommand)("Input.dispatchMouseEvent", { | ||
type: "mouseReleased", | ||
x, | ||
y, | ||
clickCount: (_d = options.clickCount) !== null && _d !== void 0 ? _d : 1, | ||
buttons: 1, | ||
pointerType: (_e = options.pointer) !== null && _e !== void 0 ? _e : "mouse", | ||
button: (_f = options.button) !== null && _f !== void 0 ? _f : "left", | ||
}); | ||
const { clickCount = 1 } = options; | ||
for (let currentClick = 1; currentClick <= clickCount; currentClick++) { | ||
yield (0, fireCdpCommand_1.fireCdpCommand)("Input.dispatchMouseEvent", { | ||
type: "mousePressed", | ||
x, | ||
y, | ||
clickCount: currentClick, | ||
buttons: 1, | ||
pointerType: (_a = options.pointer) !== null && _a !== void 0 ? _a : "mouse", | ||
button: (_b = options.button) !== null && _b !== void 0 ? _b : "left", | ||
}); | ||
yield (0, fireCdpCommand_1.fireCdpCommand)("Input.dispatchMouseEvent", { | ||
type: "mouseReleased", | ||
x, | ||
y, | ||
clickCount: currentClick, | ||
buttons: 1, | ||
pointerType: (_c = options.pointer) !== null && _c !== void 0 ? _c : "mouse", | ||
button: (_d = options.button) !== null && _d !== void 0 ? _d : "left", | ||
}); | ||
} | ||
log.snapshot("after").end(); | ||
@@ -54,0 +57,0 @@ return subject; |
@@ -24,3 +24,3 @@ type NormalizeCypressCommand<TFun> = TFun extends ( | ||
realClick: NormalizeCypressCommand< | ||
typeof import("./commands/realClick").realClick | ||
typeof import("./commands/realClick").realClick | ||
>; | ||
@@ -36,3 +36,3 @@ /** | ||
realTouch: NormalizeCypressCommand< | ||
typeof import("./commands/realTouch").realTouch | ||
typeof import("./commands/realTouch").realTouch | ||
>; | ||
@@ -47,3 +47,3 @@ /** | ||
realHover: NormalizeCypressCommand< | ||
typeof import("./commands/realHover").realHover | ||
typeof import("./commands/realHover").realHover | ||
>; | ||
@@ -59,3 +59,3 @@ /** | ||
realSwipe: NormalizeCypressCommand< | ||
typeof import("./commands/realSwipe").realSwipe | ||
typeof import("./commands/realSwipe").realSwipe | ||
>; | ||
@@ -100,3 +100,13 @@ /** | ||
>; | ||
/** | ||
* Fires native system mouseMoved event. | ||
* Moves mouse inside a subject to the provided amount of coordinates from top left corner (adjustable with position option.) | ||
* @see https://github.com/dmtrKovalenko/cypress-real-events#cyrealMouseMove | ||
* @example | ||
* cy.get("button").realMouseUp() | ||
*/ | ||
realMouseMove: NormalizeCypressCommand< | ||
typeof import("./commands/mouseMove").realMouseMove | ||
>; | ||
} | ||
} |
@@ -77,2 +77,7 @@ export declare const keyCodeDefinitions: { | ||
}; | ||
readonly Backspace: { | ||
readonly keyCode: 8; | ||
readonly code: "Backspace"; | ||
readonly key: "Backspace"; | ||
}; | ||
readonly Tab: { | ||
@@ -79,0 +84,0 @@ readonly keyCode: 9; |
@@ -22,2 +22,3 @@ "use strict"; | ||
'{backspace}': { 'keyCode': 8, 'code': 'Backspace', 'key': 'Backspace' }, | ||
'Backspace': { 'keyCode': 8, 'code': 'Backspace', 'key': 'Backspace' }, | ||
'Tab': { 'keyCode': 9, 'code': 'Tab', 'key': 'Tab' }, | ||
@@ -24,0 +25,0 @@ 'Numpad5': { 'keyCode': 12, 'shiftKeyCode': 101, 'key': 'Clear', 'code': 'Numpad5', 'shiftKey': '5', 'location': 3 }, |
{ | ||
"name": "cypress-real-events", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Real native events for cypress. Dispatched via CDP.", | ||
@@ -5,0 +5,0 @@ "author": "Dmitriy Kovalenko", |
@@ -11,2 +11,3 @@ "use strict"; | ||
const mouseUp_1 = require("./commands/mouseUp"); | ||
const mouseMove_1 = require("./commands/mouseMove"); | ||
// TODO fix this unsafe convertions. This happens because cypress does not allow anymore to return Promise for types, but allows for command which is pretty useful for current implementation. | ||
@@ -21,1 +22,2 @@ Cypress.Commands.add("realClick", { prevSubject: true }, realClick_1.realClick); | ||
Cypress.Commands.add("realMouseUp", { prevSubject: true }, mouseUp_1.realMouseUp); | ||
Cypress.Commands.add("realMouseMove", { prevSubject: true }, mouseMove_1.realMouseMove); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99736
30
2694