-
Notifications
You must be signed in to change notification settings - Fork 162
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,9 @@ import createWrapper, { AppLayoutWrapper } from '../../../lib/components/test-ut | |
import { viewports } from './constants'; | ||
import { getUrlParams, Theme } from './utils'; | ||
|
||
import vrDrawerStyles from '../../../lib/components/app-layout/visual-refresh/styles.selectors.js'; | ||
import vrToolbarDrawerStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/drawer/styles.selectors.js'; | ||
|
||
const wrapper = createWrapper().findAppLayout(); | ||
const findDrawerById = (wrapper: AppLayoutWrapper, id: string) => { | ||
return wrapper.find(`[data-testid="awsui-app-layout-drawer-${id}"]`); | ||
|
@@ -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 }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the actual scrollable elements are different in Classic vs VR |
||
const scrollableContainer = | ||
theme === 'classic' | ||
? wrapper.findActiveDrawer().toSelector() | ||
: theme === 'refresh' | ||
? `.${vrDrawerStyles['drawer-content-container']}` | ||
: `.${vrToolbarDrawerStyles['drawer-content-container']}`; | ||
|
||
await page.elementScrollTo(scrollableContainer, { top: 100 }); | ||
await expect(getScrollPosition()).resolves.toEqual(scrollBefore); | ||
await expect(page.isDisplayed('[data-testid="drawer-sticky-header"]')).resolves.toBe(true); | ||
}) | ||
|
@@ -316,7 +326,8 @@ describe('Visual refresh toolbar only', () => { | |
const getScrollPosition = () => page.getBoundingBox('[data-testid="drawer-sticky-header"]'); | ||
const scrollBefore = await getScrollPosition(); | ||
|
||
await page.elementScrollTo(wrapper.findActiveDrawer().toSelector(), { top: 100 }); | ||
const scrollableContainer = `.${vrToolbarDrawerStyles['drawer-content-container']}`; | ||
await page.elementScrollTo(scrollableContainer, { top: 100 }); | ||
await expect(getScrollPosition()).resolves.toEqual(scrollBefore); | ||
await expect(page.isDisplayed('[data-testid="drawer-sticky-header"]')).resolves.toBe(true); | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it isn't failing, but also doesn't match with actual height https://github.com/cloudscape-design/components/blob/main/pages/cards/sticky-header.page.tsx#L68 |
||
const overflowParentPageHeight = 400; | ||
const verticalOffset = 50; | ||
|
||
test( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this element
|
||
await page.hoverElement(legendWrapper.findItems().get(2).toSelector()); | ||
|
||
await expect(page.getText(legendWrapper.findHighlightedItem().toSelector())).resolves.toBe('Chocolate'); | ||
|
@@ -239,7 +238,6 @@ describe('Legend', () => { | |
'highlighted legend elements should be not be highlighted when user hovers away', | ||
setupTest(async page => { | ||
// Hover over second segment in the legend | ||
await page.elementScrollTo(legendWrapper.findItems().get(2).toSelector(), { top: 0, left: 0 }); | ||
await page.hoverElement(legendWrapper.findItems().get(2).toSelector()); | ||
|
||
// Verify that no legend is highlighted | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 I remove the check and a new test should be added once the issue is fixed |
||
}) | ||
); | ||
|
||
|
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.
Do we need new test-utils selectors for these? How customers would scroll the elements in their tests?
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.
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
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.
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.