@@ -3537,6 +3537,63 @@ describe('AnalyticalTable', () => {
35373537 cy . get ( '[data-component-name="AnalyticalTableBody"]' ) . should ( 'have.css' , 'height' , '800px' ) ;
35383538 } ) ;
35393539
3540+ it ( 'initial scroll-to' , ( ) => {
3541+ const ScrollTo = ( ) => {
3542+ const tableRef = useRef < AnalyticalTableDomRef > ( null ) ;
3543+ useEffect ( ( ) => {
3544+ tableRef . current . scrollTo ( 520 ) ;
3545+ } , [ ] ) ;
3546+ return < AnalyticalTable data = { generateMoreData ( 200 ) } columns = { columns } ref = { tableRef } /> ;
3547+ } ;
3548+ cy . mount ( < ScrollTo /> ) ;
3549+ cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( 'Name-12' ) . should ( 'be.visible' ) ;
3550+ cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( 'Name-11' ) . should ( 'not.be.visible' ) ;
3551+
3552+ const ScrollToItem = ( ) => {
3553+ const tableRef = useRef ( null ) ;
3554+ useEffect ( ( ) => {
3555+ tableRef . current . scrollToItem ( 12 , { align : 'start' } ) ;
3556+ } , [ ] ) ;
3557+ return < AnalyticalTable data = { generateMoreData ( 200 ) } columns = { columns } ref = { tableRef } /> ;
3558+ } ;
3559+ cy . mount ( < ScrollToItem /> ) ;
3560+ cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( 'Name-12' ) . should ( 'be.visible' ) ;
3561+ cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( 'Name-11' ) . should ( 'not.be.visible' ) ;
3562+
3563+ const ScrollToHorizontal = ( ) => {
3564+ const tableRef = useRef ( null ) ;
3565+ useEffect ( ( ) => {
3566+ tableRef . current . horizontalScrollTo ( 1020 ) ;
3567+ } , [ ] ) ;
3568+ return (
3569+ < AnalyticalTable
3570+ data = { generateMoreData ( 200 ) }
3571+ columns = { [ ...columns , ...new Array ( 50 ) . fill ( '' ) . map ( ( _ , index ) => ( { id : `${ index } ` , Header : ( ) => index } ) ) ] }
3572+ ref = { tableRef }
3573+ />
3574+ ) ;
3575+ } ;
3576+ cy . mount ( < ScrollToHorizontal /> ) ;
3577+ cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( '13' ) . should ( 'be.visible' ) ;
3578+ cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( '12' ) . should ( 'not.be.visible' ) ;
3579+ const ScrollToItemHorizontal = ( ) => {
3580+ const tableRef = useRef ( null ) ;
3581+ useEffect ( ( ) => {
3582+ tableRef . current . horizontalScrollToItem ( 13 , { align : 'start' } ) ;
3583+ } , [ ] ) ;
3584+ return (
3585+ < AnalyticalTable
3586+ data = { generateMoreData ( 200 ) }
3587+ columns = { new Array ( 50 ) . fill ( '' ) . map ( ( _ , index ) => ( { id : `${ index } ` , Header : ( ) => index } ) ) }
3588+ ref = { tableRef }
3589+ />
3590+ ) ;
3591+ } ;
3592+ cy . mount ( < ScrollToItemHorizontal /> ) ;
3593+ cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( '13' ) . should ( 'be.visible' ) ;
3594+ cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( '12' ) . should ( 'not.be.visible' ) ;
3595+ } ) ;
3596+
35403597 it ( 'additionalEmptyRowsCount' , ( ) => {
35413598 cy . mount ( < AnalyticalTable data = { data } columns = { columns } minRows = { 4 } /> ) ;
35423599 cy . get ( '[data-empty-row]' ) . should ( 'not.exist' ) ;
@@ -4242,63 +4299,6 @@ describe('AnalyticalTable', () => {
42424299 cy . focused ( ) . should ( 'have.text' , 'Before' ) ;
42434300 } ) ;
42444301
4245- it ( 'initial scroll-to' , ( ) => {
4246- const ScrollTo = ( ) => {
4247- const tableRef = useRef < AnalyticalTableDomRef > ( null ) ;
4248- useEffect ( ( ) => {
4249- tableRef . current . scrollTo ( 520 ) ;
4250- } , [ ] ) ;
4251- return < AnalyticalTable data = { generateMoreData ( 200 ) } columns = { columns } ref = { tableRef } /> ;
4252- } ;
4253- cy . mount ( < ScrollTo /> ) ;
4254- cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( 'Name-12' ) . should ( 'be.visible' ) ;
4255- cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( 'Name-11' ) . should ( 'not.be.visible' ) ;
4256-
4257- const ScrollToItem = ( ) => {
4258- const tableRef = useRef ( null ) ;
4259- useEffect ( ( ) => {
4260- tableRef . current . scrollToItem ( 12 , { align : 'start' } ) ;
4261- } , [ ] ) ;
4262- return < AnalyticalTable data = { generateMoreData ( 200 ) } columns = { columns } ref = { tableRef } /> ;
4263- } ;
4264- cy . mount ( < ScrollToItem /> ) ;
4265- cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( 'Name-12' ) . should ( 'be.visible' ) ;
4266- cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( 'Name-11' ) . should ( 'not.be.visible' ) ;
4267-
4268- const ScrollToHorizontal = ( ) => {
4269- const tableRef = useRef ( null ) ;
4270- useEffect ( ( ) => {
4271- tableRef . current . horizontalScrollTo ( 1020 ) ;
4272- } , [ ] ) ;
4273- return (
4274- < AnalyticalTable
4275- data = { generateMoreData ( 200 ) }
4276- columns = { [ ...columns , ...new Array ( 50 ) . fill ( '' ) . map ( ( _ , index ) => ( { id : `${ index } ` , Header : ( ) => index } ) ) ] }
4277- ref = { tableRef }
4278- />
4279- ) ;
4280- } ;
4281- cy . mount ( < ScrollToHorizontal /> ) ;
4282- cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( '13' ) . should ( 'be.visible' ) ;
4283- cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( '12' ) . should ( 'not.be.visible' ) ;
4284- const ScrollToItemHorizontal = ( ) => {
4285- const tableRef = useRef ( null ) ;
4286- useEffect ( ( ) => {
4287- tableRef . current . horizontalScrollToItem ( 13 , { align : 'start' } ) ;
4288- } , [ ] ) ;
4289- return (
4290- < AnalyticalTable
4291- data = { generateMoreData ( 200 ) }
4292- columns = { new Array ( 50 ) . fill ( '' ) . map ( ( _ , index ) => ( { id : `${ index } ` , Header : ( ) => index } ) ) }
4293- ref = { tableRef }
4294- />
4295- ) ;
4296- } ;
4297- cy . mount ( < ScrollToItemHorizontal /> ) ;
4298- cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( '13' ) . should ( 'be.visible' ) ;
4299- cy . get ( '[data-component-name="AnalyticalTableContainer"]' ) . findByText ( '12' ) . should ( 'not.be.visible' ) ;
4300- } ) ;
4301-
43024302 cypressPassThroughTestsFactory ( AnalyticalTable , { data, columns } ) ;
43034303} ) ;
43044304
0 commit comments