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() negative number into input not working #2173

Closed
mataslib opened this issue Jul 19, 2018 · 8 comments · Fixed by #2016
Closed

.type() negative number into input not working #2173

mataslib opened this issue Jul 19, 2018 · 8 comments · Fixed by #2016
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug
Milestone

Comments

@mataslib
Copy link

Current behavior:

When typing negative number into input with type "number" set, minus is ignored and possitive number is typed instead.

used method: cy.type()

numbertypebug

Desired behavior:

Type negative number.

Steps to reproduce:

html

Versions

Cypress: 3.0.2
Windows 10
Chrome 67

@kuceb
Copy link
Contributor

kuceb commented Jul 19, 2018

Hi, @equistx ,
This issue should be fixed in an upcoming 3.0.3 release, via this PR #2016

@kuceb kuceb added this to the 3.0.3 milestone Jul 19, 2018
@kuceb kuceb self-assigned this Jul 19, 2018
@kuceb kuceb added type: bug pkg/driver This is due to an issue in the packages/driver directory labels Jul 19, 2018
brian-mann pushed a commit that referenced this issue Jul 23, 2018
this grew to a large PR fixing many cy.type issues.

fix #365
fix #420
fix #586 
fix #593 
fix #596 
fix #610 
fix #651
fix #940
fix #1002 
fix #1108
fix #1171
fix #1209 
fix #1234 
fix #1366
fix #1381 
fix #1684 
fix #1686
fix #1926 
fix #2056
fix #2096 
fix #2110 
fix #2173
fix #2187
@jennifer-shehane jennifer-shehane added stage: pending release and removed stage: needs review The PR code is done & tested, needs review stage: needs investigating Someone from Cypress needs to look at this stage: in progress labels Jul 23, 2018
@Fenopiu

This comment has been minimized.

@kuceb
Copy link
Contributor

kuceb commented May 22, 2019

In version 3.3.0 this bug is still on.

@Fenopiu your screenshot and test code don't indicate this has anything to do with failing to type negative numbers

@jennifer-shehane
Copy link
Member

@Fenopiu You likely want to assert on the 'value' inside of the span, not the span itself. Something like.

it("Should be max 10", () => {
  cy.get(".count").invoke('text').then((text) => {
    expect(text).to.be.lessThan(11);
  })
})

@TheBestPessimist
Copy link

TheBestPessimist commented Jul 18, 2019

in v 3.4.0 i can confirm this bug still appears.

See:
0000000333

@kuceb
Copy link
Contributor

kuceb commented Jul 18, 2019

@TheBestPessimist

in v 3.4.0 i can confirm this bug still appears.

0--? That's zero?
0---12345? What?

Please show your Cypress test code or a simple case of a negative number failing

@TheBestPessimist
Copy link

TheBestPessimist commented Jul 19, 2019

Here's the relevant piece of code:

  cy.get('.form-field-MovementQty')
    .find('input')
    .type('{selectall}')
    .type(`-222`)
    .type('{enter}');

Here's a gif showing that instead of -222, cypress types 222 along with the request sent to the backend:
cypress minus bug

Here's the body of the frontend request: [{"op":"replace","path":"MovementQty","value":"222"}], where it should have been "value": "-222".

Here's the html of that element:

<div class="form-group row  form-field-MovementQty">
    <div class="form-control-label col-sm-3" title="Menge eines bewegten Produktes.">Bewegungs-Menge</div>
    <div class="col-sm-9 ">
        <div class="input-body-container"><span></span>
            <div class="input-block input-secondary pulse-off"><input autocomplete="new-password" class="input-field js-input-field" placeholder="none" tabindex="0" title="222" type="number" min="0" step="1" value="222"></div>
        </div>
    </div>
</div>

I have also tried the alternative

  cy.get('.form-field-MovementQty')
    .find('input')
    .type('{selectall}')
    .type(-222) // instead of `-222`
    .type('{enter}');

but that didnt help either.


Here's a gif of me typing a negative number in the same field, along with the request sent to the backend:
e

@kuceb
Copy link
Contributor

kuceb commented Jul 19, 2019

@TheBestPessimist Thanks for this. I see the issue, we don't take into account that the input has a selection. You can workaround this by doing .clear() before .type() for now. I'll open an issue to fix this

Edit: see open issue here #4767

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants