Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.type() does not input a minus operation if a symbol or letter is typed before a number in a number field #6055

Closed
reuxr opened this issue Dec 27, 2019 · 3 comments · Fixed by #6121

Comments

@reuxr
Copy link

@reuxr reuxr commented Dec 27, 2019

Current behavior:

Using cy.get('input').type('-a2') or '-&2' or other invalid symbols outputs "2", whereas manually typing them outputs -2.

Desired behavior:

The code above should output -2 ignoring the invalid symbols.

Steps to reproduce: (app code and test code)

Use the type command to input a minus operation followed by a symbol and then a number e.g. "-a2" or "-&2" into a number field.

Versions

3.8.1

@jennifer-shehane

This comment has been minimized.

Copy link
Member

@jennifer-shehane jennifer-shehane commented Dec 30, 2019

I have confirmed the - character does not type correctly when combined with non-valid characters in a number input.

This bug was introduced in 3.7.0 and not fixed in the 3.8.1 patch #6033

index.html

<!DOCTYPE html>
<html>
<body>
<input type="number">
</body>
</html>
it('types - char', () => {
  cy.visit('index.html')
  cy.get('input').type('-2')
    .should('have.value', '-2') // passes!
})

it('does not type - char', () => {
  cy.visit('index.html')
  cy.get('input').type('-a2')
    .should('have.value', '-2') // fails :(
})

3.7.0

Screen Shot 2019-12-30 at 2 58 57 PM

3.8.0

Screen Shot 2019-12-30 at 2 57 08 PM

3.8.1

Screen Shot 2019-12-30 at 2 55 20 PM

Console Table of Events

Screen Shot 2019-12-30 at 2 56 03 PM

Workaround

Roll back to use Cypress version 3.7.0

avallete added a commit to avallete/cypress that referenced this issue Jan 8, 2020
Fix edge case introduced into cypress-io#6033 about typing invalid number

Fixes cypress-io#6055
@avallete

This comment has been minimized.

Copy link
Contributor

@avallete avallete commented Jan 8, 2020

Hi there !

This issue isn't marked as 'help wanted' but I did had the same problem as the OP.

Since I didn't wanted to roll back on v3.7.0, I did a fix and opened a PR fixing this issue.

jennifer-shehane added a commit that referenced this issue Jan 10, 2020
Fix edge case introduced into #6033 about typing invalid number

Fixes #6055

Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
@cypress-bot

This comment has been minimized.

Copy link

@cypress-bot cypress-bot bot commented Jan 10, 2020

The code for this is done in cypress-io/cypress#6121, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.