Skip to content

test: make keyboard tests more reliable - #3659

Merged
web-padawan merged 1 commit into
masterfrom
date-picker/make-keyboard-tests-more-reliable
Apr 11, 2022
Merged

web-padawan merged 1 commit into
masterfrom
date-picker/make-keyboard-tests-more-reliable

Conversation

@vursen

@vursen vursen commented Apr 9, 2022 •

Copy link
Copy Markdown
Contributor

Description

It was discovered that sometimes await sendKeys(...) resolves after the scroll-animation-finished event is fired which results in date-picker test failures because they were written with the assumption that the event will be always fired before.

The reason is likely related to the implementation of sendKeys. There is no guarantee that the returned promise will resolve exactly at the moment you expect. It can take longer under some circumstances.

This PR attempts to deal with such test failures by introducing a waitForScrollToFinish test helper that doesn't wait if the scroll has already finished.

Part of #3538

Type of change

  • Internal

Checklist

  • I have read the contribution guide: https://vaadin.com/docs-beta/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

@sonarqubecloud

sonarqubecloud Bot commented Apr 9, 2022

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

* @param {HTMLElement} overlayContent
*/
export async function waitForScrollToFinish(overlayContent) {
if (overlayContent._targetPosition) {

@vursen vursen Apr 9, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

note: Didn't find any straightforward way of determining if the overlay content is scrolling except for using a protected property. Alternatively, it could check for the scroll events, but that would lead to a more complicated solution in the end.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems reasonable. Introducing a private API like isScrolling, and adding tests for that would also be an option, though adding APIs just for tests is not ideal as well.

@web-padawan web-padawan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks a lot for fixing these tests 🙇‍♂️

@web-padawan
web-padawan merged commit 8019343 into master Apr 11, 2022
@web-padawan
web-padawan deleted the date-picker/make-keyboard-tests-more-reliable branch April 11, 2022 08:31
web-padawan pushed a commit that referenced this pull request Apr 11, 2022
Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
@vaadin-bot

Copy link
Copy Markdown
Collaborator

This ticket/PR has been released with Vaadin 23.1.0.alpha2 and is also targeting the upcoming stable 23.1.0 version.

@vursen vursen mentioned this pull request May 6, 2022
7 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants