-
Notifications
You must be signed in to change notification settings - Fork 196
chore: Fixes virtual dropdown tests for React 18 #3842
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3842 +/- ##
==========================================
- Coverage 97.14% 97.12% -0.02%
==========================================
Files 844 844
Lines 24505 24553 +48
Branches 8647 8659 +12
==========================================
+ Hits 23805 23848 +43
- Misses 693 698 +5
Partials 7 7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
items, | ||
hasNextPage | ||
); | ||
await this.pause(10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this happening?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is what I observed. I this test:
test(
'the bottom of the dropdown lines up with the highlighted option, when going down the list',
setup({ virtualScrolling }, async page => {
await page.respondWith(0, true);
await page.keys(['ArrowDown', 'ArrowDown', 'ArrowDown']);
const { bottom: optionBottom } = await page.getHighlightedPosition();
const { bottom: dropdownBottom } = await page.getDropdownPosition();
// a small give for borders and negative margins
expect(Math.abs(optionBottom - dropdownBottom)).toBeLessThan(3);
})
);
we issue 3 keydown events. However, only two keydown events are received (sometimes, it is flaky).

I think there is a chance that the key-down handler is called before the options are ready, in which case the 1st keydown is just ignored. Adding a small delay fixes the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a reusable utility for this case: https://github.com/cloudscape-design/browser-test-tools/blob/2f3ae51ccd4f4a9869d09b4701e02b2c4322c0ff/src/page-objects/base.ts#L162-L164
Let's use that one
Description
This fixes failing autosuggest tests with React 18, reproducible here: #3829
Rel: AWSUI-61204
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md
.CONTRIBUTING.md
.Security
checkSafeUrl
function.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.