Cypress: selectall / unselect regressions in 3.5.0, 3.6

Created on 7 Nov 2019  路  10Comments  路  Source: cypress-io/cypress

Some regressions were introduced in 3.5 in type() behavior when interacting with selection (selectall / unselect).

Current behavior:

The issue happens in a rich text editor where we are making a text bold by triggering:

  • {selectall} to select the typed text
  • {ctrl}B one time to start
  • unselecting by triggering {rightarrow}.
  • {ctrl}B a second time to stop

It seems:

  • the content is not unselected by triggering {rightarrow}.
  • the {ctrl} is ignored, only B is triggered

Steps to reproduce: (app code and test code)

In a rich text editor supporting this command.

  • Type: Hello{selectall}{ctrl}B{rightarrow}{ctrl}B world!
  • Desired behavior < 3.5: Hello World !
  • Current behavior >= 3.5: B World!

_Work in progress, currently trying to generate a minimum reproduction._

Sources

Versions

Introduced in Cypress 3.5, still happening in 3.6. Linux / Mac OS.

pkdriver regression v3.5.0

All 10 comments

Thanks @znarf , I inadvertently introduced a breaking change with 3.5.0, with the decision to _not insert text_ if a non-shift modifier key is held down (what the browser does).

The problem is the cy.type API is a little obtuse and, for example, the ctrl key is not just held down for the next character, but for the entire rest of the typing sequence.

I now realize that this breaks a lot of tests, since users might not write the type string wanting/knowing the modifiers are held down for the entire rest of the type.

I'll open up a PR to revert to pre 3.5.0 behavior

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

Released in 3.6.1.

@Bkucera It's still failing but the behavior is different.

CI run: https://circleci.com/gh/opencollective/opencollective-frontend/55853

  • Type: Hello{selectall}{ctrl}B{rightarrow}{ctrl}B world!
  • Desired behavior < 3.5: Hello World !
  • Older behavior >= 3.5 and < 3.6.1: B World !
  • New behavior >= 3.6.1: HelloB World !

Looks like {ctrl}B is triggered as B. Reopen?

apologies @znarf, Would you happen to know if you're using .preventDefault on the 'B' to prevent it from typing? I am not sure why the B would not be typed prior to 3.5.0 unless that is the case, but I'll check it out.

It would help if you could screenshot the cy.type events table that gets logged to the browser console when you click the command log. Could you provide a screenshot for the event table in <3.5.0 ?

Hi @Bkucera, I'm working with @znarf on Open Collective.

We don't preventDefault in our code, but the library we're using - react-quill - may.

Here's a screenshot of the logs in console:

  • With 3.4.1

image

  • With 3.6.1

image


I've been able to make it work on 3.6.1 by splitting in multiple cy.type:

    cy.get('[data-cy="HTMLEditor"] .ql-editor').type('Hello');
    cy.get('[data-cy="HTMLEditor"] .ql-editor').type('{selectall}');
    cy.get('[data-cy="HTMLEditor"] .ql-editor').type('{ctrl}B');
    cy.get('[data-cy="HTMLEditor"] .ql-editor').type('{rightarrow}');
    cy.get('[data-cy="HTMLEditor"] .ql-editor').type('{ctrl}B');
    cy.get('[data-cy="HTMLEditor"] .ql-editor').type(' world!');

@Betree so in 3.4.1 if you have two of the same modifiers in a key string, we simply ignore the second one, since we treat it as still being held down. In 3.5.0+ we send a second keydown, which is causing the bug. If you remove the second ctrl from your type string, it should fix the issue. I'll open another PR to fix this and revert to <3.5.0 behavior, but this does show how our .type API is confusing for users. (notice
in the 3.4.1 screenshot how the ctrl modifier is held down after the first press, and there is no second ctrl keydown)

We should probably implement a way to type one modifier key combination + release without having to break up into multiple type commands, something like:
cy.type('{ctrl+b}hello{ctrl+b}world')

cy.type('{ctrl+b}hello{ctrl+b}world') looks very clear and easy to read, that' a good idea!

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

Released in 3.7.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igorpavlov picture igorpavlov  路  3Comments

weskor picture weskor  路  3Comments

jennifer-shehane picture jennifer-shehane  路  3Comments

brian-mann picture brian-mann  路  3Comments

szabyg picture szabyg  路  3Comments