@@ -2,6 +2,7 @@ import { ClientFunction, Selector } from 'testcafe';
22import { createScreenshotsComparer } from 'devextreme-screenshot-comparer' ;
33import DataGrid from 'devextreme-testcafe-models/dataGrid' ;
44import { ClassNames } from 'devextreme-testcafe-models/dataGrid/classNames' ;
5+ import { DataGridScrollMode } from 'devextreme/ui/data_grid' ;
56import { insertStylesheetRulesToPage } from '../../../helpers/domUtils' ;
67import url from '../../../helpers/getPageUrl' ;
78import { createWidget } from '../../../helpers/createWidget' ;
@@ -1545,72 +1546,73 @@ test('Last group should not disappear after collapsing another subgroup with vir
15451546
15461547// T1152498
15471548// TODO: fix unstable tests
1548- // ['infinite', 'virtual'].forEach((scrollingMode) => {
1549- // eslint-disable-next-line @stylistic/max-len
1550- // test.meta({ browserSize: [900, 600] })(`${scrollingMode} scrolling - the markup should be correct for continuous scrolling when there is a fixed column with cellTemplate (React)`, async (t) => {
1551- // // arrange
1552- // const dataGrid = new DataGrid('#container');
1553- // const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
1554- //
1555- // // act
1556- // await dataGrid.scrollTo({ y: 200 });
1557- // await t.wait(100);
1558- // await dataGrid.scrollTo({ y: 400 });
1559- // await t.wait(300);
1560- //
1561- // // assert
1562- // await t
1563- // .expect(await takeScreenshot(`grid-${scrollingMode}-scrolling-T1152498.png`, '#container'))
1564- // .ok()
1565- // .expect(compareResults.isValid())
1566- // .ok(compareResults.errorMessages());
1567- // }).before(async (t) => {
1568- // await createWidget('dxDataGrid', {
1569- // dataSource: [...new Array(500)].map((_, index) => ({ id: index, text: `item ${index}` })),
1570- // keyExpr: 'id',
1571- // height: 440,
1572- // width: 800,
1573- // renderAsync: false,
1574- // templatesRenderAsynchronously: true,
1575- // columnFixing: {
1576- // // @ts -expect-error private option
1577- // legacyMode: true,
1578- // },
1579- // customizeColumns(columns) {
1580- // columns[0].width = 70;
1581- // columns[0].fixed = true;
1582- // columns[0].cellTemplate = '#test';
1583- // },
1584- // scrolling: {
1585- // mode: scrollingMode,
1586- // },
1587- // });
1588- //
1589- // await t.wait(100);
1590- //
1591- // // simulating async rendering in React
1592- // await ClientFunction(() => {
1593- // const dataGrid = ($('#container') as any).dxDataGrid('instance');
1594- //
1595- // // eslint-disable-next-line no-underscore-dangle
1596- // dataGrid.getView('rowsView')._templatesCache = {};
1597- //
1598- // // eslint-disable-next-line no-underscore-dangle
1599- // dataGrid._getTemplate = () => ({
1600- // render(options) {
1601- // setTimeout(() => {
1602- // ($(options.container) as any).append(($('<div/>') as any).text(options.model.value));
1603- // options.deferred?.resolve();
1604- // }, 200);
1605- // },
1606- // });
1607- //
1608- // dataGrid.repaint();
1609- // })();
1610- //
1611- // await t.wait(300);
1612- // });
1613- // });
1549+ [ 'infinite' , 'virtual' ] . forEach ( ( scrollingMode : DataGridScrollMode ) => {
1550+ test . meta ( {
1551+ browserSize : [ 900 , 600 ] ,
1552+ } ) ( `${ scrollingMode } scrolling - the markup should be correct for continuous scrolling when there is a fixed column with cellTemplate (React)` , async ( t ) => {
1553+ // arrange
1554+ const dataGrid = new DataGrid ( '#container' ) ;
1555+ const { takeScreenshot, compareResults } = createScreenshotsComparer ( t ) ;
1556+
1557+ // act
1558+ await dataGrid . scrollTo ( t , { y : 200 } ) ;
1559+ await t . wait ( 100 ) ;
1560+ await dataGrid . scrollTo ( t , { y : 400 } ) ;
1561+ await t . wait ( 500 ) ;
1562+
1563+ // assert
1564+ await testScreenshot ( t , takeScreenshot , `grid-${ scrollingMode } -scrolling-T1152498.png` , { element : '#container' } ) ;
1565+
1566+ await t
1567+ . expect ( compareResults . isValid ( ) )
1568+ . ok ( compareResults . errorMessages ( ) ) ;
1569+ } ) . before ( async ( t ) => {
1570+ await createWidget ( 'dxDataGrid' , {
1571+ dataSource : [ ...new Array ( 500 ) ] . map ( ( _ , index ) => ( { id : index , text : `item ${ index } ` } ) ) ,
1572+ keyExpr : 'id' ,
1573+ height : 440 ,
1574+ width : 800 ,
1575+ renderAsync : false ,
1576+ templatesRenderAsynchronously : true ,
1577+ columnFixing : {
1578+ // @ts -expect-error private option
1579+ legacyMode : true ,
1580+ } ,
1581+ customizeColumns ( columns ) {
1582+ columns [ 0 ] . width = 70 ;
1583+ columns [ 0 ] . fixed = true ;
1584+ columns [ 0 ] . cellTemplate = '#test' ;
1585+ } ,
1586+ scrolling : {
1587+ mode : scrollingMode ,
1588+ } ,
1589+ } ) ;
1590+
1591+ await t . wait ( 100 ) ;
1592+
1593+ // simulating async rendering in React
1594+ await ClientFunction ( ( ) => {
1595+ const dataGrid = ( $ ( '#container' ) as any ) . dxDataGrid ( 'instance' ) ;
1596+
1597+ // eslint-disable-next-line no-underscore-dangle
1598+ dataGrid . getView ( 'rowsView' ) . _templatesCache = { } ;
1599+
1600+ // eslint-disable-next-line no-underscore-dangle
1601+ dataGrid . _getTemplate = ( ) => ( {
1602+ render ( options ) {
1603+ setTimeout ( ( ) => {
1604+ ( $ ( options . container ) as any ) . append ( ( $ ( '<div/>' ) as any ) . text ( options . model . value ) ) ;
1605+ options . deferred ?. resolve ( ) ;
1606+ } , 200 ) ;
1607+ } ,
1608+ } ) ;
1609+
1610+ dataGrid . repaint ( ) ;
1611+ } ) ( ) ;
1612+
1613+ await t . wait ( 300 ) ;
1614+ } ) ;
1615+ } ) ;
16141616
16151617test ( 'Editors should keep changes after being scrolled out of sight (T1145698)' , async ( t ) => {
16161618 const dataGrid = new DataGrid ( '#container' ) ;
0 commit comments