Skip to content

Commit

Permalink
Merge pull request #7004 from sainthkh/decaff-driver-0
Browse files Browse the repository at this point in the history
Decaff driver part 0
  • Loading branch information
jennifer-shehane authored Apr 16, 2020
2 parents 5a64934 + 233bb94 commit 28b9a5d
Show file tree
Hide file tree
Showing 22 changed files with 1,274 additions and 1,051 deletions.
5 changes: 0 additions & 5 deletions packages/driver/src/config/bluebird.coffee

This file was deleted.

5 changes: 5 additions & 0 deletions packages/driver/src/config/bluebird.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Promise = require('bluebird')

Promise.config({
cancellation: true,
})
19 changes: 0 additions & 19 deletions packages/driver/src/config/moment.coffee

This file was deleted.

19 changes: 19 additions & 0 deletions packages/driver/src/config/moment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const moment = require('moment')

moment.updateLocale('en', {
relativeTime: {
future: 'in %s',
past: '%s ago',
s: 's',
m: '1m',
mm: '%dm',
h: '1h',
hh: '%dh',
d: '1d',
dd: '%dd',
M: '1mo',
MM: '%dmo',
y: '1y',
yy: '%dy',
},
})
145 changes: 0 additions & 145 deletions packages/driver/src/cy/commands/actions/check.coffee

This file was deleted.

168 changes: 168 additions & 0 deletions packages/driver/src/cy/commands/actions/check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
const _ = require('lodash')
const Promise = require('bluebird')

const $dom = require('../../../dom')
const $utils = require('../../../cypress/utils')
const $errUtils = require('../../../cypress/error_utils')
const $elements = require('../../../dom/elements')

const checkOrUncheck = (Cypress, cy, type, subject, values = [], userOptions = {}) => {
// we're not handling conversion of values to strings
// in case we've received numbers

// if we're not an array but we are an object
// reassign userOptions to values
if (!_.isArray(values) && _.isObject(values)) {
userOptions = values
values = []
} else {
// make sure we're an array of values
values = [].concat(values)
}

// keep an array of subjects which
// are potentially reduced down
// to new filtered subjects
const matchingElements = []

const options = _.defaults({}, userOptions, {
$el: subject,
log: true,
force: false,
})

const isNoop = ($el) => {
return type === 'check'
? $el.prop('checked')
: !$el.prop('checked')
}

const isAcceptableElement = ($el) => {
return type === 'check'
? $el.is(':checkbox,:radio')
: $el.is(':checkbox')
}

// does our el have a value
// in the values array?
// or values array is empty
const elHasMatchingValue = ($el) => {
const value = $elements.getNativeProp($el.get(0), 'value')

return (values.length === 0) || values.includes(value)
}

// blow up if any member of the subject
// isnt a checkbox or radio
const checkOrUncheckEl = (el) => {
const $el = $dom.wrap(el)

if (!isAcceptableElement($el)) {
const node = $dom.stringify($el)
const word = $utils.plural(options.$el, 'contains', 'is')
const phrase = type === 'check' ? ' and `:radio`' : ''

$errUtils.throwErrByPath('check_uncheck.invalid_element', {
onFail: options._log,
args: { node, word, phrase, cmd: type },
})
}

const isElActionable = elHasMatchingValue($el)

if (isElActionable) {
matchingElements.push(el)
}

const consoleProps = {
'Applied To': $dom.getElements($el),
'Elements': $el.length,
}

if (options.log && isElActionable) {
// figure out the userOptions which actually change the behavior of clicks
const deltaOptions = $utils.filterOutOptions(options)

options._log = Cypress.log({
message: deltaOptions,
$el,
consoleProps () {
return _.extend(consoleProps, {
Options: deltaOptions,
})
},
})

options._log.snapshot('before', { next: 'after' })

// if the checkbox was already checked
// then notify the user of this note
// and bail
if (isNoop($el)) {
if (!options.force) {
// still ensure visibility even if the command is noop
cy.ensureVisibility($el, options._log)
}

if (options._log) {
const inputType = $el.is(':radio') ? 'radio' : 'checkbox'

consoleProps.Note = `This ${inputType} was already ${type}ed. No operation took place.`
options._log.snapshot().end()
}

return null
}
}

// if we didnt pass in any values or our
// el's value is in the array then check it
if (isElActionable) {
return cy.now('click', $el, {
$el,
log: false,
verify: false,
_log: options._log,
force: options.force,
timeout: options.timeout,
interval: options.interval,
}).then(() => {
if (options._log) {
options._log.snapshot().end()
}

return null
})
}
}

// return our original subject when our promise resolves
return Promise
.resolve(options.$el.toArray())
.each(checkOrUncheckEl)
.then(() => {
// filter down our $el to the
// matching elements
options.$el = options.$el.filter(matchingElements)

const verifyAssertions = () => {
return cy.verifyUpcomingAssertions(options.$el, options, {
onRetry: verifyAssertions,
})
}

return verifyAssertions()
})
}

module.exports = function (Commands, Cypress, cy) {
return Commands.addAll({ prevSubject: 'element' }, {
check (subject, values, options) {
return checkOrUncheck.call(this, Cypress, cy, 'check', subject, values, options)
},

uncheck (subject, values, options) {
return checkOrUncheck.call(this, Cypress, cy, 'uncheck', subject, values, options)
},
})
}
Loading

4 comments on commit 28b9a5d

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 28b9a5d Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.4.1/linux-x64/circle-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-301894/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.4.1/circle-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-301886/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 28b9a5d Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.4.1/win32-ia32/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.4.1/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.4.1/win32-ia32/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.4.1/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.4.1/win32-ia32/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.4.1/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.4.1/win32-ia32/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.4.1/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 28b9a5d Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

Instructions are included below, depending on the shell you are using.

In Command Prompt (cmd.exe):

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.4.1/win32-x64/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.4.1/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.tgz

In PowerShell:

$env:CYPRESS_INSTALL_BINARY = https://cdn.cypress.io/beta/binary/4.4.1/win32-x64/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.4.1/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.tgz

In Git Bash:

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.4.1/win32-x64/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.4.1/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.tgz

Using cross-env:

If the above commands do not work for you, you can also try using cross-env:

npm i -g cross-env
cross-env CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.4.1/win32-x64/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.zip npm install https://cdn.cypress.io/beta/npm/4.4.1/appveyor-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-32218089/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 28b9a5d Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

export CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/4.4.1/darwin-x64/circle-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-301953/cypress.zip
npm install https://cdn.cypress.io/beta/npm/4.4.1/circle-develop-28b9a5d5d38d924f652408d3b057e1e4f9f42a9a-301904/cypress.tgz

Please sign in to comment.