rename cy.type disableSpecialChars options (#4761)

* Revert "Add option to ignore special character sequences to cy.type (#4744)"

This reverts commit 8153c6ec96.

* rename disableSpecialCharSequences

* update err msg pt 2

* update err msg pt 3

* update parseSpecialChar booleon - default is TRUE

* remove trailing whitespace


Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
This commit is contained in:
Ben Kucera
2019-07-24 15:50:52 -04:00
committed by Brian Mann
parent a6cf9d5a13
commit 50a285a980
5 changed files with 23 additions and 12 deletions
+4 -4
View File
@@ -2255,12 +2255,12 @@ declare namespace Cypress {
*/
delay: number
/**
* Disable typing special characters for strings surrounded by `{}`,
* such as `{esc}`, and type the literal characters instead
* Parse special characters for strings surrounded by `{}`,
* such as `{esc}`. Set to `false` to type the literal characters instead
*
* @default false
* @default true
*/
disableSpecialCharSequences: boolean
parseSpecialCharSequences: boolean
/**
* Forces the action, disables waiting for actionability
*
@@ -32,7 +32,7 @@ module.exports = (Commands, Cypress, cy, state, config) ->
force: false
delay: 10
release: true
disableSpecialCharSequences: false
parseSpecialCharSequences: true
waitForAnimations: config("waitForAnimations")
animationDistanceThreshold: config("animationDistanceThreshold")
})
@@ -246,7 +246,7 @@ module.exports = (Commands, Cypress, cy, state, config) ->
chars: options.chars
delay: options.delay
release: options.release
disableSpecialCharSequences: options.disableSpecialCharSequences
parseSpecialCharSequences: options.parseSpecialCharSequences
window: win
updateValue: (el, key) ->
@@ -903,7 +903,14 @@ module.exports = {
type:
empty_string: "#{cmd('type')} cannot accept an empty String. You need to actually type something."
invalid: "Special character sequence: '{{chars}}' is not recognized. Available sequences are: {{allChars}}"
readonly: "#{cmd('type')} cannot type into an element with a 'readonly' attribute. The element typed into was: {{node}}"
invalid: """
Special character sequence: '{{chars}}' is not recognized. Available sequences are: {{allChars}}
If you want to skip parsing special character sequences and type the text exactly as written, pass the option: {parseSpecialCharSequences: false}
https://on.cypress.io/type
"""
invalid_date: "Typing into a date input with #{cmd('type')} requires a valid date with the format 'yyyy-MM-dd'. You passed: {{chars}}"
invalid_month: "Typing into a month input with #{cmd('type')} requires a valid month with the format 'yyyy-MM'. You passed: {{chars}}"
invalid_week: "Typing into a week input with #{cmd('type')} requires a valid week with the format 'yyyy-Www', where W is the literal character 'W' and ww is the week number (00-53). You passed: {{chars}}"
+2 -2
View File
@@ -338,7 +338,7 @@ const $Keyboard = {
type (options = {}) {
_.defaults(options, {
delay: 10,
disableSpecialCharSequences: false,
parseSpecialCharSequences: true,
onEvent () {},
onBeforeEvent () {},
onBeforeType () {},
@@ -352,7 +352,7 @@ const $Keyboard = {
let keys = options.chars
if (!options.disableSpecialCharSequences) {
if (options.parseSpecialCharSequences) {
keys = options.chars.split(charsBetweenCurlyBracesRe).map((chars) => {
if (charsBetweenCurlyBracesRe.test(chars)) {
//# allow special chars and modifiers to be case-insensitive
@@ -1529,10 +1529,10 @@ describe('src/cy/commands/actions/type', () => {
describe('specialChars', () => {
context('disableSpecialCharSequences: true', () => {
context('parseSpecialCharSequences: false', () => {
it('types special character sequences literally', (done) => {
cy.get(':text:first').invoke('val', 'foo')
.type('{{}{backspace}', { disableSpecialCharSequences: true }).then(($input) => {
.type('{{}{backspace}', { parseSpecialCharSequences: false }).then(($input) => {
expect($input).to.have.value('foo{{}{backspace}')
done()
@@ -4340,7 +4340,11 @@ describe('src/cy/commands/actions/type', () => {
const allChars = _.keys(Keyboard.specialChars).concat(_.keys(Keyboard.modifierChars)).join(', ')
expect(err.message).to.eq(`Special character sequence: '{bar}' is not recognized. Available sequences are: ${allChars}`)
expect(err.message).to.eq(`Special character sequence: '{bar}' is not recognized. Available sequences are: ${allChars}
If you want to skip parsing special character sequences and type the text exactly as written, pass the option: {parseSpecialCharSequences: false}
https://on.cypress.io/type`)
done()
})