From 2f860eb67322cf5c310b4b9160241b402497e951 Mon Sep 17 00:00:00 2001 From: Sergey Vinogradov Date: Fri, 17 Jul 2026 17:03:31 +0400 Subject: [PATCH 1/3] test: cover cell content attach and detach on column add/remove Co-Authored-By: Claude Fable 5 --- packages/grid/test/column.test.js | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/packages/grid/test/column.test.js b/packages/grid/test/column.test.js index 2bca9e81ca2..d0d8e6f8742 100644 --- a/packages/grid/test/column.test.js +++ b/packages/grid/test/column.test.js @@ -503,6 +503,49 @@ describe('column', () => { }); }); + describe('cell content attach and detach', () => { + it('should remove header cell content from the grid when column is removed', async () => { + const content = getHeaderCellContent(grid, 1, 0); + + column.remove(); + await nextFrame(); + + expect(content.parentElement).to.be.null; + }); + + it('should remove footer cell content from the grid when column is removed', async () => { + const content = getContainerCellContent(grid.$.footer, 0, 0); + + column.remove(); + await nextFrame(); + + expect(content.parentElement).to.be.null; + }); + + it('should remove body cell content from the grid when column is removed', async () => { + const content = getBodyCellContent(grid, 0, 0); + + column.remove(); + await nextFrame(); + + expect(content.parentElement).to.be.null; + }); + + it('should render cell content when column is added back', async () => { + const group = column.parentElement; + column.remove(); + await nextFrame(); + + group.insertBefore(column, group.firstElementChild); + await nextFrame(); + flushGrid(grid); + + expect(getHeaderCellContent(grid, 1, 0).textContent).to.equal('header1'); + expect(getContainerCellContent(grid.$.footer, 0, 0).textContent).to.equal('footer1'); + expect(getBodyCellContent(grid, 0, 0).textContent).to.equal('cell'); + }); + }); + it('should not throw an exception when size is changed after removing column', () => { expect(grid.size).to.equal(10); expect(column.isConnected).to.be.true; From 3e1881b1bc37a7265f6f4d6529fba3c4bfa5f642 Mon Sep 17 00:00:00 2001 From: Sergey Vinogradov Date: Fri, 17 Jul 2026 17:21:58 +0400 Subject: [PATCH 2/3] test: iterate over sections in cell content removal tests Co-Authored-By: Claude Fable 5 --- packages/grid/test/column.test.js | 40 ++++++++++++++----------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/packages/grid/test/column.test.js b/packages/grid/test/column.test.js index d0d8e6f8742..86f1bb5e0e3 100644 --- a/packages/grid/test/column.test.js +++ b/packages/grid/test/column.test.js @@ -504,31 +504,27 @@ describe('column', () => { }); describe('cell content attach and detach', () => { - it('should remove header cell content from the grid when column is removed', async () => { - const content = getHeaderCellContent(grid, 1, 0); - - column.remove(); - await nextFrame(); - - expect(content.parentElement).to.be.null; - }); - - it('should remove footer cell content from the grid when column is removed', async () => { - const content = getContainerCellContent(grid.$.footer, 0, 0); - - column.remove(); - await nextFrame(); - - expect(content.parentElement).to.be.null; - }); + ['header', 'body', 'footer'].forEach((sectionName) => { + let content; - it('should remove body cell content from the grid when column is removed', async () => { - const content = getBodyCellContent(grid, 0, 0); + beforeEach(() => { + if (sectionName === 'header') { + content = getHeaderCellContent(grid, 1, 0); + } + if (sectionName === 'footer') { + content = getContainerCellContent(grid.$.footer, 0, 0); + } + if (sectionName === 'body') { + content = getBodyCellContent(grid, 0, 0); + } + }); - column.remove(); - await nextFrame(); + it(`should remove ${sectionName} cell content from the grid when column is removed`, async () => { + column.remove(); + await nextFrame(); - expect(content.parentElement).to.be.null; + expect(content.parentElement).to.be.null; + }); }); it('should render cell content when column is added back', async () => { From 261e04bcf5953727db42f378005247d9f114bbc6 Mon Sep 17 00:00:00 2001 From: Sergey Vinogradov Date: Fri, 17 Jul 2026 17:37:13 +0400 Subject: [PATCH 3/3] test: use switch to resolve section cell content Co-Authored-By: Claude Fable 5 --- packages/grid/test/column.test.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/grid/test/column.test.js b/packages/grid/test/column.test.js index 86f1bb5e0e3..006ee8a544e 100644 --- a/packages/grid/test/column.test.js +++ b/packages/grid/test/column.test.js @@ -508,14 +508,15 @@ describe('column', () => { let content; beforeEach(() => { - if (sectionName === 'header') { - content = getHeaderCellContent(grid, 1, 0); - } - if (sectionName === 'footer') { - content = getContainerCellContent(grid.$.footer, 0, 0); - } - if (sectionName === 'body') { - content = getBodyCellContent(grid, 0, 0); + switch (sectionName) { + case 'header': + content = getHeaderCellContent(grid, 1, 0); + break; + case 'footer': + content = getContainerCellContent(grid.$.footer, 0, 0); + break; + default: + content = getBodyCellContent(grid, 0, 0); } });