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

fix(driver): Sticky elements within a fixed container will not prevent an element from being scrolled to #18441

Merged
merged 31 commits into from
Nov 2, 2021

Conversation

davidmunechika
Copy link
Contributor

@davidmunechika davidmunechika commented Oct 11, 2021

User facing changelog

Sticky elements within a fixed container will now be able to be scrolled to.

Additional details

Flowchart detailing the new actionability behavior: https://whimsical.com/actionability-J38eY9K2Y3vA6uCMWtmLVA

Previously, sticky elements could cover up elements that user would try to scroll to, causing failed tests such as the one below:
image

This error would happen because cy.ensureVisibility() would fail before our nudging algorithm would run. This PR extracts some of the visibility checks related to being covered up by ancestors into a new ensure function and runs these checks after the nudging algorithm scrolls the element into view.

PR Tasks

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 11, 2021

Thanks for taking the time to open a PR!

@davidmunechika davidmunechika self-assigned this Oct 11, 2021
@cypress
Copy link

cypress bot commented Oct 11, 2021



Test summary

4227 1 50 2Flakiness 1


Run details

Project cypress
Status Failed
Commit 5aa6dc7
Started Nov 2, 2021 3:30 PM
Ended Nov 2, 2021 3:42 PM
Duration 11:14 💡
OS Linux Debian - 10.9
Browser Electron 93

View run in Cypress Dashboard ➡️


Failures

cypress/integration/commands/navigation_spec.js Failed
1 ... > throws when qs is null

Flakiness

cypress/integration/commands/net_stubbing_spec.ts Flakiness
1 network stubbing > waiting and aliasing > can timeout waiting on a single request using "alias.request"

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we should use the rotate scrollBehavior if the user has specified a scrollBehavior to overwrite the default. They may be testing that an element is clickable with a specific scroll behavior - that you can scroll to bottom and always click for example. What would be the use of passing scrollBehavior if it is always overridden?

I do however think that most people use the scrollBehavior option as a fix for our issues of not finding the thing to click on, but this would be a breaking change imo.

This does fix the initial issue.

Copy link
Contributor

@chrisbreiding chrisbreiding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add a test covering when the user specifies the scroll behavior.

I think it could basically be the same as the test you added, but pass in a scrollBehavior to cy.click() that makes it fail. Then test it's the right failure. If you're not sure how to do that, look at tests that use cy.on('fail', ...). There are a bunch of them in the driver tests.

packages/driver/src/cy/actionability.ts Outdated Show resolved Hide resolved
packages/driver/src/cy/commands/actions/click.ts Outdated Show resolved Hide resolved
davidmunechika and others added 4 commits October 13, 2021 11:23
Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
Copy link
Contributor

@chrisbreiding chrisbreiding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍 Nice work!

Copy link
Contributor

@chrisbreiding chrisbreiding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I approved this too soon. We need to take into account all of the commands that can receive scrollBehavior as an option. That means setting the userSetScrollBehavior in each command and adding tests for each one too.

I think these are all the other commands that accept scrollBehavior:

  • check
  • clear
  • dblclick
  • trigger
  • type
  • uncheck

@jennifer-shehane jennifer-shehane removed their request for review November 2, 2021 14:32
@jennifer-shehane jennifer-shehane dismissed their stale review November 2, 2021 14:33

Dismissing previous review

@chrisbreiding chrisbreiding merged commit 28ae1c1 into develop Nov 2, 2021
@chrisbreiding chrisbreiding deleted the issue-4233-click-sticky-element branch November 2, 2021 18:22
tgriesser added a commit that referenced this pull request Nov 3, 2021
* develop: (40 commits)
  fix(driver): Sticky elements within a fixed container will not prevent an element from being scrolled to (#18441)
  chore: make `create` function on server.ts obsolete (#18615)
  docs: Add instructions to squash commits to develop in Contributing (#18728)
  fix(@cypress/react): throw if using Next.js swc-loader without nodeVersion=system (#18686)
  refactor: remove Ramda (#18723)
  chore: Increase paralleled machines for desktop-gui tests (#18725)
  chore: Update Chrome (stable) to 95.0.4638.69 (#18696)
  chore: release @cypress/vue-v3.0.4
  chore: release @cypress/react-v5.10.2
  chore: release @cypress/schematic-v1.5.3
  fix: remove outdated registry link (#18710)
  chore: release @cypress/schematic-v1.5.2
  chore: release create-cypress-tests-v1.1.3
  chore: Update Chrome (beta) to 96.0.4664.27 (#18676)
  chore(tests): Remove flaky assertion that relies on png how compression (#18668)
  fix: make sure to go back to no-specs when delete spec file (#17760)
  fix: Next.JS 12 components testing failing with ` TypeError: Cannot read property 'traceChild' of undefined` (#18648)
  Backport .gitignore from unified-desktop-gui
  chore(docs): add 'Upgrading Electron' instructions (#18594)
  release 8.7.0 [skip ci]
  ...
tgriesser added a commit that referenced this pull request Nov 3, 2021
* develop: (40 commits)
  fix(driver): Sticky elements within a fixed container will not prevent an element from being scrolled to (#18441)
  chore: make `create` function on server.ts obsolete (#18615)
  docs: Add instructions to squash commits to develop in Contributing (#18728)
  fix(@cypress/react): throw if using Next.js swc-loader without nodeVersion=system (#18686)
  refactor: remove Ramda (#18723)
  chore: Increase paralleled machines for desktop-gui tests (#18725)
  chore: Update Chrome (stable) to 95.0.4638.69 (#18696)
  chore: release @cypress/vue-v3.0.4
  chore: release @cypress/react-v5.10.2
  chore: release @cypress/schematic-v1.5.3
  fix: remove outdated registry link (#18710)
  chore: release @cypress/schematic-v1.5.2
  chore: release create-cypress-tests-v1.1.3
  chore: Update Chrome (beta) to 96.0.4664.27 (#18676)
  chore(tests): Remove flaky assertion that relies on png how compression (#18668)
  fix: make sure to go back to no-specs when delete spec file (#17760)
  fix: Next.JS 12 components testing failing with ` TypeError: Cannot read property 'traceChild' of undefined` (#18648)
  Backport .gitignore from unified-desktop-gui
  chore(docs): add 'Upgrading Electron' instructions (#18594)
  release 8.7.0 [skip ci]
  ...
tgriesser added a commit that referenced this pull request Nov 4, 2021
…ve-activeProject

* unified-desktop-gui: (57 commits)
  chore: Add e2e tests for global mode (#18719)
  chore: add percy to app and launchpad package (#18781)
  chore: update test
  refactor: move settings in app (#18729)
  feat: setup launchpad lifecycle (#18734)
  feat(app): decouple event manager from driver (#18695)
  chore: Force single resolution for core modules, infinite loop guard (#18764)
  fix(driver): Sticky elements within a fixed container will not prevent an element from being scrolled to (#18441)
  chore: cleaning up the runner container pattern (#18741)
  feat: Use .config files (#18578)
  chore(app): basic style and example to stop scrollIntoView bug (#18736)
  chore: make `create` function on server.ts obsolete (#18615)
  feat: add codegen utility (#18708)
  docs: Add instructions to squash commits to develop in Contributing (#18728)
  fix(@cypress/react): throw if using Next.js swc-loader without nodeVersion=system (#18686)
  refactor: remove Ramda (#18723)
  fix: support using create-cypress-tests as part of build process (#18714)
  chore: Increase paralleled machines for desktop-gui tests (#18725)
  fix(app): do not cache graphql (#18716)
  chore: Update Chrome (stable) to 95.0.4638.69 (#18696)
  ...
flotwig pushed a commit that referenced this pull request Nov 8, 2021
…t an element from being scrolled to (#18441)

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sticky elements within a fixed container are not properly taken into account when scrolling to an element
4 participants