From 43d2411b8990437e06099ab5b300812158f96539 Mon Sep 17 00:00:00 2001 From: Dusan Kosanovic Date: Tue, 24 Jun 2025 11:40:24 +0200 Subject: [PATCH 1/2] Table flaky/failing tests fix --- libs/blocks/table/table.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index 83c05a6c34..f4423e7532 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -256,6 +256,8 @@ function handleExpand(e) { } function setExpandEvents(el) { + if (el.dataset.expandEvents) return; // prevent multiple calls in unit tests + el.dataset.expandEvents = 'true'; el.querySelectorAll('.icon.expand').forEach((icon) => { icon.parentElement.classList.add('point-cursor'); icon.parentElement.addEventListener('click', () => handleExpand(icon)); From 08490a996c5881ce9c4b010a5cf7f3f5627dfc68 Mon Sep 17 00:00:00 2001 From: Dusan Kosanovic Date: Tue, 24 Jun 2025 16:32:52 +0200 Subject: [PATCH 2/2] Table test beforeeach logic update --- libs/blocks/table/table.js | 2 -- test/blocks/table/table.test.js | 13 +++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libs/blocks/table/table.js b/libs/blocks/table/table.js index f4423e7532..83c05a6c34 100644 --- a/libs/blocks/table/table.js +++ b/libs/blocks/table/table.js @@ -256,8 +256,6 @@ function handleExpand(e) { } function setExpandEvents(el) { - if (el.dataset.expandEvents) return; // prevent multiple calls in unit tests - el.dataset.expandEvents = 'true'; el.querySelectorAll('.icon.expand').forEach((icon) => { icon.parentElement.classList.add('point-cursor'); icon.parentElement.addEventListener('click', () => handleExpand(icon)); diff --git a/test/blocks/table/table.test.js b/test/blocks/table/table.test.js index a26a4bd6ff..1f0c13c131 100644 --- a/test/blocks/table/table.test.js +++ b/test/blocks/table/table.test.js @@ -12,7 +12,7 @@ setConfig(conf); const config = getConfig(); describe('table and tablemetadata', () => { - beforeEach(() => { + before(() => { const tables = document.querySelectorAll('.table'); tables.forEach((t) => init(t)); window.dispatchEvent(new Event(MILO_EVENTS.DEFERRED)); @@ -114,12 +114,21 @@ describe('table and tablemetadata', () => { expect(tooltipHeading.childNodes.length).to.equal(2); expect(tooltipHeading.querySelector('.milo-tooltip, .icon-tooltip')).to.exist; }); + }); + + describe('mobile aria-label test setup', () => { + beforeEach(() => { + const tables = document.querySelectorAll('.table'); + tables.forEach((t) => init(t)); + window.dispatchEvent(new Event(MILO_EVENTS.DEFERRED)); + }); it('should apply aria-label to all selects within .filters on mobile', async () => { window.innerWidth = 375; window.dispatchEvent(new Event('resize')); + const filters = await waitForElement('.filters'); + const selectElements = filters.querySelectorAll('select'); const ariaLabel = await replaceKey('choose-table-column', config); - const selectElements = document.querySelectorAll('.filters select'); selectElements.forEach((selectElement) => { expect(selectElement.getAttribute('aria-label')).to.equal(ariaLabel);