Skip to content

Commit 5ada0ea

Browse files
committed
test: Enhance assertions for Grid Store Interactions (#9021)
1 parent 6a39795 commit 5ada0ea

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

test/playwright/unit/grid/StoreInteractions.spec.mjs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,20 @@ test.describe('Grid & Store Interactions', () => {
200200

201201
const newFirstRow = grid.body.items.find(r => r.rowIndex === 0);
202202
expect(newFirstRow.record.name).toBe('New Row');
203+
204+
// 2. Verify VDOM State (The blueprint)
205+
// Access the cell for the 'name' column (index 1)
206+
const vdomCell = newFirstRow.vdom.cn[1];
207+
// The cell content might be direct html or a child node depending on renderer
208+
const vdomContent = vdomCell.html || vdomCell.cn?.[0]?.html || vdomCell.text;
209+
expect(vdomContent).toContain('New Row');
210+
211+
// 3. Verify VNode State (The simulated live DOM)
212+
// Access the cell node in the VNode tree
213+
const vnodeCell = newFirstRow.vnode.childNodes[1]; // Name column
214+
expect(vnodeCell.innerHTML).toContain('New Row');
203215

204-
// 2. Verify Deltas
216+
// 4. Verify Deltas
205217
const moveNodes = deltas.filter(d => d.action === 'moveNode');
206218
const insertNodes = deltas.filter(d => d.action === 'insertNode');
207219
const removeNodes = deltas.filter(d => d.action === 'removeNode');
@@ -231,6 +243,14 @@ test.describe('Grid & Store Interactions', () => {
231243
// Was 'Row 0', now 'Row 1' shifted up to index 0
232244
expect(newFirstRow.record.name).toBe('Row 1');
233245

246+
// Verify VDOM & VNode
247+
const vdomCell = newFirstRow.vdom.cn[1];
248+
const vdomContent = vdomCell.html || vdomCell.cn?.[0]?.html || vdomCell.text;
249+
expect(vdomContent).toContain('Row 1');
250+
251+
const vnodeCell = newFirstRow.vnode.childNodes[1];
252+
expect(vnodeCell.innerHTML).toContain('Row 1');
253+
234254
const moveNodes = deltas.filter(d => d.action === 'moveNode');
235255
const insertNodes = deltas.filter(d => d.action === 'insertNode');
236256
const removeNodes = deltas.filter(d => d.action === 'removeNode');
@@ -255,6 +275,13 @@ test.describe('Grid & Store Interactions', () => {
255275
const newFirstRow = grid.body.items.find(r => r.rowIndex === 0);
256276
expect(newFirstRow.record.name).toBe('Row 19'); // Last item is now first
257277

278+
// Verify VDOM & VNode
279+
const vdomCell = newFirstRow.vdom.cn[1];
280+
expect(vdomCell.html || vdomCell.cn?.[0]?.html).toContain('Row 19');
281+
282+
const vnodeCell = newFirstRow.vnode.childNodes[1];
283+
expect(vnodeCell.innerHTML).toContain('Row 19');
284+
258285
const moveNodes = deltas.filter(d => d.action === 'moveNode');
259286
const insertNodes = deltas.filter(d => d.action === 'insertNode');
260287
const removeNodes = deltas.filter(d => d.action === 'removeNode');
@@ -282,6 +309,18 @@ test.describe('Grid & Store Interactions', () => {
282309

283310
expect(grid.body.store.count).toBe(2);
284311

312+
// Verify Visible Row (Index 0)
313+
const visibleRow = grid.body.items.find(r => r.rowIndex === 0);
314+
expect(visibleRow.record.name).toBe('Row 0');
315+
expect(visibleRow.vdom.style.display).toBeNull(); // Should be visible (null removes display:none)
316+
317+
// Verify Hidden Row (Index 2 - effectively unused/recycled to empty)
318+
// With Fixed-DOM-Order, unused items in the pool have rowIndex = -1
319+
const hiddenRow = grid.body.items.find(r => r.rowIndex === -1);
320+
expect(hiddenRow).toBeDefined();
321+
expect(hiddenRow.vdom.style.display).toBe('none');
322+
expect(hiddenRow.vnode.style.display).toBe('none');
323+
285324
const moveNodes = deltas.filter(d => d.action === 'moveNode');
286325
const insertNodes = deltas.filter(d => d.action === 'insertNode');
287326
const removeNodes = deltas.filter(d => d.action === 'removeNode');

0 commit comments

Comments
 (0)