Skip to content

Commit e637d1a

Browse files
authored
Merge branch '26_1' into issue-4485_26_1
2 parents aa4297a + 92490a7 commit e637d1a

8 files changed

Lines changed: 91 additions & 5 deletions

File tree

e2e/testcafe-devextreme/tests/cardView/headerFilter/remote.functional.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
});

e2e/testcafe-devextreme/tests/cardView/helpers/remoteApiMock.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ export const remoteDataGroupedByA = new Array(10)
1414
}));
1515

1616
export const remoteApiMock = RequestMock()
17+
.onRequestTo(/\/api\/data\?.*group=.*filter=.*A_11/)
18+
.respond(
19+
{
20+
data: remoteDataGroupedByA.filter((item) => item.key.includes('A_11')),
21+
},
22+
200,
23+
{ 'access-control-allow-origin': '*' },
24+
)
25+
.onRequestTo(/\/api\/data\?.*group=.*filter=.*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(/\/api\/data\?.*group=/)
1834
.respond(
1935
{

packages/devextreme/js/__internal/grids/new/grid_core/columns_controller/columns_controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { OptionWithChanges } from '@ts/grids/new/grid_core/options_controll
1010
import { OptionsController } from '../options_controller/options_controller';
1111
import { getTreeNodeByPath } from '../utils/tree/index';
1212
import { 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';
1414
import type { ColumnProperties, ColumnSettings, PreNormalizedColumn } from './options';
1515
import type { Column, ColumnsConfigurationFromData, VisibleColumn } from './types';
1616
import {
@@ -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
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export const IGNORE_COLUMN_OPTION_NAMES = {
22
selector: true,
33
};
4+
5+
export const COLUMNS_OBJ_COMPARE_DEPTH = 5;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const FILTER_OBJ_COMPARE_DEPTH = 6;

packages/devextreme/js/__internal/grids/new/grid_core/data_controller/data_controller.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { normalizeFilterWithSelectors } from '../filtering/utils';
1717
import { LifeCycleController } from '../lifecycle/controller';
1818
import { OptionsController } from '../options_controller/options_controller';
1919
import { SortingController } from '../sorting_controller/index';
20+
import { FILTER_OBJ_COMPARE_DEPTH } from './const';
2021
import { StoreLoadAdapter } from './store_load_adapter/index';
2122
import type { DataObject, Key } from './types';
2223
import {
@@ -30,8 +31,6 @@ import {
3031
updateItemsImmutable,
3132
} from './utils';
3233

33-
const FILTER_OBJ_COMPARE_DEPTH = 6;
34-
3534
export class DataController {
3635
private readonly pendingLocalOperations = {};
3736

packages/devextreme/js/__internal/grids/new/grid_core/data_controller/deferred_cache.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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

packages/devextreme/js/__internal/grids/new/grid_core/data_controller/deferred_cache.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { equalByValue } from '@js/core/utils/common';
22
import type { DeferredObj } from '@js/core/utils/deferred';
33
import { 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
79
const 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) {

0 commit comments

Comments
 (0)