tablefilter 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +16 -0
- package/.github/workflows/build-deploy.yml +30 -2
- package/.github/workflows/opencode-review.yml +104 -0
- package/.github/workflows/opencode.yml +34 -0
- package/ROADMAP/README.md +6 -1
- package/ROADMAP/content-projection-parity.md +162 -0
- package/ROADMAP/hybrid-migration-strategy.md +48 -7
- package/ROADMAP/key-decisions-review.md +5 -3
- package/ROADMAP/preliminary-and-milestone-0.8.0-plan.md +11 -12
- package/ROADMAP/v1-webcomponents-investigation.md +6 -1
- package/dist/starter.html +2 -2
- package/dist/tablefilter/style/colsVisibility.css +1 -1
- package/dist/tablefilter/style/filtersVisibility.css +1 -1
- package/dist/tablefilter/style/tablefilter.css +1 -1
- package/dist/tablefilter/style/themes/default/default.css +1 -1
- package/dist/tablefilter/style/themes/mytheme/mytheme.css +1 -1
- package/dist/tablefilter/style/themes/skyblue/skyblue.css +1 -1
- package/dist/tablefilter/style/themes/transparent/transparent.css +1 -1
- package/dist/tablefilter/tablefilter.js +1 -1
- package/dist/tablefilter/tablefilter.vite.js +4 -0
- package/dist/tablefilter/tf-1-a5c3a73bd559e47dd5a2.js +1 -0
- package/dist/tablefilter/tf-2-3a936d22b849361acff5.js +6 -0
- package/dist/tablefilter.cjs.js +4 -0
- package/dist/tablefilter.esm.js +7278 -0
- package/dist/tablefilter.umd.js +4 -0
- package/package.json +12 -5
- package/playwright.config.js +25 -0
- package/scripts/check-css-tokens.js +65 -0
- package/src/components/table-filter.js +243 -0
- package/src/components/tf-clear-button.js +95 -0
- package/src/components/tf-rows-counter.js +82 -0
- package/src/components/tf-status.js +106 -0
- package/src/modules/clearButton.js +65 -11
- package/src/modules/rowsCounter.js +48 -25
- package/src/modules/statusBar.js +62 -30
- package/src/sanitize.js +25 -0
- package/static/style/active-header.styl +2 -2
- package/static/style/alternating-rows.styl +2 -2
- package/static/style/config.styl +18 -18
- package/static/style/custom-properties.styl +43 -0
- package/static/style/ezedittable.styl +12 -12
- package/static/style/filter-checklist.styl +3 -3
- package/static/style/filters.styl +8 -8
- package/static/style/grid-layout.styl +9 -9
- package/static/style/help.styl +9 -9
- package/static/style/keyword.styl +1 -1
- package/static/style/loader.styl +3 -3
- package/static/style/noresults.styl +1 -1
- package/static/style/paging.styl +1 -1
- package/static/style/rows-counter.styl +1 -1
- package/static/style/status-bar.styl +1 -4
- package/static/style/tablefilter.styl +1 -0
- package/static/style/themes/skyblue/skyblue.styl +2 -2
- package/static/style/themes/transparent/transparent.styl +2 -2
- package/static/style/toolbar.styl +1 -1
- package/static/templates/table-filter.html +40 -0
- package/test/playwright/axe.baseline.spec.js +34 -0
- package/test/playwright/axe.statusbar.spec.js +35 -0
- package/test/playwright/axeScan.js +42 -0
- package/test/playwright/ce-bridge.spec.js +167 -0
- package/test/playwright/qunit.all.spec.js +10 -0
- package/test/playwright/qunit.single.spec.js +14 -0
- package/test/playwright/qunitSuite.js +56 -0
- package/test/playwright/table-filter.config.spec.js +265 -0
- package/test/playwright/table-filter.demo.spec.js +60 -0
- package/test/playwright/table-filter.element.spec.js +477 -0
- package/test/playwright/tf-clear-button.spec.js +135 -0
- package/test/playwright/tf-rows-counter.spec.js +172 -0
- package/test/playwright/tf-status.spec.js +258 -0
- package/test/test-clear-button.js +1 -0
- package/test/test-rows-counter.js +2 -0
- package/test/test-status-bar.js +3 -0
- package/vite.config.js +71 -0
- package/webpack.config.js +12 -0
- package/dist/tablefilter/tf-1-d2360db09a424b1ed633.js +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<title>{NAME} v{VERSION} - table-filter Demo</title>
|
|
5
|
+
<!-- @import partials/style.html -->
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<h1>{NAME} v{VERSION}</h1>
|
|
9
|
+
<h2>Declarative <code><table-filter></code> demo</h2>
|
|
10
|
+
<p>
|
|
11
|
+
Every option lives in an attribute on the
|
|
12
|
+
<code><table-filter></code> element, so there is no imperative
|
|
13
|
+
<code>new TableFilter(...)</code> call. The element wraps a light-DOM
|
|
14
|
+
<code><table></code> and instantiates the engine on connect.
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<table-filter
|
|
18
|
+
base-path="../dist/tablefilter/"
|
|
19
|
+
col-0="checklist"
|
|
20
|
+
col-1="select"
|
|
21
|
+
col-2="select"
|
|
22
|
+
alternate-rows="true"
|
|
23
|
+
rows-counter="true"
|
|
24
|
+
btn-reset="true"
|
|
25
|
+
status-bar="true"
|
|
26
|
+
no-results-message="true"
|
|
27
|
+
col-widths='["150px","100px","100px","100px","100px","100px","100px","70px","60px"]'
|
|
28
|
+
>
|
|
29
|
+
<!-- @import partials/countries-table.html -->
|
|
30
|
+
</table-filter>
|
|
31
|
+
|
|
32
|
+
<!--
|
|
33
|
+
The element is not part of the legacy bundle yet (see the module
|
|
34
|
+
header), so load the module source: the Vite dev server that serves
|
|
35
|
+
the demos (npx vite, the server playwright.config.js starts)
|
|
36
|
+
compiles it. Shipping the element in a bundle is #965.
|
|
37
|
+
-->
|
|
38
|
+
<script type="module" src="/src/components/table-filter.js"></script>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Accessibility baseline (#896, report-only): scan the flagship
|
|
2
|
+
// demo page and attach violations without failing. The whole-page
|
|
3
|
+
// findings (filter inputs/selects without labels) are tracked by
|
|
4
|
+
// #948; per-component enforcement lives in axe.statusbar.spec.js.
|
|
5
|
+
const { test, expect } = require('@playwright/test');
|
|
6
|
+
const { scanAccessibility } = require('./axeScan');
|
|
7
|
+
|
|
8
|
+
const DEMO_PAGE = 'demos/demo.html';
|
|
9
|
+
|
|
10
|
+
// Axe needs longer than the default 30s on this large fixture.
|
|
11
|
+
test.setTimeout(120000);
|
|
12
|
+
|
|
13
|
+
test(`Axe baseline (report-only): ${DEMO_PAGE}`, async (
|
|
14
|
+
{ page }, testInfo
|
|
15
|
+
) => {
|
|
16
|
+
await page.goto(`/${DEMO_PAGE}`);
|
|
17
|
+
await page.waitForSelector('#demo');
|
|
18
|
+
// fltrow: default flts_row_css_class (src/tablefilter.js)
|
|
19
|
+
// state: attached — the status bar is empty (zero height) until a
|
|
20
|
+
// message arrives, so a visibility wait would only resolve when
|
|
21
|
+
// the stylesheet happens to give the empty container height.
|
|
22
|
+
await page.waitForSelector('#demo .fltrow, #demo .status', {
|
|
23
|
+
state: 'attached',
|
|
24
|
+
timeout: 15000
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const violations =
|
|
28
|
+
await scanAccessibility(page, testInfo, DEMO_PAGE);
|
|
29
|
+
|
|
30
|
+
// Report-only: the scan ran and produced a structured report.
|
|
31
|
+
// TODO(#948): assert zero violations once the whole-page
|
|
32
|
+
// findings (unlabelled filter inputs/selects) are fixed.
|
|
33
|
+
expect(Array.isArray(violations)).toBe(true);
|
|
34
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Accessibility enforcement (#897): the status bar must report zero
|
|
2
|
+
// axe violations, scoped to its own container so unrelated page
|
|
3
|
+
// findings (filter inputs/selects, tracked by #948) do not mask a
|
|
4
|
+
// real status-bar regression. Fails CI on any violation.
|
|
5
|
+
const { test, expect } = require('@playwright/test');
|
|
6
|
+
const { scanAccessibility } = require('./axeScan');
|
|
7
|
+
|
|
8
|
+
const DEMO_PAGE = 'demos/demo.html';
|
|
9
|
+
const STATUS_SCOPE = '.status';
|
|
10
|
+
|
|
11
|
+
// Page load plus the scan outlast the 30s default.
|
|
12
|
+
test.setTimeout(60000);
|
|
13
|
+
|
|
14
|
+
test(`Axe zero-violations: status bar on ${DEMO_PAGE}`, async (
|
|
15
|
+
{ page }, testInfo
|
|
16
|
+
) => {
|
|
17
|
+
await page.goto(`/${DEMO_PAGE}`);
|
|
18
|
+
|
|
19
|
+
// The bar is empty until a message arrives, so it has no height
|
|
20
|
+
// (none at all without the stylesheet): assert attachment, not
|
|
21
|
+
// visibility. Auto-retries, and fails fast with a clear message
|
|
22
|
+
// if the container class ever changes.
|
|
23
|
+
const statusBar = page.locator(STATUS_SCOPE);
|
|
24
|
+
await expect(statusBar, 'status bar container is not attached')
|
|
25
|
+
.toBeAttached({ timeout: 15000 });
|
|
26
|
+
|
|
27
|
+
const violations = await scanAccessibility(
|
|
28
|
+
page, testInfo, `status bar on ${DEMO_PAGE}`,
|
|
29
|
+
{ include: STATUS_SCOPE }
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
expect(
|
|
33
|
+
violations.map((v) => `${v.id}: ${v.nodes.length} node(s)`)
|
|
34
|
+
).toEqual([]);
|
|
35
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Accessibility scanner (#896 report-only, #897 scoped enforcement):
|
|
2
|
+
// runs AxeBuilder against a loaded page, logs a summary and attaches
|
|
3
|
+
// the violation report. Callers decide whether to assert.
|
|
4
|
+
const { AxeBuilder } = require('@axe-core/playwright');
|
|
5
|
+
|
|
6
|
+
// Full WCAG 2.x A/AA tag set; the AA target needs the A levels too.
|
|
7
|
+
const WCAG_TAGS = [
|
|
8
|
+
'wcag2a', 'wcag2aa',
|
|
9
|
+
'wcag21a', 'wcag21aa',
|
|
10
|
+
'wcag22a', 'wcag22aa'
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
// `include` narrows the audit to a CSS scope (per-component gates,
|
|
14
|
+
// e.g. .status in #897); omit it to scan the whole page.
|
|
15
|
+
async function scanAccessibility(page, testInfo, label, { include } = {}) {
|
|
16
|
+
const builder = new AxeBuilder({ page }).withTags(WCAG_TAGS);
|
|
17
|
+
if (include) {
|
|
18
|
+
builder.include(include);
|
|
19
|
+
}
|
|
20
|
+
const results = await builder.analyze();
|
|
21
|
+
const summary = results.violations.map((violation) => ({
|
|
22
|
+
id: violation.id,
|
|
23
|
+
impact: violation.impact,
|
|
24
|
+
nodes: violation.nodes.length,
|
|
25
|
+
description: violation.description
|
|
26
|
+
}));
|
|
27
|
+
await testInfo.attach(`${label} axe report`, {
|
|
28
|
+
body: JSON.stringify(
|
|
29
|
+
{ page: label, failures: summary.length, summary },
|
|
30
|
+
null,
|
|
31
|
+
2
|
|
32
|
+
),
|
|
33
|
+
contentType: 'application/json'
|
|
34
|
+
});
|
|
35
|
+
console.log(
|
|
36
|
+
`axe ${label}: ${summary.length} violation(s) ` +
|
|
37
|
+
`(${summary.map((item) => item.id).join(', ') || 'none'})`
|
|
38
|
+
);
|
|
39
|
+
return results.violations;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { WCAG_TAGS, scanAccessibility };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// CE bridge integration (#912): unlike the component specs, which mount
|
|
2
|
+
// the custom element directly, these tests load the component into the
|
|
3
|
+
// page and then initialise TableFilter, so `customElements.get(...)` is
|
|
4
|
+
// truthy and the feature routes through `initCE()` instead of
|
|
5
|
+
// `initLegacy()` (see ROADMAP/hybrid-migration-strategy.md). Each test
|
|
6
|
+
// asserts the host element, that interaction still reaches TableFilter,
|
|
7
|
+
// and that destroy() removes the host. Fails CI on regression.
|
|
8
|
+
const { test, expect } = require('@playwright/test');
|
|
9
|
+
|
|
10
|
+
const FIXTURE = '/test/test-emitter.html';
|
|
11
|
+
const TABLE_HTML =
|
|
12
|
+
'<tbody><tr><th>From</th></tr><tr><td>Sydney</td></tr></tbody>';
|
|
13
|
+
|
|
14
|
+
test('clear button bridge uses tf-clear-button', async ({ page }) => {
|
|
15
|
+
await page.goto(FIXTURE);
|
|
16
|
+
|
|
17
|
+
const result = await page.evaluate(async (tableHtml) => {
|
|
18
|
+
await import('/src/components/tf-clear-button.js');
|
|
19
|
+
|
|
20
|
+
const table = document.createElement('table');
|
|
21
|
+
table.id = 'ce-clear';
|
|
22
|
+
table.innerHTML = tableHtml;
|
|
23
|
+
document.body.appendChild(table);
|
|
24
|
+
|
|
25
|
+
const tf = new TableFilter('ce-clear', {
|
|
26
|
+
base_path: '/dist/tablefilter/',
|
|
27
|
+
btn_reset: { text: 'Clear' }
|
|
28
|
+
});
|
|
29
|
+
tf.init();
|
|
30
|
+
|
|
31
|
+
const clearButton = tf.feature('clearButton');
|
|
32
|
+
const host = clearButton.container;
|
|
33
|
+
const isCE = !!host && host.nodeName === 'TF-CLEAR-BUTTON';
|
|
34
|
+
|
|
35
|
+
let hits = 0;
|
|
36
|
+
tf.clearFilters = () => { hits++; };
|
|
37
|
+
const button = host && host.shadowRoot
|
|
38
|
+
? host.shadowRoot.querySelector('button') : null;
|
|
39
|
+
if (button) {
|
|
40
|
+
button.click();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
clearButton.destroy();
|
|
44
|
+
return {
|
|
45
|
+
isCE,
|
|
46
|
+
hasButton: !!button,
|
|
47
|
+
hits,
|
|
48
|
+
removed: !host.isConnected
|
|
49
|
+
};
|
|
50
|
+
}, TABLE_HTML);
|
|
51
|
+
|
|
52
|
+
expect(result.isCE).toBe(true);
|
|
53
|
+
expect(result.hasButton).toBe(true);
|
|
54
|
+
expect(result.hits).toBe(1);
|
|
55
|
+
expect(result.removed).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('icon markup stays on the legacy path when the element is loaded',
|
|
59
|
+
async ({ page }) => {
|
|
60
|
+
await page.goto(FIXTURE);
|
|
61
|
+
|
|
62
|
+
const result = await page.evaluate(async (tableHtml) => {
|
|
63
|
+
await import('/src/components/tf-clear-button.js');
|
|
64
|
+
|
|
65
|
+
const table = document.createElement('table');
|
|
66
|
+
table.id = 'ce-clear-icon';
|
|
67
|
+
table.innerHTML = tableHtml;
|
|
68
|
+
document.body.appendChild(table);
|
|
69
|
+
|
|
70
|
+
// Icons on (the default): this.html is <input class="reset">,
|
|
71
|
+
// the element the themes paint the eraser icon on. The element
|
|
72
|
+
// renders a bare <button>, so this must stay on the legacy path.
|
|
73
|
+
const tf = new TableFilter('ce-clear-icon', {
|
|
74
|
+
base_path: '/dist/tablefilter/',
|
|
75
|
+
btn_reset: true
|
|
76
|
+
});
|
|
77
|
+
tf.init();
|
|
78
|
+
|
|
79
|
+
const clearButton = tf.feature('clearButton');
|
|
80
|
+
const host = clearButton.container;
|
|
81
|
+
const icon = host ? host.querySelector('input.reset') : null;
|
|
82
|
+
|
|
83
|
+
clearButton.destroy();
|
|
84
|
+
return {
|
|
85
|
+
registered: Boolean(customElements.get('tf-clear-button')),
|
|
86
|
+
tag: host ? host.nodeName : null,
|
|
87
|
+
hasIcon: !!icon
|
|
88
|
+
};
|
|
89
|
+
}, TABLE_HTML);
|
|
90
|
+
|
|
91
|
+
expect(result.registered).toBe(true);
|
|
92
|
+
expect(result.tag).toBe('SPAN');
|
|
93
|
+
expect(result.hasIcon).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('status bar bridge uses tf-status', async ({ page }) => {
|
|
97
|
+
await page.goto(FIXTURE);
|
|
98
|
+
|
|
99
|
+
const result = await page.evaluate(async (tableHtml) => {
|
|
100
|
+
await import('/src/components/tf-status.js');
|
|
101
|
+
|
|
102
|
+
const table = document.createElement('table');
|
|
103
|
+
table.id = 'ce-status';
|
|
104
|
+
table.innerHTML = tableHtml;
|
|
105
|
+
document.body.appendChild(table);
|
|
106
|
+
|
|
107
|
+
const tf = new TableFilter('ce-status', {
|
|
108
|
+
base_path: '/dist/tablefilter/',
|
|
109
|
+
status_bar: true
|
|
110
|
+
});
|
|
111
|
+
tf.init();
|
|
112
|
+
|
|
113
|
+
const statusBar = tf.feature('statusBar');
|
|
114
|
+
const host = statusBar.container;
|
|
115
|
+
const isCE = !!host && host.nodeName === 'TF-STATUS';
|
|
116
|
+
|
|
117
|
+
statusBar.message('hello');
|
|
118
|
+
// message() is applied on a timeout.
|
|
119
|
+
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
120
|
+
const message = statusBar.msgContainer
|
|
121
|
+
? statusBar.msgContainer.innerHTML : null;
|
|
122
|
+
|
|
123
|
+
statusBar.destroy();
|
|
124
|
+
return { isCE, message, removed: !host.isConnected };
|
|
125
|
+
}, TABLE_HTML);
|
|
126
|
+
|
|
127
|
+
expect(result.isCE).toBe(true);
|
|
128
|
+
expect(result.message).toBe('hello');
|
|
129
|
+
expect(result.removed).toBe(true);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('rows counter bridge uses tf-rows-counter', async ({ page }) => {
|
|
133
|
+
await page.goto(FIXTURE);
|
|
134
|
+
|
|
135
|
+
const result = await page.evaluate(async (tableHtml) => {
|
|
136
|
+
await import('/src/components/tf-rows-counter.js');
|
|
137
|
+
|
|
138
|
+
const table = document.createElement('table');
|
|
139
|
+
table.id = 'ce-rows';
|
|
140
|
+
table.innerHTML = tableHtml;
|
|
141
|
+
document.body.appendChild(table);
|
|
142
|
+
|
|
143
|
+
const tf = new TableFilter('ce-rows', {
|
|
144
|
+
base_path: '/dist/tablefilter/',
|
|
145
|
+
rows_counter: true
|
|
146
|
+
});
|
|
147
|
+
tf.init();
|
|
148
|
+
|
|
149
|
+
const rowsCounter = tf.feature('rowsCounter');
|
|
150
|
+
const host = rowsCounter.container;
|
|
151
|
+
const isCE = !!host && host.nodeName === 'TF-ROWS-COUNTER';
|
|
152
|
+
|
|
153
|
+
rowsCounter.refresh();
|
|
154
|
+
const label = rowsCounter.label
|
|
155
|
+
? rowsCounter.label.innerHTML : null;
|
|
156
|
+
const countPart = host.shadowRoot.querySelector('[part="count"]');
|
|
157
|
+
const countText = countPart ? countPart.textContent : null;
|
|
158
|
+
|
|
159
|
+
rowsCounter.destroy();
|
|
160
|
+
return { isCE, label, countText, removed: !host.isConnected };
|
|
161
|
+
}, TABLE_HTML);
|
|
162
|
+
|
|
163
|
+
expect(result.isCE).toBe(true);
|
|
164
|
+
expect(result.label).toBe('1');
|
|
165
|
+
expect(result.countText).toBe('1');
|
|
166
|
+
expect(result.removed).toBe(true);
|
|
167
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// All-suites QUnit runner (#894): every test/*.html fixture runs
|
|
2
|
+
// headlessly in Chromium and must report zero failures.
|
|
3
|
+
const { test, expect } = require('@playwright/test');
|
|
4
|
+
const { discoverSuites, runQUnitSuite } = require('./qunitSuite');
|
|
5
|
+
|
|
6
|
+
for (const qunitFile of discoverSuites()) {
|
|
7
|
+
test(`QUnit suite: ${qunitFile}`, async ({ page }) => {
|
|
8
|
+
await runQUnitSuite(page, expect, qunitFile);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Single-file QUnit harness (#893): loads one existing QUnit HTML
|
|
2
|
+
// suite in headless Chromium and asserts zero failures. Override
|
|
3
|
+
// the suite with QUNIT_FILE, e.g.
|
|
4
|
+
// QUNIT_FILE=test/test-dropdown.html npx playwright test
|
|
5
|
+
// test/playwright/qunit.single.spec.js
|
|
6
|
+
const { test, expect } = require('@playwright/test');
|
|
7
|
+
const { runQUnitSuite } = require('./qunitSuite');
|
|
8
|
+
|
|
9
|
+
const qunitFile =
|
|
10
|
+
process.env.QUNIT_FILE || 'test/test-emitter.html';
|
|
11
|
+
|
|
12
|
+
test(`QUnit single suite: ${qunitFile}`, async ({ page }) => {
|
|
13
|
+
await runQUnitSuite(page, expect, qunitFile);
|
|
14
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Shared QUnit page driver: loads one existing QUnit HTML suite in a
|
|
2
|
+
// Playwright page and asserts zero failures. Used by the single-suite
|
|
3
|
+
// spec (#893) and the all-suites spec (#894).
|
|
4
|
+
const { readdirSync } = require('fs');
|
|
5
|
+
const { join } = require('path');
|
|
6
|
+
|
|
7
|
+
// All QUnit fixtures live directly in test/*.html.
|
|
8
|
+
function discoverSuites() {
|
|
9
|
+
return readdirSync(join(__dirname, '..'))
|
|
10
|
+
.filter((file) => file.endsWith('.html'))
|
|
11
|
+
.sort()
|
|
12
|
+
.map((file) => `test/${file}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function runQUnitSuite(page, expect, qunitFile) {
|
|
16
|
+
const errors = [];
|
|
17
|
+
page.on('pageerror', (err) => errors.push(String(err)));
|
|
18
|
+
|
|
19
|
+
await page.goto(`/${qunitFile}`);
|
|
20
|
+
|
|
21
|
+
// QUnit 1.x renders the summary into #qunit-testresult once done.
|
|
22
|
+
await page.waitForSelector('#qunit-testresult', {
|
|
23
|
+
timeout: 15000
|
|
24
|
+
});
|
|
25
|
+
await page.waitForFunction(
|
|
26
|
+
() => {
|
|
27
|
+
const el =
|
|
28
|
+
document.querySelector('#qunit-testresult');
|
|
29
|
+
return el && /completed/i.test(el.textContent || '');
|
|
30
|
+
},
|
|
31
|
+
{ timeout: 15000 }
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const summary = await page.evaluate(() => {
|
|
35
|
+
const el = document.querySelector('#qunit-testresult');
|
|
36
|
+
const count = (cls) => {
|
|
37
|
+
const node = el && el.querySelector(`.${cls}`);
|
|
38
|
+
return node ? Number(node.textContent) : NaN;
|
|
39
|
+
};
|
|
40
|
+
const text = el ?
|
|
41
|
+
el.textContent.trim().replace(/\s+/g, ' ') :
|
|
42
|
+
'';
|
|
43
|
+
return {
|
|
44
|
+
text,
|
|
45
|
+
total: count('total'),
|
|
46
|
+
failed: count('failed')
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
expect(errors, `page errors: ${errors.join('; ')}`).toEqual([]);
|
|
51
|
+
expect(summary.failed, `QUnit summary: ${summary.text}`).toBe(0);
|
|
52
|
+
expect(summary.total, `no tests ran in ${qunitFile}`)
|
|
53
|
+
.toBeGreaterThan(0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = { discoverSuites, runQUnitSuite };
|