Skip to content

Commit 63ff096

Browse files
authored
CardView: cardHeader.visible property does not update in runtime (#30167)
1 parent e2945bf commit 63ff096

File tree

4 files changed

+66
-9
lines changed

4 files changed

+66
-9
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import CardView from 'devextreme-testcafe-models/cardView';
2+
import url from '../../../helpers/getPageUrl';
3+
import { createWidget } from '../../../helpers/createWidget';
4+
5+
fixture.disablePageReloads`CardView - Common Behavior`
6+
.page(url(__dirname, '../../container.html'));
7+
8+
test('cardHeader.visibility property should change on contentReady', async (t) => {
9+
const cardView = new CardView('#container');
10+
await t
11+
.expect(cardView.apiOption('cardHeader.visible'))
12+
.eql(true)
13+
.expect(cardView.getCard(0).getHeader().exists)
14+
.ok();
15+
}).before(async () => {
16+
await createWidget('dxCardView', {
17+
dataSource: [{ ID: 1 }],
18+
onContentReady(e) {
19+
e.component.option('cardHeader.visible', true);
20+
},
21+
});
22+
});

packages/devextreme/js/__internal/grids/new/grid_core/utils/tree/tree.test.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('OptionsController', () => {
120120
});
121121

122122
describe('mergeOptionTrees', () => {
123-
it('should only shallow copy root if path contains error at first place', () => {
123+
it('should create absent nodes if path contains error at first place', () => {
124124
const tree = { a: { b: { c: { extra: 'extra_node' } } }, d: { e: 2 } };
125125
const updatedTree = { a: { b: { c: { extra: 'update' } } }, d: { e: 2 } };
126126
const defaultTree = { a: { b: { c: { extra: 'default' } } } };
@@ -137,9 +137,10 @@ describe('OptionsController', () => {
137137
expect(result.a.b).toBe(tree.a.b);
138138
expect(result.a.b.c).toBe(tree.a.b.c);
139139
expect(result.a.b.c.extra).toBe(tree.a.b.c.extra);
140+
expect(result.wrong_path).toStrictEqual({ c: undefined });
140141
});
141142

142-
it('should shallow copy subtree path until faced the wrong node path', () => {
143+
it('should shallow copy subtree path and create absent nodes if faced the wrong node path', () => {
143144
const tree = { a: { b: { c: { extra: 'extra_node' } } }, d: { e: 2 } };
144145
const updatedTree = { a: { b: { c: { extra: 'update' } } }, d: { e: 2 } };
145146
const defaultTree = { a: { b: { c: { extra: 'default' } } } };
@@ -156,6 +157,41 @@ describe('OptionsController', () => {
156157
expect(result.a.b).not.toBe(tree.a.b);
157158
expect(result.a.b.c).toBe(tree.a.b.c);
158159
expect(result.a.b.c.extra).toBe(tree.a.b.c.extra);
160+
expect(result.a.b.wrong_path).toStrictEqual({ extra: undefined });
161+
});
162+
163+
it('should correctly create absent last nodes and sync their values', () => {
164+
const tree = { a: { b: { c: { extra: 'extra_node' } } }, d: { e: 2 } };
165+
const updatedTree = { a: { b: { c: { newProperty: 'test' } } }, d: { e: 2 } };
166+
const defaultTree = { a: { b: { c: { extra: 'default' } } } };
167+
168+
const result = mergeOptionTrees(
169+
tree,
170+
updatedTree,
171+
defaultTree,
172+
['a', 'b', 'c', 'newProperty'],
173+
);
174+
175+
expect(result).not.toBe(tree);
176+
expect(result.a).not.toBe(tree.a);
177+
expect(result.a.b).not.toBe(tree.a.b);
178+
expect(result.a.b.c).not.toBe(tree.a.b.c);
179+
expect(result.a.b.c.newProperty).toBe(updatedTree.a.b.c.newProperty);
180+
});
181+
182+
it('should correctly create absent middle nodes and sync their values', () => {
183+
const tree = { a: { b: { c: { extra: 'extra_node' } } }, d: { e: 2 } };
184+
const updatedTree = { a: { newB: { c: { newProperty: 'test' } } }, d: { e: 2 } };
185+
const defaultTree = { a: { b: { c: { extra: 'default' } } } };
186+
187+
const result = mergeOptionTrees(
188+
tree,
189+
updatedTree,
190+
defaultTree,
191+
['a', 'newB', 'c', 'newProperty'],
192+
);
193+
194+
expect(result.a.newB.c.newProperty).toBe(updatedTree.a.newB.c.newProperty);
159195
});
160196

161197
it('should deep copy applied value from updated tree', () => {

packages/devextreme/js/__internal/grids/new/grid_core/utils/tree/tree.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,9 @@ export const mergeOptionTrees = (
129129
pathToMerge: string[],
130130
): TreeNodeType => {
131131
const [lastNodePath] = pathToMerge.slice(-1);
132-
const result = shallowCopySubtreePath(internalTree, pathToMerge);
132+
const result = createOrShallowCopySubtreePath(internalTree, pathToMerge);
133133
const targetNodeParent = getTreeNodeParentByPath(result, pathToMerge);
134134

135-
// NOTE: If we don't find parent of the tree node to update -> do nothing
136-
if (!targetNodeParent) {
137-
return result;
138-
}
139-
140135
const newNodeValue = getTreeNodeByPath(publicTree, pathToMerge);
141136
const defaultNodeValue = getTreeNodeByPath(defaultTree, pathToMerge);
142137

packages/testcafe-models/cardView/card.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ export default class Card {
3838
return this.getFieldCaptionCell(fieldCaption).nextSibling();
3939
}
4040

41+
getHeader(): Selector {
42+
return this.element.find(`.${CLASS.header}`);
43+
}
44+
4145
getToolbarItem(index: number): Selector {
42-
return this.element.find(`.${CLASS.header}`).find('.dx-toolbar-item').nth(index);
46+
return this.getHeader().find('.dx-toolbar-item').nth(index);
4347
}
4448

4549
getHighlightedTexts(): Selector {

0 commit comments

Comments
 (0)