Skip to content

Commit

Permalink
fix(commands.type): Fix the .type command on an input of type n… (#6121)
Browse files Browse the repository at this point in the history
Fix edge case introduced into #6033 about typing invalid number

Fixes #6055

Co-authored-by: Jennifer Shehane <[email protected]>
  • Loading branch information
avallete and jennifer-shehane committed Jan 10, 2020
1 parent 957d76a commit a76b3b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/driver/src/cy/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ const shouldUpdateValue = (el: HTMLElement, key: KeyDetails, options) => {
debug('skipping inserting value since number input would be invalid', key.text, potentialValue)
// when typing in a number input, only certain whitelisted chars will insert text
if (!key.text.match(isValidNumberInputChar)) {
options.prevVal = ''
// https://github.com/cypress-io/cypress/issues/6055
// Should not remove old valid values when a new one is not a valid number char, just dismiss it with return

return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,13 @@ describe('src/cy/commands/actions/type', () => {
.should('have.value', '-123.12')
})

// https://github.com/cypress-io/cypress/issues/6055
it('can type negative numbers and dismiss invalid characters', () => {
cy.get('#number-without-value')
.type('-a42')
.should('have.value', '-42')
})

it('can type {del}', () => {
cy.get('#number-with-value')
.type('{selectAll}{del}')
Expand Down

3 comments on commit a76b3b6

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a76b3b6 Jan 10, 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.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.8.2/win32-x64/appveyor-develop-a76b3b655830392d409a4d322295ee5440d1cb0e-30016893/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.8.2/win32-x64/appveyor-develop-a76b3b655830392d409a4d322295ee5440d1cb0e-30016893/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a76b3b6 Jan 10, 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/3.8.2/linux-x64/circle-develop-a76b3b655830392d409a4d322295ee5440d1cb0e-229314/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.2/circle-develop-a76b3b655830392d409a4d322295ee5440d1cb0e-229263/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a76b3b6 Jan 10, 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/3.8.2/darwin-x64/circle-develop-a76b3b655830392d409a4d322295ee5440d1cb0e-229335/cypress.zip
npm install https://cdn.cypress.io/beta/npm/3.8.2/circle-develop-a76b3b655830392d409a4d322295ee5440d1cb0e-229318/cypress.tgz

Please sign in to comment.