11import { createScreenshotsComparer } from 'devextreme-screenshot-comparer' ;
22import { Selector } from 'testcafe' ;
33import TreeView from 'devextreme-testcafe-models/treeView' ;
4- import { testScreenshot , isMaterialBased } from '../../../helpers/themeUtils' ;
4+ import { testScreenshot } from '../../../helpers/themeUtils' ;
55import url from '../../../helpers/getPageUrl' ;
66import { createWidget } from '../../../helpers/createWidget' ;
7- // eslint-disable-next-line import/extensions
8- import { employees } from './data.js' ;
7+ import { employees } from './data' ;
98import { setAttribute } from '../../../helpers/domUtils' ;
109
1110fixture . disablePageReloads `TreeView`
@@ -149,13 +148,7 @@ test('TreeView: height should be calculated correctly when searchEnabled is true
149148
150149 await scrollable . scrollTo ( { top : 1000 } ) ;
151150
152- await testScreenshot ( t , takeScreenshot , 'TreeView scrollable has correct height.png' , {
153- element : '#container' ,
154- shouldTestInCompact : true ,
155- compactCallBack : async ( ) => {
156- await scrollable . scrollTo ( { top : 1000 } ) ;
157- } ,
158- } ) ;
151+ await testScreenshot ( t , takeScreenshot , 'TreeView scrollable has correct height.png' , { element : '#container' } ) ;
159152
160153 await t
161154 . expect ( compareResults . isValid ( ) )
@@ -172,17 +165,11 @@ test('TreeView: height should be calculated correctly when searchEnabled is true
172165
173166[ true , false ] . forEach ( ( rtlEnabled ) => {
174167 [ 'selectAll' , 'normal' , 'none' ] . forEach ( ( showCheckBoxesMode ) => {
175- test ( `TreeView-selectAll,showCheckBoxesMode=${ showCheckBoxesMode } ` , async ( t ) => {
168+ const testName = `TreeView selection showCheckBoxesMode=${ showCheckBoxesMode } ,rtl=${ rtlEnabled } ` ;
169+ test ( testName , async ( t ) => {
176170 const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
177171
178- const screenshotName = `TreeView selection cbm=${ showCheckBoxesMode } ,rtl=${ rtlEnabled } .png` ;
179-
180- await testScreenshot ( t , takeScreenshot , screenshotName , { element : '#container' } ) ;
181-
182- if ( ! isMaterialBased ( ) ) {
183- await testScreenshot ( t , takeScreenshot , screenshotName , { element : '#container' , theme : 'generic.dark' } ) ;
184- await testScreenshot ( t , takeScreenshot , screenshotName , { element : '#container' , theme : 'generic.contrast' } ) ;
185- }
172+ await testScreenshot ( t , takeScreenshot , `${ testName } .png` , { element : '#container' } ) ;
186173
187174 await t
188175 . expect ( compareResults . isValid ( ) )
@@ -204,48 +191,44 @@ test('TreeView: height should be calculated correctly when searchEnabled is true
204191 } ) ;
205192} ) ;
206193
207- [ true , false ] . forEach ( ( rtlEnabled ) => {
208- [ 'normal' , 'none' ] . forEach ( ( showCheckBoxesMode ) => {
209- test ( `TreeView with custom expander icons,showCheckBoxesMode=${ showCheckBoxesMode } ` , async ( t ) => {
210- const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
211-
212- const screenshotName = `Treeview with custom icons cbm=${ showCheckBoxesMode } ,rtl=${ rtlEnabled } .png` ;
213-
214- await t . click ( Selector ( '.dx-treeview-item' ) . nth ( 1 ) ) ;
215-
216- await testScreenshot ( t , takeScreenshot , screenshotName , { element : '#container' , shouldTestInCompact : true } ) ;
217-
218- await t
219- . expect ( compareResults . isValid ( ) )
220- . ok ( compareResults . errorMessages ( ) ) ;
221- } ) . before ( async ( ) => createWidget ( 'dxTreeView' , {
222- items : employees ,
223- width : 300 ,
224- showCheckBoxesMode,
225- rtlEnabled,
226- expandIcon : 'add' ,
227- collapseIcon : 'minus' ,
228- itemTemplate ( item ) {
229- return `<div>${ item . fullName } (${ item . position } )</div>` ;
230- } ,
231- } ) ) ;
232- } ) ;
194+ [ 'normal' , 'none' ] . forEach ( ( showCheckBoxesMode ) => {
195+ const testName = `Treeview with custom icons showCheckBoxesMode=${ showCheckBoxesMode } ` ;
196+ test ( testName , async ( t ) => {
197+ const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
198+
199+ await t . click ( Selector ( '.dx-treeview-item' ) . nth ( 1 ) ) ;
200+
201+ await testScreenshot ( t , takeScreenshot , `${ testName } .png` , { element : '#container' } ) ;
202+
203+ await t
204+ . expect ( compareResults . isValid ( ) )
205+ . ok ( compareResults . errorMessages ( ) ) ;
206+ } ) . before ( async ( ) => createWidget ( 'dxTreeView' , {
207+ items : employees ,
208+ width : 300 ,
209+ showCheckBoxesMode,
210+ expandIcon : 'add' ,
211+ collapseIcon : 'minus' ,
212+ itemTemplate ( item ) {
213+ return `<div>${ item . fullName } (${ item . position } )</div>` ;
214+ } ,
215+ } ) ) ;
233216} ) ;
234217
235218test ( 'TreeView checkBox focus styles' , async ( t ) => {
236219 const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
237220
238221 await t . pressKey ( 'tab' ) ;
239222
240- await testScreenshot ( t , takeScreenshot , 'Treeview indeterminate CheckBox focus.png' , { element : '#container' , shouldTestInCompact : true } ) ;
223+ await testScreenshot ( t , takeScreenshot , 'Treeview indeterminate CheckBox focus.png' , { element : '#container' } ) ;
241224
242225 await t . pressKey ( 'down' ) ;
243226
244- await testScreenshot ( t , takeScreenshot , 'Treeview checked CheckBox focus.png' , { element : '#container' , shouldTestInCompact : true } ) ;
227+ await testScreenshot ( t , takeScreenshot , 'Treeview checked CheckBox focus.png' , { element : '#container' } ) ;
245228
246229 await t . pressKey ( 'down' ) ;
247230
248- await testScreenshot ( t , takeScreenshot , 'Treeview unchecked CheckBox focus.png' , { element : '#container' , shouldTestInCompact : true } ) ;
231+ await testScreenshot ( t , takeScreenshot , 'Treeview unchecked CheckBox focus.png' , { element : '#container' } ) ;
249232
250233 await t
251234 . expect ( compareResults . isValid ( ) )
0 commit comments