File tree Expand file tree Collapse file tree
e2e/testcafe-devextreme/tests/cardView
packages/devextreme/js/__internal/grids/new/grid_core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -532,3 +532,53 @@ const clearRemoteOperations = () => ClientFunction(() => {
532532 await clearRemoteOperations ( ) ;
533533 } ) ;
534534} ) ;
535+
536+ test ( 'remote operations: true -> should load data for each search value in header filter' , async ( t ) => {
537+ // arrange
538+ const cardView = new CardView ( CARD_VIEW_SELECTOR ) ;
539+ const filterIcon = cardView
540+ . getHeaderPanel ( )
541+ . getHeaderItem ( )
542+ . getFilterIcon ( ) ;
543+
544+ // act
545+ await t . click ( filterIcon ) ;
546+
547+ // assert
548+ const list = cardView . getHeaderFilterList ( ) ;
549+ await t . expect ( list . getItems ( ) . count ) . eql ( 10 ) ;
550+
551+ // act
552+ await t . typeText ( list . searchInput , 'A_1' ) ;
553+
554+ // assert
555+ await t . expect ( list . getItems ( ) . count ) . eql ( 1 ) ;
556+ await t . expect ( list . getItem ( 0 ) . text ) . eql ( 'A_1' ) ;
557+
558+ // act
559+ await t . typeText ( list . searchInput , '1' ) ;
560+
561+ // assert
562+ await t . expect ( list . getItems ( ) . count ) . eql ( 0 ) ;
563+ } ) . before ( async ( t ) => {
564+ await t . addRequestHooks ( remoteApiMock ) ;
565+ await createWidget ( 'dxCardView' , ( ) => ( {
566+ dataSource : {
567+ store : ( window as any ) . DevExpress . data . AspNet . createStore ( {
568+ key : 'id' ,
569+ loadUrl : 'https://api/data' ,
570+ } ) ,
571+ } ,
572+ columns : [ 'A' ] ,
573+ remoteOperations : true ,
574+ headerFilter : {
575+ visible : true ,
576+ search : {
577+ enabled : true ,
578+ } ,
579+ } ,
580+ height : 600 ,
581+ } ) ) ;
582+ } ) . after ( async ( t ) => {
583+ await t . removeRequestHooks ( remoteApiMock ) ;
584+ } ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,22 @@ export const remoteDataGroupedByA = new Array(10)
1414 } ) ) ;
1515
1616export const remoteApiMock = RequestMock ( )
17+ . onRequestTo ( / \/ a p i \/ d a t a \? .* g r o u p = .* f i l t e r = .* A _ 1 1 / )
18+ . respond (
19+ {
20+ data : remoteDataGroupedByA . filter ( ( item ) => item . key . includes ( 'A_11' ) ) ,
21+ } ,
22+ 200 ,
23+ { 'access-control-allow-origin' : '*' } ,
24+ )
25+ . onRequestTo ( / \/ a p i \/ d a t a \? .* g r o u p = .* f i l t e r = .* A _ 1 / )
26+ . respond (
27+ {
28+ data : remoteDataGroupedByA . filter ( ( item ) => item . key . includes ( 'A_1' ) ) ,
29+ } ,
30+ 200 ,
31+ { 'access-control-allow-origin' : '*' } ,
32+ )
1733 . onRequestTo ( / \/ a p i \/ d a t a \? .* g r o u p = / )
1834 . respond (
1935 {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import type { OptionWithChanges } from '@ts/grids/new/grid_core/options_controll
1010import { OptionsController } from '../options_controller/options_controller' ;
1111import { getTreeNodeByPath } from '../utils/tree/index' ;
1212import { updateColumnSettings } from './columns_settings/index' ;
13- import { IGNORE_COLUMN_OPTION_NAMES } from './const' ;
13+ import { COLUMNS_OBJ_COMPARE_DEPTH , IGNORE_COLUMN_OPTION_NAMES } from './const' ;
1414import type { ColumnProperties , ColumnSettings , PreNormalizedColumn } from './options' ;
1515import type { Column , ColumnsConfigurationFromData , VisibleColumn } from './types' ;
1616import {
@@ -176,7 +176,7 @@ export class ColumnsController {
176176 newValue : unknown ,
177177 prevValue : unknown ,
178178 ) : void {
179- if ( ! equalByValue ( prevValue , newValue , { maxDepth : 5 } ) ) {
179+ if ( ! equalByValue ( prevValue , newValue , { maxDepth : COLUMNS_OBJ_COMPARE_DEPTH } ) ) {
180180 const fullOptionPath = `columns[${ columnIndex } ].${ optionName } ` ;
181181 this . options . notifyColumnOptionChanged ( fullOptionPath , newValue , prevValue ) ;
182182 }
Original file line number Diff line number Diff line change 11export const IGNORE_COLUMN_OPTION_NAMES = {
22 selector : true ,
33} ;
4+
5+ export const COLUMNS_OBJ_COMPARE_DEPTH = 5 ;
Original file line number Diff line number Diff line change 1+ export const FILTER_OBJ_COMPARE_DEPTH = 6 ;
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import { normalizeFilterWithSelectors } from '../filtering/utils';
1717import { LifeCycleController } from '../lifecycle/controller' ;
1818import { OptionsController } from '../options_controller/options_controller' ;
1919import { SortingController } from '../sorting_controller/index' ;
20+ import { FILTER_OBJ_COMPARE_DEPTH } from './const' ;
2021import { StoreLoadAdapter } from './store_load_adapter/index' ;
2122import type { DataObject , Key } from './types' ;
2223import {
@@ -30,8 +31,6 @@ import {
3031 updateItemsImmutable ,
3132} from './utils' ;
3233
33- const FILTER_OBJ_COMPARE_DEPTH = 6 ;
34-
3534export class DataController {
3635 private readonly pendingLocalOperations = { } ;
3736
Original file line number Diff line number Diff line change @@ -83,6 +83,22 @@ describe('DataController', () => {
8383 expect ( originFn ) . toHaveBeenCalledTimes ( 2 ) ;
8484 } ) ;
8585
86+ it ( 'should call origin fn if args differ on deep value' , async ( ) => {
87+ const firstArgs = { filter : [ [ 'text' , 'contains' , 'tra' ] ] } ;
88+ const secondArgs = { filter : [ [ 'text' , 'contains' , 'travel' ] ] } ;
89+ const originFn = jest
90+ . fn ( )
91+ . mockImplementation ( ( ) => createDeferred ( ) . resolve ( ) ) ;
92+ const decoratedFn = deferredCache (
93+ originFn as ( args : ( typeof firstArgs | typeof secondArgs ) ) => DeferredObj < void > ,
94+ ) ;
95+
96+ await decoratedFn ( firstArgs ) ;
97+ await decoratedFn ( secondArgs ) ;
98+
99+ expect ( originFn ) . toHaveBeenCalledTimes ( 2 ) ;
100+ } ) ;
101+
86102 it ( 'should return result from origin fn' , async ( ) => {
87103 const expectedResult = { a : 'A' } ;
88104 const originFn = jest
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { equalByValue } from '@js/core/utils/common';
22import type { DeferredObj } from '@js/core/utils/deferred' ;
33import { Deferred } from '@js/core/utils/deferred' ;
44
5+ import { FILTER_OBJ_COMPARE_DEPTH } from './const' ;
6+
57// @ts -expect-error bad deferred ctor type
68// eslint-disable-next-line @typescript-eslint/no-explicit-any
79const createDeferred = ( ) : any => new Deferred ( ) ;
@@ -19,7 +21,7 @@ export const deferredCache = <TArgs, TResult>(
1921 ) : DeferredObj < TResult > => {
2022 const hasPreviousCall = lastArgs !== null && cachedResult !== null ;
2123 const isArgsSame = hasPreviousCall
22- ? equalByValue ( lastArgs , args )
24+ ? equalByValue ( lastArgs , args , { maxDepth : FILTER_OBJ_COMPARE_DEPTH } )
2325 : false ;
2426
2527 if ( hasPreviousCall && isArgsSame ) {
You can’t perform that action at this time.
0 commit comments