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

chore: Fix elements scrolling with elementScrollTo in integration tests #3138

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

Al-Dani
Copy link
Member

@Al-Dani Al-Dani commented Dec 13, 2024

Description

Related links, issue #, if available:

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@@ -44,7 +44,7 @@ describe('Cards Sticky Header', () => {
const scrollTopToBtn = '#scroll-to-top-btn';
const toggleStickinessBtn = '#toggle-stickiness-btn';
const toggleVerticalOffsetBtn = '#toggle-vertical-offset-btn';
const overflowParentPageHeight = 300;
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.44%. Comparing base (0be1ec7) to head (9b483f1).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3138    +/-   ##
========================================
  Coverage   96.44%   96.44%            
========================================
  Files         790      790            
  Lines       22249    22249            
  Branches     7231     7637   +406     
========================================
  Hits        21458    21458            
+ Misses        784      739    -45     
- Partials        7       52    +45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Al-Dani Al-Dani force-pushed the non-scrollable-tests branch from 356e3c5 to 28c6984 Compare December 13, 2024 14:14
@@ -209,7 +209,6 @@ describe('Legend', () => {
'can be controlled with mouse',
setupTest(async page => {
// Hover over second segment in the legend
await page.elementScrollTo(legendWrapper.findItems().get(2).toSelector(), { top: 0, left: 0 });
Copy link
Member Author

Choose a reason for hiding this comment

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

this element

  • isn't scrollable by design
  • is already in the viewport

@@ -109,8 +109,6 @@ test(
const { height: actualDropdownHeight } = await page.getBoundingBox(optionsSelector);
const availableDropdownHeight = smallestContainerHeight - triggerHeight;
expect(actualDropdownHeight).toBeLessThan(availableDropdownHeight);
const { top: containerScrollTop } = await page.getElementScroll('#smallest_container');
expect(containerScrollTop).toBe(0);
Copy link
Member Author

Choose a reason for hiding this comment

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

this check was was inherited from v2.1 where it tested the fix for AWSUI-7290. However, the test doesn't work, as the issue is still reproducible in the current version of the components.

I remove the check and a new test should be added once the issue is fixed

@@ -117,7 +120,14 @@ describe.each(['classic', 'refresh', 'refresh-toolbar'] as Theme[])('%s', theme
const getScrollPosition = () => page.getBoundingBox('[data-testid="drawer-sticky-header"]');
const scrollBefore = await getScrollPosition();

await page.elementScrollTo(wrapper.findActiveDrawer().toSelector(), { top: 100 });
Copy link
Member Author

Choose a reason for hiding this comment

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

the actual scrollable elements are different in Classic vs VR

@Al-Dani Al-Dani force-pushed the non-scrollable-tests branch from ae9cd42 to 9b483f1 Compare January 27, 2025 11:15
@Al-Dani Al-Dani marked this pull request as ready for review January 27, 2025 11:33
@Al-Dani Al-Dani requested a review from a team as a code owner January 27, 2025 11:33
@Al-Dani Al-Dani requested review from orangevolon and removed request for a team January 27, 2025 11:33
? wrapper.findActiveDrawer().toSelector()
: theme === 'refresh'
? `.${vrDrawerStyles['drawer-content-container']}`
: `.${vrToolbarDrawerStyles['drawer-content-container']}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need new test-utils selectors for these? How customers would scroll the elements in their tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, interesting question, I was thinking about it too.

We don't have any test utils to get scrollable containers except findOptionsContainer in select-alike components that says "Use this element to scroll through the list of options".

Moreover, currently doing page.elementScrollTo(wrapper.findActiveDrawer().toSelector(), { top: 100 }); in customer tests means assuming that the returned element is scrollable. I don't think we support such assumptions.

It seems like a possible, but quite specific test-case where users need that. We could treat it as a feature request, but we haven't heard from customers yet that it's needed

Copy link
Contributor

@orangevolon orangevolon Jan 29, 2025

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 this particular PR is blocked by this comment either, but if something is scrollable, I think it's fair to give the customers a way to scroll safely. The theme I've seen so far is that people make feature requests when they get really frustrated by something. Mostly they just use CSS selectors to get to the element they want to scroll.

@Al-Dani Al-Dani requested a review from orangevolon January 29, 2025 11:16
@Al-Dani Al-Dani added this pull request to the merge queue Jan 29, 2025
Merged via the queue into main with commit 124c9b8 Jan 29, 2025
38 checks passed
@Al-Dani Al-Dani deleted the non-scrollable-tests branch January 29, 2025 15:03
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.

2 participants