Skip to content

Commit b94dbff

Browse files
vursenclaude
andauthored
test: cover cell content attach and detach on column add/remove (#12181)
When a column is removed, the grid also removes the column's `<vaadin-grid-cell-content>` elements from its light DOM, and adds them back when the column is added again. This behavior wasn't covered by tests for header and footer cells. The declarative header/footer rendering refactor changes how header and footer cell content is managed, so this adds tests to lock in the current behavior first. Extracted from #12134 Part of #10789 --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 315c748 commit b94dbff

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

packages/grid/test/column.test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,46 @@ describe('column', () => {
503503
});
504504
});
505505

506+
describe('cell content attach and detach', () => {
507+
['header', 'body', 'footer'].forEach((sectionName) => {
508+
let content;
509+
510+
beforeEach(() => {
511+
switch (sectionName) {
512+
case 'header':
513+
content = getHeaderCellContent(grid, 1, 0);
514+
break;
515+
case 'footer':
516+
content = getContainerCellContent(grid.$.footer, 0, 0);
517+
break;
518+
default:
519+
content = getBodyCellContent(grid, 0, 0);
520+
}
521+
});
522+
523+
it(`should remove ${sectionName} cell content from the grid when column is removed`, async () => {
524+
column.remove();
525+
await nextFrame();
526+
527+
expect(content.parentElement).to.be.null;
528+
});
529+
});
530+
531+
it('should render cell content when column is added back', async () => {
532+
const group = column.parentElement;
533+
column.remove();
534+
await nextFrame();
535+
536+
group.insertBefore(column, group.firstElementChild);
537+
await nextFrame();
538+
flushGrid(grid);
539+
540+
expect(getHeaderCellContent(grid, 1, 0).textContent).to.equal('header1');
541+
expect(getContainerCellContent(grid.$.footer, 0, 0).textContent).to.equal('footer1');
542+
expect(getBodyCellContent(grid, 0, 0).textContent).to.equal('cell');
543+
});
544+
});
545+
506546
it('should not throw an exception when size is changed after removing column', () => {
507547
expect(grid.size).to.equal(10);
508548
expect(column.isConnected).to.be.true;

0 commit comments

Comments
 (0)