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 · 4 comments · Fixed by #6121 · May be fixed by qsays/grafana#1
Closed

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

reuxr opened this issue Dec 27, 2019 · 4 comments · Fixed by #6121 · May be fixed by qsays/grafana#1
Assignees
Labels
topic: cy.type ⌨️ type: regression v3.7.0 🐛

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

@kuceb kuceb self-assigned this Dec 28, 2019
@cypress-bot cypress-bot bot added the stage: ready for work label Dec 30, 2019
@jennifer-shehane
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

@jennifer-shehane jennifer-shehane added type: regression v3.7.0 🐛 labels Dec 30, 2019
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
@cypress-bot cypress-bot bot added stage: work in progress and removed stage: ready for work labels Jan 8, 2020
@avallete
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 cypress-bot bot added stage: pending release and removed stage: work in progress labels Jan 10, 2020
@cypress-bot
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.

@jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Mar 3, 2020

Released in 3.8.2

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Mar 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: cy.type ⌨️ type: regression v3.7.0 🐛
Projects
None yet
4 participants