@@ -12,6 +12,15 @@ describe('Example - Auto scroll when dragging', { retries: 1 }, () => {
1212 fullTitles . push ( 'Mock' + i ) ;
1313 }
1414
15+ beforeEach ( ( ) => {
16+ // add a serve mode to avoid adding the GitHub Stars link since that can slowdown Cypress considerably
17+ // because it keeps waiting for it to load, we also preserve the cookie for all other tests
18+ cy . setCookie ( 'serve-mode' , 'cypress' ) ;
19+
20+ // create a console.log spy for later use
21+ cy . window ( ) . then ( ( win ) => cy . spy ( win . console , 'log' ) ) ;
22+ } ) ;
23+
1524 it ( 'should load Example' , ( ) => {
1625 cy . visit ( `${ Cypress . config ( 'baseUrl' ) } /examples/example-auto-scroll-when-dragging.html` ) ;
1726 } ) ;
@@ -299,4 +308,32 @@ describe('Example - Auto scroll when dragging', { retries: 1 }, () => {
299308 cy . get ( '#myGrid2 div.slick-row[style*="top: 0px;"]' ) . should ( 'have.length' , 1 ) ;
300309 } ) ;
301310
311+ describe ( 'Frozen Columns' , ( ) => {
312+ it ( 'should set 3 frozen columns in first grid' , ( ) => {
313+ cy . get ( '[data-test="frozen-column-count"]' ) . clear ( ) . type ( '3' ) ;
314+ cy . get ( '[data-test="set-frozen-columns-btn"]' ) . click ( ) ;
315+
316+ cy . get ( '#myGrid .slick-pane-left .slick-header-column' ) . should ( 'have.length' , 4 ) ;
317+ cy . get ( '#myGrid .slick-pane-right .slick-header-column' ) . should ( 'have.length' , 34 ) ;
318+ } ) ;
319+
320+ it ( 'should try to set frozen columns wider than possible and expect an error and abort of the execution' , ( ) => {
321+ const stub = cy . stub ( ) ;
322+ cy . on ( 'window:alert' , stub ) ;
323+ cy . get ( '[data-test="frozen-column-count"]' ) . clear ( ) . type ( '12' ) ;
324+ cy . get ( '[data-test="set-frozen-columns-btn"]' )
325+ . click ( )
326+ . then ( ( ) => {
327+ expect ( stub . getCall ( 0 ) ) . to . be . calledWith (
328+ '[SlickGrid] You are trying to freeze/pin more columns than the grid can support. ' +
329+ 'Make sure to have less columns pinned (on the left) than the actual visible grid width. ' +
330+ 'Also, please remember that only the columns on the right are scrollable and the pinned columns are not.'
331+ ) ;
332+
333+ // it should still have previous pinning
334+ cy . get ( '#myGrid .slick-pane-left .slick-header-column' ) . should ( 'have.length' , 4 ) ;
335+ cy . get ( '#myGrid .slick-pane-right .slick-header-column' ) . should ( 'have.length' , 34 ) ;
336+ } ) ;
337+ } ) ;
338+ } ) ;
302339} ) ;
0 commit comments