Skip to content

Commit 978be64

Browse files
committedFeb 28, 2024
test: fix tests
1 parent c0fd102 commit 978be64

16 files changed

+103
-26
lines changed
 

‎test/autocomplete.test.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
/* eslint-disable max-lines */
12
import { assert, html, nextFrame } from '@open-wc/testing';
23

3-
import { setupOmnitableFixture } from './helpers/utils';
4+
import {
5+
ignoreResizeObserverLoopErrors,
6+
rowVisible,
7+
setupOmnitableFixture,
8+
} from './helpers/utils';
49

510
import '../cosmoz-omnitable.js';
611
import { getComparableValue } from '../cosmoz-omnitable-column-autocomplete.js';
@@ -422,10 +427,12 @@ const basicFixture = html`
422427
`;
423428

424429
suite('autocomplete unit tests', () => {
430+
ignoreResizeObserverLoopErrors(setup, teardown);
425431
let omnitable;
426432

427433
setup(async () => {
428434
omnitable = await setupOmnitableFixture(basicFixture, data.slice(0));
435+
await rowVisible();
429436
});
430437

431438
test('basic render test', async () => {
@@ -454,6 +461,7 @@ suite('autocomplete unit tests', () => {
454461
});
455462

456463
suite('values as function', () => {
464+
ignoreResizeObserverLoopErrors(setup, teardown);
457465
test('displays values from a source function', async () => {
458466
const data = [
459467
{

‎test/basic.test.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { assert, expect, html, nextFrame } from '@open-wc/testing';
44
import { assert as sinonAssert, spy } from 'sinon';
55

66
import '../demo/helpers/cosmoz-translations';
7-
import { setupOmnitableFixture } from './helpers/utils';
7+
import { ignoreResizeObserverLoopErrors, rowVisible, setupOmnitableFixture } from './helpers/utils';
88
import { generateTableDemoData } from '../demo/table-demo-helper';
99
import { flush } from '@polymer/polymer/lib/utils/flush';
1010

@@ -16,6 +16,7 @@ import { columnSymbol } from '../lib/use-dom-columns';
1616
sinonAssert.expose(assert, { prefix: '' });
1717

1818
suite('basic', () => {
19+
ignoreResizeObserverLoopErrors(setup, teardown);
1920
let omnitable, columnWithoutGroupOn;
2021

2122
setup(async () => {
@@ -140,6 +141,7 @@ suite('basic', () => {
140141
});
141142

142143
suite('default-config', () => {
144+
ignoreResizeObserverLoopErrors(setup, teardown);
143145
test('default valuePath is name', async () => {
144146
const omnitable = await setupOmnitableFixture(
145147
html`
@@ -169,6 +171,7 @@ suite('default-config', () => {
169171
});
170172

171173
suite('item update effects', () => {
174+
ignoreResizeObserverLoopErrors(setup, teardown);
172175
let omnitable;
173176

174177
setup(async () => {
@@ -217,6 +220,7 @@ suite('item update effects', () => {
217220
});
218221

219222
suite('render cell function', () => {
223+
ignoreResizeObserverLoopErrors(setup, teardown);
220224
let omnitable;
221225

222226
setup(async () => {
@@ -297,6 +301,7 @@ suite('render cell function', () => {
297301
});
298302

299303
suite('render header function', () => {
304+
ignoreResizeObserverLoopErrors(setup, teardown);
300305
let omnitable;
301306

302307
const getRows = () =>
@@ -381,6 +386,7 @@ suite('render header function', () => {
381386
});
382387

383388
suite('fit columns behaviour', () => {
389+
ignoreResizeObserverLoopErrors(setup, teardown);
384390
let omnitable;
385391

386392
setup(async () => {
@@ -422,6 +428,7 @@ suite('fit columns behaviour', () => {
422428
`,
423429
data,
424430
);
431+
await rowVisible();
425432
});
426433

427434
test('it adjusts the visible columns based on the available width', async () => {
@@ -436,6 +443,7 @@ suite('fit columns behaviour', () => {
436443
await nextFrame();
437444
await nextFrame();
438445
await nextFrame();
446+
await nextFrame();
439447

440448
assert.deepEqual(
441449
Array.from(omnitable.shadowRoot.querySelectorAll('.header-cell')).map(
@@ -448,6 +456,7 @@ suite('fit columns behaviour', () => {
448456
await nextFrame();
449457
await nextFrame();
450458
await nextFrame();
459+
await nextFrame();
451460

452461
assert.deepEqual(
453462
Array.from(omnitable.shadowRoot.querySelectorAll('.header-cell')).map(
@@ -459,6 +468,7 @@ suite('fit columns behaviour', () => {
459468
});
460469

461470
suite('render group function', () => {
471+
ignoreResizeObserverLoopErrors(setup, teardown);
462472
let omnitable;
463473

464474
setup(async () => {
@@ -497,6 +507,7 @@ suite('render group function', () => {
497507
});
498508

499509
suite('enabled columns', () => {
510+
ignoreResizeObserverLoopErrors(setup, teardown);
500511
test('displays only enabled columns', async () => {
501512
const omnitable = await setupOmnitableFixture(
502513
html` <cosmoz-omnitable

‎test/boolean.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { assert, html } from '@open-wc/testing';
22

33
import { spy } from 'sinon';
4-
import { setupOmnitableFixture } from './helpers/utils';
4+
import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils';
55

66
import '../cosmoz-omnitable.js';
77
import '../cosmoz-omnitable-columns.js';
@@ -17,6 +17,7 @@ import { serializeFilter } from '../cosmoz-omnitable-column-mixin';
1717
import { columnSymbol } from '../lib/use-dom-columns';
1818

1919
suite('boolean', () => {
20+
ignoreResizeObserverLoopErrors(setup, teardown);
2021
test('initializes boolean column', async () => {
2122
const data = [
2223
{ boolean: true },

‎test/expand-line.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { fixture, html, assert } from '@open-wc/testing';
22
import '../cosmoz-omnitable-item-expand-line';
3+
import { ignoreResizeObserverLoopErrors } from './helpers/utils';
34

45
suite('cosmoz-omnitable-item-expand-line', () => {
6+
ignoreResizeObserverLoopErrors(setup, teardown);
57
test('initializes correctly', async () => {
68
const el = await fixture(
79
html`<cosmoz-omnitable-item-expand-line

‎test/group.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { assert, html, nextFrame } from '@open-wc/testing';
22

3-
import { setupOmnitableFixture } from './helpers/utils';
3+
import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils';
44
import { generateTableDemoData } from '../demo/table-demo-helper';
55

66
import '../cosmoz-omnitable.js';
77
import '../cosmoz-omnitable-columns.js';
88

99
suite('id', () => {
10+
ignoreResizeObserverLoopErrors(setup, teardown);
1011
let omnitable, data;
1112

1213
setup(async () => {
@@ -62,6 +63,7 @@ suite('id', () => {
6263
});
6364

6465
suite('bool', () => {
66+
ignoreResizeObserverLoopErrors(setup, teardown);
6567
let omnitable, data;
6668

6769
setup(async () => {
@@ -118,6 +120,7 @@ suite('bool', () => {
118120
});
119121

120122
suite('amount', () => {
123+
ignoreResizeObserverLoopErrors(setup, teardown);
121124
let omnitable, data;
122125

123126
setup(async () => {

‎test/hash-param-read.test.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { assert, html, nextFrame } from '@open-wc/testing';
1+
import { assert, html } from '@open-wc/testing';
22

3-
import { setupOmnitableFixture } from './helpers/utils';
3+
import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils';
44

55
import '../cosmoz-omnitable.js';
66
import '../cosmoz-omnitable-column-autocomplete.js';
@@ -31,7 +31,6 @@ const data = [
3131
],
3232
location = window.location,
3333
instantiate = async () => {
34-
await nextFrame();
3534
omnitable = await setupOmnitableFixture(
3635
html`
3736
<cosmoz-omnitable
@@ -69,10 +68,10 @@ const data = [
6968
`,
7069
data,
7170
);
72-
await nextFrame();
7371
};
7472

7573
suite('basic-read', () => {
74+
ignoreResizeObserverLoopErrors(setup, teardown);
7675
setup(() => {
7776
location.hash = '#!/';
7877
});

‎test/hash-param-write.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { assert, html, nextFrame } from '@open-wc/testing';
22

3-
import { setupOmnitableFixture } from './helpers/utils';
3+
import { ignoreResizeObserverLoopErrors, setupOmnitableFixture } from './helpers/utils';
44

55
import '../cosmoz-omnitable.js';
66
import '../cosmoz-omnitable-column-autocomplete.js';
@@ -73,6 +73,7 @@ const data = [
7373
};
7474

7575
suite('basic-write', () => {
76+
ignoreResizeObserverLoopErrors(setup, teardown);
7677
setup(async () => {
7778
location.hash = '#!/';
7879
await instantiate();

‎test/helpers/utils.js

+36-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
1-
import { fixture, nextFrame } from '@open-wc/testing';
2-
import { flush } from '@polymer/polymer/lib/utils/flush';
1+
import { fixture } from '@open-wc/testing';
2+
import { perform } from '@neovici/cfg/web/perform.js';
33

44
export const setupOmnitableFixture = async (omnitableFixture, data) => {
55
const omnitable = await fixture(omnitableFixture);
6+
7+
await perform(async ({ page, expect }) => {
8+
await expect(page.locator('cosmoz-omnitable-header-row')).toBeVisible();
9+
});
10+
611
omnitable.data = data;
7-
await nextFrame();
8-
flush();
9-
await nextFrame();
1012
return omnitable;
1113
};
14+
15+
export const rowVisible = async () => {
16+
await perform(async ({ page, expect }) => {
17+
await expect(page.locator('.itemRow').first()).toBeVisible();
18+
});
19+
};
20+
21+
export const ignoreResizeObserverLoopErrors = (setup, teardown) => {
22+
// called before any tests are run
23+
const e = window.onerror;
24+
25+
setup(() => {
26+
window.onerror = function (err) {
27+
if (
28+
err === 'ResizeObserver loop limit exceeded' ||
29+
err === 'ResizeObserver loop completed with undelivered notifications.'
30+
) {
31+
// eslint-disable-next-line no-console
32+
console.warn('Ignored:', err);
33+
return false;
34+
}
35+
return e(...arguments);
36+
};
37+
});
38+
39+
teardown(() => {
40+
window.onerror = e;
41+
});
42+
};

‎test/list.test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { assert, html } from '@open-wc/testing';
22

3-
import { setupOmnitableFixture } from './helpers/utils';
3+
import { ignoreResizeObserverLoopErrors, rowVisible, setupOmnitableFixture } from './helpers/utils';
44

55
import '../cosmoz-omnitable.js';
66
import '../cosmoz-omnitable-columns.js';
@@ -12,6 +12,7 @@ import {
1212
import { columnSymbol } from '../lib/use-dom-columns';
1313

1414
suite('basic', () => {
15+
ignoreResizeObserverLoopErrors(setup, teardown);
1516
let omnitable, column, data;
1617

1718
setup(async () => {
@@ -43,6 +44,7 @@ suite('basic', () => {
4344
});
4445

4546
suite('horizontal', () => {
47+
ignoreResizeObserverLoopErrors(setup, teardown);
4648
let omnitable, column, data;
4749

4850
setup(async () => {
@@ -69,6 +71,7 @@ suite('horizontal', () => {
6971
});
7072

7173
test('basic render', async () => {
74+
await rowVisible();
7275
const cells = Array.from(
7376
omnitable.shadowRoot.querySelectorAll('.itemRow-cell'),
7477
);

‎test/range-amount.test.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { assert, html, nextFrame } from '@open-wc/testing';
33

44
import { assert as sinonAssert } from 'sinon';
55

6-
import { setupOmnitableFixture } from './helpers/utils';
6+
import {
7+
ignoreResizeObserverLoopErrors,
8+
setupOmnitableFixture,
9+
} from './helpers/utils';
710
import { flush } from '@polymer/polymer/lib/utils/flush';
811

912
import '../cosmoz-omnitable.js';
@@ -92,6 +95,7 @@ const data = [
9295
sinonAssert.expose(assert, { prefix: '' });
9396

9497
suite('amount', () => {
98+
ignoreResizeObserverLoopErrors(setup, teardown);
9599
const rates = undefined;
96100
let omnitable, column, columnHeaderInput;
97101

@@ -383,6 +387,7 @@ suite('amount', () => {
383387
});
384388

385389
suite('currency rates', () => {
390+
ignoreResizeObserverLoopErrors(setup, teardown);
386391
let omnitable, column, columnHeaderInput;
387392

388393
const rates = {
@@ -875,6 +880,7 @@ suite('currency rates', () => {
875880
});
876881

877882
suite('default currency', () => {
883+
ignoreResizeObserverLoopErrors(setup, teardown);
878884
let omnitable, column, columnHeaderInput;
879885

880886
setup(async () => {

‎test/range-date.test.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { assert, html, nextFrame } from '@open-wc/testing';
33
import { assert as sinonAssert } from 'sinon';
44

5-
import { setupOmnitableFixture } from './helpers/utils';
5+
import { ignoreResizeObserverLoopErrors, rowVisible, setupOmnitableFixture } from './helpers/utils';
66
import { flush as polymerFlush } from '@polymer/polymer/lib/utils/flush';
77

88
import '../cosmoz-omnitable.js';
@@ -99,17 +99,21 @@ const data = [
9999
sinonAssert.expose(assert, { prefix: '' });
100100

101101
suite('render', () => {
102+
ignoreResizeObserverLoopErrors(setup, teardown);
102103
test('basic render', async () => {
103-
const omnitable = await setupOmnitableFixture(rangeFixture, data),
104-
cells = Array.from(
105-
omnitable.shadowRoot.querySelectorAll('.itemRow-cell'),
106-
);
104+
const omnitable = await setupOmnitableFixture(rangeFixture, data);
105+
await rowVisible();
106+
107+
const cells = Array.from(
108+
omnitable.shadowRoot.querySelectorAll('.itemRow-cell'),
109+
);
107110
assert.isAtLeast(cells.length, 20);
108111
assert.equal(cells[0].innerText, '17');
109112
});
110113
});
111114

112115
suite('date', () => {
116+
ignoreResizeObserverLoopErrors(setup, teardown);
113117
let omnitable, column, columnHeaderInput;
114118

115119
setup(async () => {

0 commit comments

Comments
 (0)
Failed to load comments.