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

{enter} on input type=number leads to invalid input (3.8.0 regression) #5968

Closed
Narretz opened this issue Dec 16, 2019 · 8 comments · Fixed by #6033 · May be fixed by qsays/grafana#1
Closed

{enter} on input type=number leads to invalid input (3.8.0 regression) #5968

Narretz opened this issue Dec 16, 2019 · 8 comments · Fixed by #6033 · May be fixed by qsays/grafana#1
Assignees
Labels
topic: cy.type ⌨️ type: regression A bug that didn't appear until a specific Cy version release v3.8.0 🐛 Issue present since 3.8.0

Comments

@Narretz
Copy link
Contributor

Narretz commented Dec 16, 2019

Current behavior:

when you type a number in an number input and then type enter, the input becomes empty and the console logs an error:

cypress_runner.js:107262 The specified value "12\n" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)?

You can see that the {enter} adds \n to the input value.

Desired behavior:

It should set the value without \n

Steps to reproduce: (app code and test code)

html:

<input type="number" id="input" />

spec code:

cy.get('#input')
  .type('2')
  .type('{enter}')

Versions

Cypress 3.8.0
edit: Chrome 79 with cypress run

Possibly related to #5854

@jennifer-shehane
Copy link
Member

@Narretz I'm not able to recreate this from the code provided in 3.8.0 in Electron 78 or Chrome 79. Can you double check the provided code exactly and see if the error occurs for you? Thanks.

The code I ran with no other settings:

index.html

<!DOCTYPE html>
<html>
<body>
  <input type="number" id="input" />
</body>
</html>

spec.js

it('types', function () {
  cy.visit('index.html')
  cy.get('#input')
    .type('2')
    .type('{enter}')
})

Screen Shot 2019-12-17 at 4 10 42 PM

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Dec 17, 2019
@Narretz
Copy link
Contributor Author

Narretz commented Dec 17, 2019

Hi @jennifer-shehane thanks for the quick response. Since the screenshot seems to be showing the end of the test run, then it's also showing the wrong result I mentioned - the input shouldn't be empty, it should still have the 2 in it. Did you check the console for the message / warning?

(There will be no error in the test log, so the result being "green" is expected)
(Forgot to mention that I tested this with cypress run and Chrome 79)

@Narretz
Copy link
Contributor Author

Narretz commented Dec 19, 2019

@jennifer-shehane do you need anything else for this issue?
As I wrote in response to you, your screenshot already shows the problem.

@jennifer-shehane
Copy link
Member

@Narretz Right, sorry. It's helpful to provide the incorrect failing test case. So, the assertion below incorrectly fails.

I do see the message in the console. I misread and thought that was an error throwing in the Test Runner directly.

<!DOCTYPE html>
<html>
<body>
  <input type="number" id="input" />
</body>
</html>
it('types', function () {
  cy.visit('index.html')
  cy.get('#input')
  // doing .type('2{enter}`) causes same error
    .type('2')
    .type('{enter}') 
    .should('have.value', '2')
})

3.7.0

Screen Shot 2019-12-20 at 1 26 45 PM

3.8.0

Screen Shot 2019-12-20 at 1 12 07 PM

2 console table

Screen Shot 2019-12-20 at 1 29 40 PM

{enter} console table

Screen Shot 2019-12-20 at 1 29 01 PM

@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope and removed stage: needs information Not enough info to reproduce the issue labels Dec 20, 2019
@jennifer-shehane jennifer-shehane added type: regression A bug that didn't appear until a specific Cy version release v3.8.0 🐛 Issue present since 3.8.0 labels Dec 20, 2019
@Narretz
Copy link
Contributor Author

Narretz commented Dec 20, 2019

Thanks! Next time I will include a failing test.

@reuxr
Copy link

reuxr commented Dec 23, 2019

I believe I have a similar issue. When typing '0500' or any number with 0 at the start will results in the input only being 0.

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Dec 23, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Dec 23, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 23, 2019

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

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 26, 2019

Released in 3.8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: cy.type ⌨️ type: regression A bug that didn't appear until a specific Cy version release v3.8.0 🐛 Issue present since 3.8.0
Projects
None yet
4 participants