cypress-real-events
Advanced tools
Comparing version 1.8.1 to 1.9.1
@@ -22,4 +22,21 @@ /// <reference types="cypress" /> | ||
button?: keyof typeof mouseButtonNumbers; | ||
/** X coordinate to click, relative to the Element. Overrides `position`. | ||
* @example | ||
* cy.get("canvas").realMouseDown({ x: 100, y: 115 }) | ||
* cy.get("body").realMouseDown({ x: 11, y: 12 }) // global click by coordinates | ||
*/ | ||
x?: number; | ||
/** Y coordinate to click, relative to the Element. Overrides `position`. | ||
* @example | ||
* cy.get("canvas").realMouseDown({ x: 100, y: 115 }) | ||
* cy.get("body").realMouseDown({ x: 11, y: 12 }) // global click by coordinates | ||
*/ | ||
y?: number; | ||
/** | ||
* Indicates whether the shift key was pressed or not when an event occurred | ||
* @example cy.realMouseDown({ shiftKey: true }); | ||
*/ | ||
shiftKey?: boolean; | ||
} | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
export declare function realMouseDown(subject: JQuery, options?: realMouseDownOptions): Promise<JQuery<HTMLElement>>; |
@@ -16,2 +16,3 @@ "use strict"; | ||
const mouseButtonNumbers_1 = require("../mouseButtonNumbers"); | ||
const keyToModifierBitMap_1 = require("../keyToModifierBitMap"); | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
@@ -21,3 +22,4 @@ function realMouseDown(subject, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { x, y } = (0, getCypressElementCoordinates_1.getCypressElementCoordinates)(subject, options.position, options.scrollBehavior); | ||
const position = options.x && options.y ? { x: options.x, y: options.y } : options.position; | ||
const { x, y } = (0, getCypressElementCoordinates_1.getCypressElementCoordinates)(subject, position, options.scrollBehavior); | ||
const log = Cypress.log({ | ||
@@ -40,2 +42,3 @@ $el: subject, | ||
button: (_c = options.button) !== null && _c !== void 0 ? _c : "left", | ||
modifiers: options.shiftKey ? keyToModifierBitMap_1.keyToModifierBitMap.Shift : 0, | ||
}); | ||
@@ -42,0 +45,0 @@ log.snapshot("after").end(); |
@@ -13,7 +13,12 @@ /// <reference types="cypress" /> | ||
* Controls how the page is scrolled to bring the subject into view, if needed. | ||
* @example cy.realClick({ scrollBehavior: "top" }); | ||
* @example cy.realMouseMove({ scrollBehavior: "top" }); | ||
*/ | ||
scrollBehavior?: ScrollBehaviorOptions; | ||
/** | ||
* Indicates whether the shift key was pressed or not when an event occurred | ||
* @example cy.realMouseMove({ shiftKey: true }); | ||
*/ | ||
shiftKey?: boolean; | ||
} | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
export declare function realMouseMove(subject: JQuery, x: number, y: number, options?: RealMouseMoveOptions): Promise<JQuery<HTMLElement>>; |
@@ -15,2 +15,3 @@ "use strict"; | ||
const getCypressElementCoordinates_1 = require("../getCypressElementCoordinates"); | ||
const keyToModifierBitMap_1 = require("../keyToModifierBitMap"); | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
@@ -34,2 +35,3 @@ function realMouseMove(subject, x, y, options = {}) { | ||
y: y * basePosition.frameScale + basePosition.y, | ||
modifiers: options.shiftKey ? keyToModifierBitMap_1.keyToModifierBitMap.Shift : 0, | ||
}); | ||
@@ -36,0 +38,0 @@ log.snapshot("after").end(); |
@@ -22,4 +22,21 @@ /// <reference types="cypress" /> | ||
button?: keyof typeof mouseButtonNumbers; | ||
/** X coordinate to click, relative to the Element. Overrides `position`. | ||
* @example | ||
* cy.get("canvas").realMouseUp({ x: 100, y: 115 }) | ||
* cy.get("body").realMouseUp({ x: 11, y: 12 }) // global click by coordinates | ||
*/ | ||
x?: number; | ||
/** Y coordinate to click, relative to the Element. Overrides `position`. | ||
* @example | ||
* cy.get("canvas").realMouseUp({ x: 100, y: 115 }) | ||
* cy.get("body").realMouseUp({ x: 11, y: 12 }) // global click by coordinates | ||
*/ | ||
y?: number; | ||
/** | ||
* Indicates whether the shift key was pressed or not when an event occurred | ||
* @example cy.realMouseUp({ shiftKey: true }); | ||
*/ | ||
shiftKey?: boolean; | ||
} | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
export declare function realMouseUp(subject: JQuery, options?: realMouseUpOptions): Promise<JQuery<HTMLElement>>; |
@@ -16,2 +16,3 @@ "use strict"; | ||
const mouseButtonNumbers_1 = require("../mouseButtonNumbers"); | ||
const keyToModifierBitMap_1 = require("../keyToModifierBitMap"); | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
@@ -21,3 +22,4 @@ function realMouseUp(subject, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { x, y } = (0, getCypressElementCoordinates_1.getCypressElementCoordinates)(subject, options.position, options.scrollBehavior); | ||
const position = options.x && options.y ? { x: options.x, y: options.y } : options.position; | ||
const { x, y } = (0, getCypressElementCoordinates_1.getCypressElementCoordinates)(subject, position, options.scrollBehavior); | ||
const log = Cypress.log({ | ||
@@ -40,2 +42,3 @@ $el: subject, | ||
button: (_c = options.button) !== null && _c !== void 0 ? _c : "left", | ||
modifiers: options.shiftKey ? keyToModifierBitMap_1.keyToModifierBitMap.Shift : 0, | ||
}); | ||
@@ -42,0 +45,0 @@ log.snapshot("after").end(); |
@@ -36,4 +36,9 @@ /// <reference types="cypress" /> | ||
clickCount?: number; | ||
/** | ||
* Indicates whether the shift key was pressed or not when an event occurred | ||
* @example cy.realClick({ shiftKey: true }); | ||
*/ | ||
shiftKey?: boolean; | ||
} | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
export declare function realClick(subject: JQuery, options?: RealClickOptions): Promise<JQuery<HTMLElement>>; |
@@ -16,2 +16,3 @@ "use strict"; | ||
const mouseButtonNumbers_1 = require("../mouseButtonNumbers"); | ||
const keyToModifierBitMap_1 = require("../keyToModifierBitMap"); | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
@@ -21,6 +22,3 @@ function realClick(subject, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// prettier-ignore | ||
const position = options.x && options.y | ||
? { x: options.x, y: options.y } | ||
: options.position; | ||
const position = options.x && options.y ? { x: options.x, y: options.y } : options.position; | ||
const { x, y } = (0, getCypressElementCoordinates_1.getCypressElementCoordinates)(subject, position, options.scrollBehavior); | ||
@@ -46,2 +44,3 @@ const log = Cypress.log({ | ||
button: (_c = options.button) !== null && _c !== void 0 ? _c : "left", | ||
modifiers: options.shiftKey ? keyToModifierBitMap_1.keyToModifierBitMap.Shift : 0, | ||
}); | ||
@@ -56,2 +55,3 @@ yield (0, fireCdpCommand_1.fireCdpCommand)("Input.dispatchMouseEvent", { | ||
button: (_f = options.button) !== null && _f !== void 0 ? _f : "left", | ||
modifiers: options.shiftKey ? keyToModifierBitMap_1.keyToModifierBitMap.Shift : 0, | ||
}); | ||
@@ -58,0 +58,0 @@ } |
@@ -19,4 +19,9 @@ /// <reference types="cypress" /> | ||
scrollBehavior?: ScrollBehaviorOptions; | ||
/** | ||
* Indicates whether the shift key was pressed or not when an event occurred | ||
* @example cy.realHover({ shiftKey: true }); | ||
*/ | ||
shiftKey?: boolean; | ||
} | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
export declare function realHover(subject: JQuery, options?: RealHoverOptions): Promise<JQuery<HTMLElement>>; |
@@ -15,2 +15,3 @@ "use strict"; | ||
const getCypressElementCoordinates_1 = require("../getCypressElementCoordinates"); | ||
const keyToModifierBitMap_1 = require("../keyToModifierBitMap"); | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
@@ -35,2 +36,3 @@ function realHover(subject, options = {}) { | ||
pointerType: (_a = options.pointer) !== null && _a !== void 0 ? _a : "mouse", | ||
modifiers: options.shiftKey ? keyToModifierBitMap_1.keyToModifierBitMap.Shift : 0, | ||
}); | ||
@@ -37,0 +39,0 @@ log.snapshot().end(); |
@@ -15,2 +15,3 @@ "use strict"; | ||
const keyCodeDefinitions_1 = require("../keyCodeDefinitions"); | ||
const keyToModifierBitMap_1 = require("../keyToModifierBitMap"); | ||
function getKeyDefinition(key) { | ||
@@ -34,8 +35,2 @@ var _a, _b, _c, _d; | ||
} | ||
const keyToModifierBitMap = { | ||
Alt: 1, | ||
Control: 2, | ||
Meta: 4, | ||
Shift: 8, | ||
}; | ||
/** @ignore this, update documentation for this function at index.d.ts */ | ||
@@ -59,3 +54,3 @@ function realPress(keyOrShortcut, options = {}) { | ||
for (const key of keyDefinitions) { | ||
modifiers |= (_b = keyToModifierBitMap[key.key]) !== null && _b !== void 0 ? _b : 0; | ||
modifiers |= (_b = keyToModifierBitMap_1.keyToModifierBitMap[key.key]) !== null && _b !== void 0 ? _b : 0; | ||
yield (0, fireCdpCommand_1.fireCdpCommand)("Input.dispatchKeyEvent", Object.assign({ type: key.text ? "keyDown" : "rawKeyDown", modifiers }, key)); | ||
@@ -62,0 +57,0 @@ if (key.code === "Enter") { |
/// <reference types="cypress" /> | ||
/// <reference types="cypress" /> | ||
import { Position } from '../getCypressElementCoordinates'; | ||
import { Position } from "../getCypressElementCoordinates"; | ||
export interface RealTouchOptions { | ||
@@ -5,0 +5,0 @@ /** |
@@ -17,3 +17,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const position = typeof options.x === 'number' || typeof options.y === 'number' | ||
const position = typeof options.x === "number" || typeof options.y === "number" | ||
? { x: options.x || 0, y: options.y || 0 } | ||
@@ -23,4 +23,4 @@ : options.position; | ||
const elementPoint = { x: elementCoordinates.x, y: elementCoordinates.y }; | ||
const radiusX = (options.radiusX || options.radius || 1); | ||
const radiusY = (options.radiusY || options.radius || 1); | ||
const radiusX = options.radiusX || options.radius || 1; | ||
const radiusY = options.radiusY || options.radius || 1; | ||
const log = Cypress.log({ | ||
@@ -35,4 +35,4 @@ $el: subject, | ||
y: radiusY, | ||
} | ||
}) | ||
}, | ||
}), | ||
}); | ||
@@ -39,0 +39,0 @@ log.snapshot("before"); |
@@ -98,3 +98,3 @@ "use strict"; | ||
height: height * frameScale, | ||
frameScale: frameScale | ||
frameScale: frameScale, | ||
}; | ||
@@ -125,5 +125,5 @@ } | ||
y: posY, | ||
frameScale: frameScale | ||
frameScale: frameScale, | ||
}; | ||
} | ||
exports.getCypressElementCoordinates = getCypressElementCoordinates; |
@@ -67,3 +67,5 @@ type NormalizeCypressCommand<TFun> = TFun extends ( | ||
*/ | ||
realPress: NormalizeNonSubjectCypressCommand<typeof import("./commands/realPress").realPress>; | ||
realPress: NormalizeNonSubjectCypressCommand< | ||
typeof import("./commands/realPress").realPress | ||
>; | ||
/** | ||
@@ -78,3 +80,5 @@ * Runs a sequence of native press event (via cy.press) | ||
*/ | ||
realType: NormalizeNonSubjectCypressCommand<typeof import("./commands/realType").realType>; | ||
realType: NormalizeNonSubjectCypressCommand< | ||
typeof import("./commands/realType").realType | ||
>; | ||
/** | ||
@@ -99,8 +103,8 @@ * Fires native system mousePressed event. | ||
/** | ||
* 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() | ||
*/ | ||
* 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< | ||
@@ -107,0 +111,0 @@ typeof import("./commands/mouseMove").realMouseMove |
@@ -5,8 +5,8 @@ "use strict"; | ||
exports.mouseButtonNumbers = { | ||
"none": 0, | ||
"left": 1, | ||
"right": 2, | ||
"middle": 4, | ||
"back": 8, | ||
"forward": 16, | ||
none: 0, | ||
left: 1, | ||
right: 2, | ||
middle: 4, | ||
back: 8, | ||
forward: 16, | ||
}; |
{ | ||
"name": "cypress-real-events", | ||
"version": "1.8.1", | ||
"version": "1.9.1", | ||
"description": "Real native events for cypress. Dispatched via CDP.", | ||
@@ -11,2 +11,4 @@ "author": "Dmitriy Kovalenko", | ||
"release": "yarn build && yarn version && node scripts/release.js && yarn publish dist", | ||
"format": "yarn prettier --write './{src,cypress}/**/*.ts'", | ||
"format-check": "yarn prettier --check './{src,cypress}/**/*.ts'", | ||
"semantic-release": "semantic-release" | ||
@@ -27,5 +29,5 @@ }, | ||
"semantic-release": "^17.3.0", | ||
"typedoc": "^0.23.22", | ||
"typedoc": "^0.24.8", | ||
"typedoc-plugin-markdown": "^3.14.0", | ||
"typescript": "^4.8.4" | ||
"typescript": "^5.1.3" | ||
}, | ||
@@ -41,4 +43,7 @@ "repository": { | ||
}, | ||
"dependencies": { | ||
"prettier": "^3.0.0" | ||
}, | ||
"main": "./support.js", | ||
"typings": "./index.d.ts" | ||
} | ||
} |
108295
34
2868
2
+ Addedprettier@^3.0.0
+ Addedcall-bound@1.0.4(transitive)
+ Addedprettier@3.5.3(transitive)
- Removedcall-bound@1.0.3(transitive)