diff --git a/src/web/components/form/__tests__/__snapshots__/selectelement.js.snap b/src/web/components/form/__tests__/__snapshots__/selectelement.js.snap index bee0468f3f..76c9f5221b 100644 --- a/src/web/components/form/__tests__/__snapshots__/selectelement.js.snap +++ b/src/web/components/form/__tests__/__snapshots__/selectelement.js.snap @@ -249,6 +249,40 @@ exports[`Menu tests should render with position adjust 1`] = ` /> `; +exports[`Menu tests should render with position reference to parent element 1`] = ` +.c0 { + outline: 0; + border-radius: 0 0 4px 4px; + -webkit-transition: opacity 0.1s ease; + transition: opacity 0.1s ease; + box-shadow: 0 2px 3px 0 rgba(34,36,38,0.15); + border: 1px solid #bfbfbf; + background-color: #fff; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + position: absolute; + z-index: 600; + margin-top: -1px; + box-sizing: border-box; + top: 120px; + left: 50px; + white-space: nowrap; +} + +
+`; + exports[`Menu tests should render with position right 1`] = ` .c0 { outline: 0; diff --git a/src/web/components/form/__tests__/selectelement.js b/src/web/components/form/__tests__/selectelement.js index c650e6a2f1..dd7265e6d2 100644 --- a/src/web/components/form/__tests__/selectelement.js +++ b/src/web/components/form/__tests__/selectelement.js @@ -21,6 +21,7 @@ import {isFunction} from 'gmp/utils/identity'; import {render} from 'web/utils/testing'; import Theme from 'web/utils/theme'; +import PropTypes from 'web/utils/proptypes'; import { Box, @@ -207,19 +208,43 @@ class MenuTestComponent extends React.Component { super(...args); this.target = React.createRef(); + this.mockBoundingClientRect = this.props.mockBoundingClientRect; } render() { const hasTarget = this.target.current !== null; + if (hasTarget && this.mockBoundingClientRect) { + const rect = this.target.current.closest('.multiselect-scroll'); + if (rect !== null) { + jest.spyOn(rect, 'getBoundingClientRect').mockImplementation(() => { + return { + top: 100, + bottom: 50, + height: 20, + width: 100, + right: 10, + left: 50, + }; + }); + } + } return (