@@ -11,57 +11,45 @@ const createScheduler = async (options): Promise<void> => createWidget('dxSchedu
1111const scrollToDate = ClientFunction ( ( ) => {
1212 const instance = ( $ ( '#container' ) as any ) . dxScheduler ( 'instance' ) ;
1313 const currentDate = instance . option ( 'currentDate' ) ;
14- const date = new Date ( currentDate . getTime ( ) + 2 * 24 * 60 * 60 * 1000 ) ;
15- date . setHours ( 9 , 40 , 0 , 0 ) ;
16-
14+ const date = new Date ( currentDate . getTime ( ) ) ;
15+ date . setHours ( date . getHours ( ) + 6 , 30 , 0 , 0 ) ;
1716 instance . scrollTo ( date ) ;
1817} ) ;
1918
2019const scrollToDateWithGroups = ClientFunction ( ( ) => {
2120 const instance = ( $ ( '#container' ) as any ) . dxScheduler ( 'instance' ) ;
2221 const currentDate = instance . option ( 'currentDate' ) ;
23- const date = new Date ( currentDate . getTime ( ) + 2 * 24 * 60 * 60 * 1000 ) ;
24- date . setHours ( 9 , 40 , 0 , 0 ) ;
25-
22+ const date = new Date ( currentDate . getTime ( ) ) ;
23+ date . setHours ( date . getHours ( ) + 6 , 30 , 0 , 0 ) ;
2624 instance . scrollTo ( date , { priority : 1 } ) ;
2725} ) ;
2826
2927const scrollToAllDay = ClientFunction ( ( ) => {
3028 const instance = ( $ ( '#container' ) as any ) . dxScheduler ( 'instance' ) ;
3129 const currentDate = instance . option ( 'currentDate' ) ;
32- const date = new Date ( currentDate . getTime ( ) + 2 * 24 * 60 * 60 * 1000 ) ;
33- date . setHours ( 9 , 40 , 0 , 0 ) ;
34-
30+ const date = new Date ( currentDate . getTime ( ) ) ;
31+ date . setHours ( date . getHours ( ) + 6 , 30 , 0 , 0 ) ;
3532 instance . scrollTo ( date , undefined , true ) ;
3633} ) ;
3734
3835test ( 'ScrollTo works correctly with week and day views' , async ( t ) => {
3936 const scheduler = new Scheduler ( '#container' ) ;
4037
41- const views = [ {
42- name : 'week' ,
43- initValue : 0 ,
44- } , {
45- name : 'day' ,
46- initValue : 0 ,
47- } ] ;
38+ const views = [ { name : 'week' , initValue : 0 } , { name : 'day' , initValue : 0 } ] ;
4839
4940 // eslint-disable-next-line no-restricted-syntax
5041 for ( const view of views ) {
5142 const { name, initValue } = view ;
5243
5344 await scheduler . option ( 'currentView' , name ) ;
5445 await scheduler . option ( 'useNative' , true ) ;
55-
56- await t
57- . expect ( scheduler . workSpaceScroll . top ) . eql ( initValue , `Work space has init scroll position in ${ name } view` ) ;
46+ await t . wait ( 2000 ) ;
5847
5948 await scrollToDate ( ) ;
60-
61- const workSpaceScrollTop = await scheduler . workSpaceScroll . top ;
49+ await t . wait ( 3000 ) ;
6250
6351 await t
64- . expect ( workSpaceScrollTop ) . notEql ( initValue , `Work space is scrolled in ${ name } view` ) ;
52+ . expect ( scheduler . workSpaceScroll . top ) . gt ( initValue , `Work space is scrolled in ${ name } view` ) ;
6553 }
6654} ) . before ( async ( ) => createScheduler ( {
6755 dataSource : [ ] ,
@@ -79,18 +67,15 @@ test('ScrollTo works correctly with grouping in week view', async (t) => {
7967
8068 await scheduler . option ( 'currentView' , 'week' ) ;
8169 await scheduler . option ( 'useNative' , true ) ;
70+ await t . wait ( 2000 ) ;
8271
83- const initValue = 0 ;
84-
85- await t
86- . expect ( scheduler . workSpaceScroll . top ) . eql ( initValue , 'Work space has init scroll position' ) ;
72+ const initialTop = await scheduler . workSpaceScroll . top ;
8773
8874 await scrollToDateWithGroups ( ) ;
89-
90- const workSpaceScrollTop = await scheduler . workSpaceScroll . top ;
75+ await t . wait ( 3000 ) ;
9176
9277 await t
93- . expect ( workSpaceScrollTop ) . notEql ( initValue , 'Work space is scrolled with groups' ) ;
78+ . expect ( scheduler . workSpaceScroll . top ) . gt ( initialTop , 'Work space is scrolled with groups' ) ;
9479} ) . before ( async ( ) => createScheduler ( {
9580 dataSource : [ ] ,
9681 views : [ 'week' ] ,
@@ -123,6 +108,7 @@ test('ScrollTo works correctly with all-day panel', async (t) => {
123108 . expect ( scheduler . workSpaceScroll . top ) . eql ( initValue , 'Work space has init scroll position' ) ;
124109
125110 await scrollToAllDay ( ) ;
111+ await t . wait ( 3000 ) ;
126112
127113 await t
128114 . expect ( scheduler . workSpaceScroll . top ) . eql ( expectedTopValue , 'Work space is scrolled to all-day panel' ) ;
@@ -144,15 +130,17 @@ test('ScrollTo works correctly with RTL mode', async (t) => {
144130 await scheduler . option ( 'currentView' , 'week' ) ;
145131 await scheduler . option ( 'useNative' , true ) ;
146132 await scheduler . option ( 'rtlEnabled' , true ) ;
133+ await t . wait ( 2000 ) ;
147134
148- const initialWorkSpaceScrollTop = await scheduler . workSpaceScroll . top ;
135+ const initialBrowserTop = await scheduler . workSpaceScroll . top ;
149136
150137 await scrollToDate ( ) ;
138+ await t . wait ( 3000 ) ;
151139
152- const workSpaceScrollTop = await scheduler . workSpaceScroll . top ;
140+ const browserTop = await ClientFunction ( ( ) => ( $ ( '#container' ) as any ) . dxScheduler ( 'instance' ) . getWorkSpaceScrollable ( ) . scrollTop ( ) ) ( ) ;
153141
154142 await t
155- . expect ( workSpaceScrollTop ) . notEql ( initialWorkSpaceScrollTop , 'Work space is scrolled in RTL' ) ;
143+ . expect ( browserTop ) . gt ( initialBrowserTop , 'Work space is scrolled in RTL' ) ;
156144} ) . before ( async ( ) => createScheduler ( {
157145 dataSource : [ ] ,
158146 views : [ 'week' ] ,
@@ -163,3 +151,82 @@ test('ScrollTo works correctly with RTL mode', async (t) => {
163151 endDayHour : 20 ,
164152 height : 580 ,
165153} ) ) ;
154+
155+ test ( 'ScrollTo works correctly with timeline views (native, sync header/workspace)' , async ( t ) => {
156+ const scheduler = new Scheduler ( '#container' ) ;
157+
158+ const views = [ { name : 'timelineDay' } , { name : 'timelineWeek' } ] ;
159+
160+ // eslint-disable-next-line no-restricted-syntax
161+ for ( const view of views ) {
162+ const { name } = view ;
163+
164+ await scheduler . option ( 'currentView' , name ) ;
165+ await scheduler . option ( 'useNative' , true ) ;
166+ await t . wait ( 200 ) ;
167+
168+ const getWSLeft = ClientFunction ( ( ) => ( $ ( '#container' ) as any ) . dxScheduler ( 'instance' ) . getWorkSpaceScrollable ( ) . scrollLeft ( ) ) ;
169+ const getHeaderLeft = ClientFunction ( ( ) => $ ( '.dx-scheduler-header-scrollable .dx-scrollable-container' ) . scrollLeft ( ) ) ;
170+
171+ const initialLeft = await getWSLeft ( ) ;
172+ const initialHeaderLeft = await getHeaderLeft ( ) ;
173+
174+ await t . expect ( initialLeft ) . eql ( initialHeaderLeft , `${ name } : header/workspace initial sync` ) ;
175+
176+ await scrollToDate ( ) ;
177+ await t . wait ( 300 ) ;
178+
179+ const left = await getWSLeft ( ) ;
180+ const headerLeft = await getHeaderLeft ( ) ;
181+
182+ await t
183+ . expect ( left ) . notEql ( initialLeft , `${ name } : workspace left changed` )
184+ . expect ( headerLeft ) . eql ( left , `${ name } : header synchronized with workspace` ) ;
185+ }
186+ } ) . before ( async ( ) => createScheduler ( {
187+ dataSource : [ ] ,
188+ views : [ 'timelineDay' , 'timelineWeek' ] ,
189+ currentView : 'timelineDay' ,
190+ currentDate : new Date ( 2019 , 5 , 1 , 9 , 40 ) ,
191+ firstDayOfWeek : 0 ,
192+ startDayHour : 0 ,
193+ endDayHour : 20 ,
194+ height : 580 ,
195+ } ) ) ;
196+
197+ test ( 'ScrollTo works correctly in timeline RTL (native, sync header/workspace)' , async ( t ) => {
198+ const scheduler = new Scheduler ( '#container' ) ;
199+
200+ await scheduler . option ( 'currentView' , 'timelineWeek' ) ;
201+ await scheduler . option ( 'useNative' , true ) ;
202+ await scheduler . option ( 'rtlEnabled' , true ) ;
203+ await t . wait ( 200 ) ;
204+
205+ const getWSLeft = ClientFunction ( ( ) => ( $ ( '#container' ) as any ) . dxScheduler ( 'instance' ) . getWorkSpaceScrollable ( ) . scrollLeft ( ) ) ;
206+ const getHeaderLeft = ClientFunction ( ( ) => $ ( '.dx-scheduler-header-scrollable .dx-scrollable-container' ) . scrollLeft ( ) ) ;
207+
208+ const initialLeft = await getWSLeft ( ) ;
209+ const initialHeaderLeft = await getHeaderLeft ( ) ;
210+
211+ await t . expect ( initialLeft ) . eql ( initialHeaderLeft , 'timeline RTL: initial sync' ) ;
212+
213+ await scrollToDate ( ) ;
214+ await t . wait ( 300 ) ;
215+
216+ const left = await getWSLeft ( ) ;
217+ const headerLeft = await getHeaderLeft ( ) ;
218+
219+ await t
220+ . expect ( left ) . notEql ( initialLeft , 'timeline RTL: workspace left changed' )
221+ . expect ( headerLeft ) . eql ( left , 'timeline RTL: header synchronized' ) ;
222+ } ) . before ( async ( ) => createScheduler ( {
223+ dataSource : [ ] ,
224+ views : [ 'timelineWeek' ] ,
225+ currentView : 'timelineWeek' ,
226+ currentDate : new Date ( 2019 , 5 , 1 , 9 , 40 ) ,
227+ firstDayOfWeek : 0 ,
228+ startDayHour : 0 ,
229+ endDayHour : 20 ,
230+ height : 580 ,
231+ rtlEnabled : true ,
232+ } ) ) ;
0 commit comments