diff --git a/test/autocomplete.test.js b/test/autocomplete.test.js index 43903332..946370e1 100644 --- a/test/autocomplete.test.js +++ b/test/autocomplete.test.js @@ -1,6 +1,11 @@ +/* eslint-disable max-lines */ import { assert, html, nextFrame } from '@open-wc/testing'; -import { setupOmnitableFixture } from './helpers/utils'; +import { + ignoreResizeObserverLoopErrors, + rowVisible, + setupOmnitableFixture, +} from './helpers/utils'; import '../cosmoz-omnitable.js'; import { getComparableValue } from '../cosmoz-omnitable-column-autocomplete.js'; @@ -422,10 +427,12 @@ const basicFixture = html` `; suite('autocomplete unit tests', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable; setup(async () => { omnitable = await setupOmnitableFixture(basicFixture, data.slice(0)); + await rowVisible(); }); test('basic render test', async () => { @@ -454,6 +461,7 @@ suite('autocomplete unit tests', () => { }); suite('values as function', () => { + ignoreResizeObserverLoopErrors(setup, teardown); test('displays values from a source function', async () => { const data = [ { diff --git a/test/basic.test.js b/test/basic.test.js index f128f71f..3b7d313e 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -4,7 +4,7 @@ import { assert, expect, html, nextFrame } from '@open-wc/testing'; import { assert as sinonAssert, spy } from 'sinon'; import '../demo/helpers/cosmoz-translations'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, rowVisible, setupOmnitableFixture } from './helpers/utils'; import { generateTableDemoData } from '../demo/table-demo-helper'; import { flush } from '@polymer/polymer/lib/utils/flush'; @@ -16,6 +16,7 @@ import { columnSymbol } from '../lib/use-dom-columns'; sinonAssert.expose(assert, { prefix: '' }); suite('basic', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, columnWithoutGroupOn; setup(async () => { @@ -140,6 +141,7 @@ suite('basic', () => { }); suite('default-config', () => { + ignoreResizeObserverLoopErrors(setup, teardown); test('default valuePath is name', async () => { const omnitable = await setupOmnitableFixture( html` @@ -169,6 +171,7 @@ suite('default-config', () => { }); suite('item update effects', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable; setup(async () => { @@ -217,6 +220,7 @@ suite('item update effects', () => { }); suite('render cell function', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable; setup(async () => { @@ -297,6 +301,7 @@ suite('render cell function', () => { }); suite('render header function', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable; const getRows = () => @@ -381,6 +386,7 @@ suite('render header function', () => { }); suite('fit columns behaviour', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable; setup(async () => { @@ -422,6 +428,7 @@ suite('fit columns behaviour', () => { `, data, ); + await rowVisible(); }); test('it adjusts the visible columns based on the available width', async () => { @@ -436,6 +443,7 @@ suite('fit columns behaviour', () => { await nextFrame(); await nextFrame(); await nextFrame(); + await nextFrame(); assert.deepEqual( Array.from(omnitable.shadowRoot.querySelectorAll('.header-cell')).map( @@ -448,6 +456,7 @@ suite('fit columns behaviour', () => { await nextFrame(); await nextFrame(); await nextFrame(); + await nextFrame(); assert.deepEqual( Array.from(omnitable.shadowRoot.querySelectorAll('.header-cell')).map( @@ -459,6 +468,7 @@ suite('fit columns behaviour', () => { }); suite('render group function', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable; setup(async () => { @@ -497,6 +507,7 @@ suite('render group function', () => { }); suite('enabled columns', () => { + ignoreResizeObserverLoopErrors(setup, teardown); test('displays only enabled columns', async () => { const omnitable = await setupOmnitableFixture( html` { + ignoreResizeObserverLoopErrors(setup, teardown); test('initializes boolean column', async () => { const data = [ { boolean: true }, diff --git a/test/expand-line.test.js b/test/expand-line.test.js index 8dbc73d7..eacae716 100644 --- a/test/expand-line.test.js +++ b/test/expand-line.test.js @@ -1,7 +1,9 @@ import { fixture, html, assert } from '@open-wc/testing'; import '../cosmoz-omnitable-item-expand-line'; +import { ignoreResizeObserverLoopErrors } from './helpers/utils'; suite('cosmoz-omnitable-item-expand-line', () => { + ignoreResizeObserverLoopErrors(setup, teardown); test('initializes correctly', async () => { const el = await fixture( html` { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, data; setup(async () => { @@ -62,6 +63,7 @@ suite('id', () => { }); suite('bool', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, data; setup(async () => { @@ -118,6 +120,7 @@ suite('bool', () => { }); suite('amount', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, data; setup(async () => { diff --git a/test/hash-param-read.test.js b/test/hash-param-read.test.js index d180aaa8..71a93593 100644 --- a/test/hash-param-read.test.js +++ b/test/hash-param-read.test.js @@ -1,6 +1,6 @@ -import { assert, html, nextFrame } from '@open-wc/testing'; +import { assert, html } from '@open-wc/testing'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils'; import '../cosmoz-omnitable.js'; import '../cosmoz-omnitable-column-autocomplete.js'; @@ -31,7 +31,6 @@ const data = [ ], location = window.location, instantiate = async () => { - await nextFrame(); omnitable = await setupOmnitableFixture( html` { + ignoreResizeObserverLoopErrors(setup, teardown); setup(() => { location.hash = '#!/'; }); diff --git a/test/hash-param-write.test.js b/test/hash-param-write.test.js index 2c8a9208..7f8a4de5 100644 --- a/test/hash-param-write.test.js +++ b/test/hash-param-write.test.js @@ -1,6 +1,6 @@ import { assert, html, nextFrame } from '@open-wc/testing'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils'; import '../cosmoz-omnitable.js'; import '../cosmoz-omnitable-column-autocomplete.js'; @@ -73,6 +73,7 @@ const data = [ }; suite('basic-write', () => { + ignoreResizeObserverLoopErrors(setup, teardown); setup(async () => { location.hash = '#!/'; await instantiate(); diff --git a/test/helpers/utils.js b/test/helpers/utils.js index 784adf4e..e238e337 100644 --- a/test/helpers/utils.js +++ b/test/helpers/utils.js @@ -1,11 +1,42 @@ -import { fixture, nextFrame } from '@open-wc/testing'; -import { flush } from '@polymer/polymer/lib/utils/flush'; +import { fixture } from '@open-wc/testing'; +import { perform } from '@neovici/cfg/web/perform.js'; export const setupOmnitableFixture = async (omnitableFixture, data) => { const omnitable = await fixture(omnitableFixture); + + await perform(async ({ page, expect }) => { + await expect(page.locator('cosmoz-omnitable-header-row')).toBeVisible(); + }); + omnitable.data = data; - await nextFrame(); - flush(); - await nextFrame(); return omnitable; }; + +export const rowVisible = async () => { + await perform(async ({ page, expect }) => { + await expect(page.locator('.itemRow').first()).toBeVisible(); + }); +}; + +export const ignoreResizeObserverLoopErrors = (setup, teardown) => { + // called before any tests are run + const e = window.onerror; + + setup(() => { + window.onerror = function (err) { + if ( + err === 'ResizeObserver loop limit exceeded' || + err === 'ResizeObserver loop completed with undelivered notifications.' + ) { + // eslint-disable-next-line no-console + console.warn('Ignored:', err); + return false; + } + return e(...arguments); + }; + }); + + teardown(() => { + window.onerror = e; + }); +}; diff --git a/test/list.test.js b/test/list.test.js index bf0f1e09..636f6569 100644 --- a/test/list.test.js +++ b/test/list.test.js @@ -1,6 +1,6 @@ import { assert, html } from '@open-wc/testing'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, rowVisible, setupOmnitableFixture } from './helpers/utils'; import '../cosmoz-omnitable.js'; import '../cosmoz-omnitable-columns.js'; @@ -12,6 +12,7 @@ import { import { columnSymbol } from '../lib/use-dom-columns'; suite('basic', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, column, data; setup(async () => { @@ -43,6 +44,7 @@ suite('basic', () => { }); suite('horizontal', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, column, data; setup(async () => { @@ -69,6 +71,7 @@ suite('horizontal', () => { }); test('basic render', async () => { + await rowVisible(); const cells = Array.from( omnitable.shadowRoot.querySelectorAll('.itemRow-cell'), ); diff --git a/test/range-amount.test.js b/test/range-amount.test.js index 155c46a0..f02d8ae5 100644 --- a/test/range-amount.test.js +++ b/test/range-amount.test.js @@ -3,7 +3,10 @@ import { assert, html, nextFrame } from '@open-wc/testing'; import { assert as sinonAssert } from 'sinon'; -import { setupOmnitableFixture } from './helpers/utils'; +import { + ignoreResizeObserverLoopErrors, + setupOmnitableFixture, +} from './helpers/utils'; import { flush } from '@polymer/polymer/lib/utils/flush'; import '../cosmoz-omnitable.js'; @@ -92,6 +95,7 @@ const data = [ sinonAssert.expose(assert, { prefix: '' }); suite('amount', () => { + ignoreResizeObserverLoopErrors(setup, teardown); const rates = undefined; let omnitable, column, columnHeaderInput; @@ -383,6 +387,7 @@ suite('amount', () => { }); suite('currency rates', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, column, columnHeaderInput; const rates = { @@ -875,6 +880,7 @@ suite('currency rates', () => { }); suite('default currency', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, column, columnHeaderInput; setup(async () => { diff --git a/test/range-date.test.js b/test/range-date.test.js index e16c6746..43cd6807 100644 --- a/test/range-date.test.js +++ b/test/range-date.test.js @@ -2,7 +2,7 @@ import { assert, html, nextFrame } from '@open-wc/testing'; import { assert as sinonAssert } from 'sinon'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, rowVisible, setupOmnitableFixture } from './helpers/utils'; import { flush as polymerFlush } from '@polymer/polymer/lib/utils/flush'; import '../cosmoz-omnitable.js'; @@ -99,17 +99,21 @@ const data = [ sinonAssert.expose(assert, { prefix: '' }); suite('render', () => { + ignoreResizeObserverLoopErrors(setup, teardown); test('basic render', async () => { - const omnitable = await setupOmnitableFixture(rangeFixture, data), - cells = Array.from( - omnitable.shadowRoot.querySelectorAll('.itemRow-cell'), - ); + const omnitable = await setupOmnitableFixture(rangeFixture, data); + await rowVisible(); + + const cells = Array.from( + omnitable.shadowRoot.querySelectorAll('.itemRow-cell'), + ); assert.isAtLeast(cells.length, 20); assert.equal(cells[0].innerText, '17'); }); }); suite('date', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, column, columnHeaderInput; setup(async () => { diff --git a/test/range-datetime.test.js b/test/range-datetime.test.js index 2d1ffb12..535f69a5 100644 --- a/test/range-datetime.test.js +++ b/test/range-datetime.test.js @@ -1,7 +1,7 @@ /* eslint-disable max-lines */ import { assert, html, nextFrame } from '@open-wc/testing'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils'; import { flush as polymerFlush } from '@polymer/polymer/lib/utils/flush'; import { fromHashString, @@ -99,6 +99,7 @@ const data = [ `; suite('datetime', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, columnHeaderInput; setup(async () => { diff --git a/test/range-time.test.js b/test/range-time.test.js index 28dc672a..a6071344 100644 --- a/test/range-time.test.js +++ b/test/range-time.test.js @@ -1,7 +1,7 @@ /* eslint-disable max-lines */ import { assert, html, nextFrame } from '@open-wc/testing'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils'; import { flush as polymerFlush } from '@polymer/polymer/lib/utils/flush'; import '../cosmoz-omnitable'; @@ -100,6 +100,7 @@ const data = [ `; suite('time', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, column, columnHeaderInput; setup(async () => { diff --git a/test/range.test.js b/test/range.test.js index 53567862..99f9b97f 100644 --- a/test/range.test.js +++ b/test/range.test.js @@ -3,7 +3,7 @@ import { assert, html, nextFrame } from '@open-wc/testing'; import { assert as sinonAssert } from 'sinon'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils'; import { flush } from '@polymer/polymer/lib/utils/flush'; import '../cosmoz-omnitable.js'; @@ -86,6 +86,7 @@ const data = [ sinonAssert.expose(assert, { prefix: '' }); suite('number', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, column, columnHeaderInput; setup(async () => { @@ -257,6 +258,7 @@ suite('number - pure functions', () => { }); suite('external values', () => { + ignoreResizeObserverLoopErrors(setup, teardown); test('changing _filterInput min on column with external values updates filter min correctly', async () => { const omnitable = await setupOmnitableFixture( html` diff --git a/test/select.test.js b/test/select.test.js index e5e2cd00..b679ca86 100644 --- a/test/select.test.js +++ b/test/select.test.js @@ -2,13 +2,14 @@ import { assert, html, nextFrame } from '@open-wc/testing'; import '../demo/helpers/cosmoz-translations'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, rowVisible, setupOmnitableFixture } from './helpers/utils'; import { generateTableDemoData } from '../demo/table-demo-helper'; import '../cosmoz-omnitable.js'; import '../cosmoz-omnitable-columns.js'; suite('basic', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable; setup(async () => { omnitable = await setupOmnitableFixture( @@ -22,6 +23,7 @@ suite('basic', () => { `, generateTableDemoData(10, 11, 25), ); + await rowVisible(); }); test('selects and deselect all items', async () => { diff --git a/test/xlsx-export.test.js b/test/xlsx-export.test.js index 8d7dd19f..3d48ed09 100644 --- a/test/xlsx-export.test.js +++ b/test/xlsx-export.test.js @@ -1,7 +1,7 @@ import { assert, html, nextFrame } from '@open-wc/testing'; import { assert as sinonAssert } from 'sinon'; -import { setupOmnitableFixture } from './helpers/utils'; +import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils'; import '../cosmoz-omnitable.js'; import '../cosmoz-omnitable-columns.js'; @@ -11,6 +11,7 @@ import { toDate } from '../lib/utils-date'; sinonAssert.expose(assert, { prefix: '' }); suite('xlsx-export-omnitable', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable; const data = [ { @@ -115,6 +116,7 @@ suite('xlsx-export-omnitable', () => { }); suite('toXlsx range tests', () => { + ignoreResizeObserverLoopErrors(setup, teardown); let omnitable, xlsx; const data = [ { diff --git a/web-test-runner.config.mjs b/web-test-runner.config.mjs index 7ec9025a..12e92290 100644 --- a/web-test-runner.config.mjs +++ b/web-test-runner.config.mjs @@ -1,3 +1,5 @@ import cfg from '@neovici/cfg/web/test-runner.mjs'; +cfg.testFramework.config.timeout = 10000; + export default cfg;