@@ -2,11 +2,13 @@ import { createScreenshotsComparer } from 'devextreme-screenshot-comparer';
22import Scheduler from 'devextreme-testcafe-models/scheduler' ;
33import { createWidget } from '../../../../../helpers/createWidget' ;
44import url from '../../../../../helpers/getPageUrl' ;
5+ import { generateOptionMatrix } from '../../../../../helpers/generateOptionMatrix' ;
6+ import { changeTheme } from '../../../../../helpers/changeTheme' ;
57
68fixture . disablePageReloads `Appointments collector`
79 . page ( url ( __dirname , '../../../../container.html' ) ) ;
810
9- test ( 'Appointment collector has correct offset when adaptivityEnabled=true' , async ( t ) => {
11+ test ( 'Appointment collector has correct offset when adaptivityEnabled=true (T1024299) ' , async ( t ) => {
1012 const scheduler = new Scheduler ( '#container' ) ;
1113
1214 const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
@@ -29,3 +31,111 @@ test('Appointment collector has correct offset when adaptivityEnabled=true', asy
2931 } ] ,
3032 height : 300 ,
3133} ) ) ;
34+
35+ const getSchedulerBaseOptions = ( view : string , count = 20 ) => {
36+ const day = [ 'workWeek' , 'timelineWorkWeek' ] . includes ( view ) ? 2 : 1 ;
37+ const allDayAppointments = Array ( Math . round ( count / 4 ) ) . fill ( {
38+ allDay : true ,
39+ text : 'text' ,
40+ startDate : new Date ( 2021 , 7 , day , 0 ) ,
41+ endDate : new Date ( 2021 , 7 , day , 2 ) ,
42+ } ) ;
43+ const regularAppointments = Array ( Math . round ( ( count * 3 ) / 4 ) ) . fill ( {
44+ text : 'text' ,
45+ startDate : new Date ( 2021 , 7 , day , 0 ) ,
46+ endDate : new Date ( 2021 , 7 , day , 2 ) ,
47+ } ) ;
48+ const width = [ 'month' , 'week' , 'workWeek' ] . includes ( view ) ? 800 : 500 ;
49+ const height = [ 'month' ] . includes ( view ) ? 500 : 300 ;
50+
51+ return {
52+ currentDate : new Date ( 2021 , 7 , day ) ,
53+ views : [ view ] ,
54+ currentView : view ,
55+ dataSource : [ ...allDayAppointments , ...regularAppointments ] ,
56+ height,
57+ width,
58+ } ;
59+ } ;
60+
61+ generateOptionMatrix ( {
62+ view : [ 'day' , 'week' , 'workWeek' , 'month' , 'timelineDay' , 'timelineWeek' , 'timelineWorkWeek' , 'timelineMonth' ] ,
63+ theme : [ 'generic.light' , 'material.blue.light' , 'fluent.blue.light' , 'generic.light.compact' , 'material.blue.light.compact' , 'fluent.blue.light.compact' ] ,
64+ adaptivityEnabled : [ false , true ] ,
65+ } ) . forEach ( ( { view, theme, adaptivityEnabled } ) => {
66+ test ( `Appointment collector has correct offset when view=${ view } adaptivityEnabled=${ adaptivityEnabled } theme=${ theme } ` , async ( t ) => {
67+ const scheduler = new Scheduler ( '#container' ) ;
68+
69+ const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
70+
71+ await t
72+ . expect ( await takeScreenshot ( `appointment-collector-${ view } -adapt(${ adaptivityEnabled } )-${ theme } .png` , scheduler . workSpace ) )
73+ . ok ( )
74+
75+ . expect ( compareResults . isValid ( ) )
76+ . ok ( compareResults . errorMessages ( ) ) ;
77+ } ) . before ( async ( ) => {
78+ await changeTheme ( theme ) ;
79+
80+ return createWidget ( 'dxScheduler' , {
81+ adaptivityEnabled,
82+ ...getSchedulerBaseOptions ( view ) ,
83+ } ) ;
84+ } ) . after ( async ( ) => {
85+ await changeTheme ( 'generic.light' ) ;
86+ } ) ;
87+ } ) ;
88+
89+ [ 'generic.light' , 'material.blue.light' , 'fluent.blue.light' ] . forEach ( ( theme ) => {
90+ test ( `Appointment collector has correct offset when month view with double interval theme=${ theme } ` , async ( t ) => {
91+ const scheduler = new Scheduler ( '#container' ) ;
92+
93+ const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
94+
95+ await t
96+ . expect ( await takeScreenshot ( `appointment-collector-month-double-interval-${ theme } .png` , scheduler . workSpace ) )
97+ . ok ( )
98+
99+ . expect ( compareResults . isValid ( ) )
100+ . ok ( compareResults . errorMessages ( ) ) ;
101+ } ) . before ( async ( ) => {
102+ await changeTheme ( theme ) ;
103+
104+ return createWidget ( 'dxScheduler' , {
105+ ...getSchedulerBaseOptions ( 'month' ) ,
106+ views : [ { type : 'month' , intervalCount : 2 } ] ,
107+ } ) ;
108+ } ) . after ( async ( ) => {
109+ await changeTheme ( 'generic.light' ) ;
110+ } ) ;
111+ } ) ;
112+
113+ generateOptionMatrix ( {
114+ view : [ 'day' , 'week' , 'workWeek' , 'month' , 'timelineDay' , 'timelineWeek' , 'timelineWorkWeek' , 'timelineMonth' ] ,
115+ variants : [
116+ { maxAppointmentsPerCell : 'auto' , rtlEnabled : false } ,
117+ { maxAppointmentsPerCell : 'auto' , rtlEnabled : true } ,
118+ { maxAppointmentsPerCell : 0 , rtlEnabled : false } ,
119+ { maxAppointmentsPerCell : 2 , rtlEnabled : false } ,
120+ { maxAppointmentsPerCell : 'unlimited' , rtlEnabled : false } ,
121+ ] ,
122+ } ) . forEach ( ( {
123+ view, variants : { maxAppointmentsPerCell, rtlEnabled } ,
124+ } ) => {
125+ test ( `Appointment collector has correct offset when view=${ view } maxAppointmentsPerCell=${ maxAppointmentsPerCell } rtlEnabled=${ rtlEnabled } ` , async ( t ) => {
126+ const scheduler = new Scheduler ( '#container' ) ;
127+
128+ const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
129+
130+ await t
131+ . expect ( await takeScreenshot ( `appointment-collector-${ view } -${ maxAppointmentsPerCell } -rtl(${ rtlEnabled } ).png` , scheduler . workSpace ) )
132+ . ok ( )
133+
134+ . expect ( compareResults . isValid ( ) )
135+ . ok ( compareResults . errorMessages ( ) ) ;
136+ } ) . before ( async ( ) => createWidget ( 'dxScheduler' , {
137+ maxAppointmentsPerCell,
138+ rtlEnabled,
139+ ...getSchedulerBaseOptions ( view , maxAppointmentsPerCell === 'unlimited' ? 8 : 20 ) ,
140+ } ) ) ;
141+ } ) ;
0 commit comments