@@ -4,6 +4,7 @@ import murmurhash from 'murmurhash'
4
4
import {
5
5
treeWithMaxParametersXml ,
6
6
treeWithNestedDisabledFieldsXml ,
7
+ treeWithNestedScrollableXml ,
7
8
treeXml
8
9
} from '../mocks/FormElement'
9
10
import { Tree } from '../../src/components/Tree/Tree'
@@ -428,6 +429,30 @@ describe('Tree component', () => {
428
429
cy . get ( '[data-cy="/Parent1/Child1-1/Child1-1-2"]:indeterminate' ) . should ( 'exist' )
429
430
cy . get ( '[data-cy="/Parent1/Child1-1/Child1-1-2/Child1-1-2-1"]' ) . should ( 'be.checked' )
430
431
cy . get ( '[data-cy="/Parent1/Child1-1/Child1-1-2/Child1-1-2-2"]' ) . should ( 'not.be.checked' )
432
+
433
+ // We shouldn't be able to scroll because the leaf labels are not long enough
434
+ cy . get ( '.ef-tree__list-wrapper' ) . scrollTo ( 'right' , { ensureScrollable : false } )
435
+
436
+ } )
437
+
438
+ it ( 'scrolls for long leaf label' , ( ) => {
439
+ const onFormModelUpdatedSpy = cy . spy ( ) . as ( 'onFormModelUpdatedSpy' )
440
+ const onFormIsValidUpdatedSpy = cy . spy ( ) . as ( 'onFormIsValidUpdatedSpy' )
441
+
442
+ cy . mount (
443
+ < EDSCEchoform
444
+ form = { treeWithNestedScrollableXml }
445
+ onFormModelUpdated = { onFormModelUpdatedSpy }
446
+ onFormIsValidUpdated = { onFormIsValidUpdatedSpy }
447
+ />
448
+ )
449
+
450
+ // Expand tree
451
+ cy . get ( '[data-cy="ef-tree-item__parent-button-2"]' ) . click ( )
452
+ cy . get ( '[data-cy="ef-tree-item__parent-button-3"]' ) . click ( )
453
+
454
+ // Scroll to right edge and verify that with the longer leaf label value, this element will be scrollable
455
+ cy . get ( '.ef-tree__list-wrapper' ) . scrollTo ( 'right' , { ensureScrollable : true } )
431
456
} )
432
457
} )
433
458
} )
0 commit comments