Skip to content

Commit

Permalink
Renames: issue 2957 (cypress-io#4879)
Browse files Browse the repository at this point in the history
* [rename only] {keyboard,mouse}.js

* refactor keyboard/mouse into cy/

* fix cy.type for refactor

* fix e2e test error

* commands now recieve devices as separate prop

* add .history to .estlintignore

* fix linting errors

* remove passing log and devices to commands, pull devices off of cy

* fix commands.coffee


Co-authored-by: Brian Mann <brian.mann86@gmail.com>
  • Loading branch information
kuceb and brian-mann committed Aug 6, 2019
1 parent 15bf98f commit a038e7f
Show file tree
Hide file tree
Showing 11 changed files with 751 additions and 745 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ packages/launcher/lib/**/*.js
**/package-lock.json
**/tsconfig.json
**/.vscode
**/.history
11 changes: 5 additions & 6 deletions packages/driver/src/cy/commands/actions/click.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
const _ = require('lodash')
const Promise = require('bluebird')

const $Mouse = require('../../../cy/mouse')

const $dom = require('../../../dom')
const $utils = require('../../../cypress/utils')
const $elements = require('../../../dom/elements')
const $selection = require('../../../dom/selection')
const $actionability = require('../../actionability')

module.exports = (Commands, Cypress, cy, state, config) => {
const { mouse } = cy.devices

return Commands.addAll({ prevSubject: 'element' }, {
click (subject, positionOrX, y, options = {}) {
//# TODO handle pointer-events: none
Expand Down Expand Up @@ -74,11 +73,11 @@ module.exports = (Commands, Cypress, cy, state, config) => {
//# https://www.w3.org/TR/uievents/#event-type-click (scroll up slightly)

if ($dom.isAttached($elToClick)) {
domEvents.mouseUp = $Mouse.mouseUp($elToClick, fromViewport)
domEvents.mouseUp = mouse.mouseUp($elToClick, fromViewport)
}

if ($dom.isAttached($elToClick)) {
domEvents.click = $Mouse.click($elToClick, fromViewport)
domEvents.click = mouse.click($elToClick, fromViewport)
}

if (options._log) {
Expand Down Expand Up @@ -167,7 +166,7 @@ module.exports = (Commands, Cypress, cy, state, config) => {

el = $elToClick.get(0)

domEvents.mouseDown = $Mouse.mouseDown($elToClick, coords.fromViewport)
domEvents.mouseDown = mouse.mouseDown($elToClick, coords.fromViewport)

//# if mousedown was canceled then or caused
//# our element to be removed from the DOM
Expand Down
9 changes: 3 additions & 6 deletions packages/driver/src/cy/commands/actions/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const moment = require('moment')
const $dom = require('../../../dom')
const $elements = require('../../../dom/elements')
const $selection = require('../../../dom/selection')
const $Keyboard = require('../../../cy/keyboard')
const $utils = require('../../../cypress/utils')
const $actionability = require('../../actionability')

Expand All @@ -17,9 +16,7 @@ const weekRegex = /^\d{4}-W(0[1-9]|[1-4]\d|5[0-3])$/
const timeRegex = /^([0-1]\d|2[0-3]):[0-5]\d(:[0-5]\d)?(\.[0-9]{1,3})?$/

module.exports = function (Commands, Cypress, cy, state, config) {
Cypress.on('test:before:run', () => {
return $Keyboard.resetModifiers(state('document'), state('window'))
})
const { keyboard } = cy.devices

return Commands.addAll({ prevSubject: 'element' }, {
type (subject, chars, options = {}) {
Expand Down Expand Up @@ -54,7 +51,7 @@ module.exports = function (Commands, Cypress, cy, state, config) {
let obj

table[id] = (obj = {})
const modifiers = $Keyboard.activeModifiers()
const modifiers = keyboard.getActiveModifiersArray()

if (modifiers.length) {
obj.modifiers = modifiers.join(', ')
Expand Down Expand Up @@ -300,7 +297,7 @@ module.exports = function (Commands, Cypress, cy, state, config) {
const isContentEditable = $elements.isContentEditable(options.$el.get(0))
const isTextarea = $elements.isTextarea(options.$el.get(0))

return $Keyboard.type({
return keyboard.type({
$el: options.$el,
chars: options.chars,
delay: options.delay,
Expand Down
Loading

0 comments on commit a038e7f

Please sign in to comment.