-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7004 from sainthkh/decaff-driver-0
Decaff driver part 0
- Loading branch information
Showing
22 changed files
with
1,274 additions
and
1,051 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Promise = require('bluebird') | ||
|
||
Promise.config({ | ||
cancellation: true, | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}, | ||
}) | ||
} |
Oops, something went wrong.
28b9a5d
There was a problem hiding this comment.
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.28b9a5d
There was a problem hiding this comment.
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
):In PowerShell:
In Git Bash:
Using
cross-env
:If the above commands do not work for you, you can also try using
cross-env
:28b9a5d
There was a problem hiding this comment.
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
):In PowerShell:
In Git Bash:
Using
cross-env
:If the above commands do not work for you, you can also try using
cross-env
:28b9a5d
There was a problem hiding this comment.
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.