tablefilter 0.7.3 → 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/.editorconfig +15 -15
- package/.esdoc.json +14 -14
- package/.eslintrc +37 -37
- package/.gitattributes +16 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +36 -36
- package/.github/ISSUE_TEMPLATE/support.md +17 -17
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/build-deploy.yml +141 -0
- package/.github/workflows/opencode-review.yml +104 -0
- package/.github/workflows/opencode.yml +34 -0
- package/AGENTS.md +36 -0
- package/CONTRIBUTING.md +128 -128
- package/Gruntfile.js +252 -252
- package/LICENSE +21 -21
- package/PULL_REQUEST_TEMPLATE.md +24 -24
- package/README.md +166 -174
- package/ROADMAP/README.md +34 -0
- package/ROADMAP/content-projection-parity.md +162 -0
- package/ROADMAP/hybrid-migration-strategy.md +275 -0
- package/ROADMAP/key-decisions-review.md +215 -0
- package/ROADMAP/preliminary-and-milestone-0.8.0-plan.md +307 -0
- package/ROADMAP/v1-webcomponents-investigation.md +521 -0
- package/dist/starter.html +514 -514
- 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/index.js +3 -3
- package/libs/sortabletable.js +438 -438
- package/package.json +12 -5
- package/playwright.config.js +25 -0
- package/scripts/check-css-tokens.js +65 -0
- package/src/array.js +22 -22
- 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/const.js +118 -118
- package/src/cookie.js +57 -57
- package/src/dom.js +192 -192
- package/src/emitter.js +53 -53
- package/src/event.js +124 -124
- package/src/extensions/advancedGrid/adapterEzEditTable.js +509 -509
- package/src/extensions/advancedGrid/advancedGrid.js +2 -2
- package/src/extensions/colOps/colOps.js +474 -480
- package/src/extensions/colsVisibility/colsVisibility.js +725 -725
- package/src/extensions/filtersVisibility/filtersVisibility.js +316 -316
- package/src/extensions/sort/adapterSortabletable.js +537 -537
- package/src/extensions/sort/sort.js +8 -8
- package/src/feature.js +102 -102
- package/src/modules/alternateRows.js +145 -145
- package/src/modules/baseDropdown.js +160 -160
- package/src/modules/checkList.js +519 -519
- package/src/modules/clearButton.js +196 -142
- package/src/modules/dateType.js +157 -157
- package/src/modules/dropdown.js +376 -376
- package/src/modules/gridLayout.js +483 -483
- package/src/modules/hash.js +126 -126
- package/src/modules/help.js +264 -264
- package/src/modules/highlightKeywords.js +180 -180
- package/src/modules/loader.js +183 -183
- package/src/modules/markActiveColumns.js +146 -146
- package/src/modules/noResults.js +193 -193
- package/src/modules/paging.js +916 -916
- package/src/modules/popupFilter.js +461 -461
- package/src/modules/rowsCounter.js +230 -207
- package/src/modules/state.js +545 -545
- package/src/modules/statusBar.js +340 -308
- package/src/modules/storage.js +161 -161
- package/src/modules/toolbar.js +224 -224
- package/src/number.js +96 -32
- package/src/root.js +6 -6
- package/src/sanitize.js +25 -0
- package/src/settings.js +53 -53
- package/src/sort.js +82 -82
- package/src/string.js +112 -112
- package/src/tablefilter.js +3053 -3053
- package/src/types.js +81 -81
- package/static/partials/books-table-with-images.html +327 -327
- package/static/partials/books.html +272 -272
- package/static/partials/countries-by-continent.html +2592 -2592
- package/static/partials/countries-table-tiny.html +436 -436
- package/static/partials/countries-table.html +12954 -12954
- package/static/partials/dummy-table-with-totals-footer.html +353 -353
- package/static/partials/dummy-table.html +502 -502
- package/static/partials/pre-inline-script.html +17 -17
- package/static/partials/pre.html +1 -1
- package/static/partials/style.html +22 -22
- package/static/partials/table-with-grouped-headers.html +9258 -9258
- package/static/style/active-header.styl +10 -10
- package/static/style/alternating-rows.styl +8 -8
- package/static/style/config.styl +44 -44
- package/static/style/custom-properties.styl +43 -0
- package/static/style/extensions/colsVisibility.styl +71 -71
- package/static/style/extensions/filtersVisibility.styl +18 -18
- package/static/style/ezedittable.styl +93 -93
- package/static/style/filter-checklist.styl +52 -52
- package/static/style/filters.styl +111 -111
- package/static/style/grid-layout.styl +130 -130
- package/static/style/help.styl +57 -57
- package/static/style/keyword.styl +8 -8
- package/static/style/loader.styl +16 -16
- package/static/style/mixins/arrow.styl +63 -63
- package/static/style/mixins/box-shadow.styl +8 -8
- package/static/style/mixins/empty-content.styl +7 -7
- package/static/style/noresults.styl +14 -14
- package/static/style/paging.styl +73 -73
- package/static/style/reset-button.styl +21 -21
- package/static/style/rows-counter.styl +17 -17
- package/static/style/sort.styl +20 -20
- package/static/style/status-bar.styl +13 -16
- package/static/style/table.styl +44 -44
- package/static/style/tablefilter.styl +19 -18
- package/static/style/themes/default/default.styl +137 -137
- package/static/style/themes/mytheme/mytheme.styl +152 -152
- package/static/style/themes/skyblue/skyblue.styl +195 -195
- package/static/style/themes/transparent/transparent.styl +205 -205
- package/static/style/toolbar.styl +58 -58
- package/static/templates/advanced-grid-editable.html +140 -140
- package/static/templates/advanced-grid-selection.html +93 -93
- package/static/templates/auto-filter.html +46 -46
- package/static/templates/columns-visibility.html +67 -67
- package/static/templates/data-types.html +123 -123
- package/static/templates/demo.html +62 -62
- package/static/templates/external-filters-visibility-commad.html +49 -49
- package/static/templates/external-filters.html +125 -125
- package/static/templates/filter-images.html +91 -91
- package/static/templates/filters-visibility.html +45 -45
- package/static/templates/grid-layout.html +51 -51
- package/static/templates/grouped-headers.html +78 -78
- package/static/templates/linked-filters-disabled.html +56 -56
- package/static/templates/linked-filters.html +45 -45
- package/static/templates/load-filters-on-demand.html +42 -42
- package/static/templates/pagination.html +78 -78
- package/static/templates/requirejs.html +53 -53
- package/static/templates/starter.html +61 -61
- package/static/templates/table-filter.html +40 -0
- package/static/templates/theme-roller.html +106 -106
- package/test/libs/polyfill.js +359 -359
- package/test/libs/qunit/qunit.css +237 -237
- package/test/libs/qunit/qunit.js +2495 -2495
- 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-active-columns.html +80 -80
- package/test/test-active-columns.js +318 -318
- package/test/test-alternate-rows.html +80 -80
- package/test/test-alternate-rows.js +335 -335
- package/test/test-api.html +141 -141
- package/test/test-api.js +795 -795
- package/test/test-auto-filter.html +80 -80
- package/test/test-auto-filter.js +43 -43
- package/test/test-callbacks.html +77 -77
- package/test/test-callbacks.js +58 -58
- package/test/test-case-sensitive-query.html +77 -77
- package/test/test-case-sensitive-query.js +39 -39
- package/test/test-cell-parser.html +109 -109
- package/test/test-cell-parser.js +80 -80
- package/test/test-checklist.html +77 -77
- package/test/test-checklist.js +267 -267
- package/test/test-clear-button.html +79 -79
- package/test/test-clear-button.js +183 -182
- package/test/test-col-ops-grid-layout.html +129 -129
- package/test/test-col-ops-grid-layout.js +134 -134
- package/test/test-col-ops-paging.html +129 -129
- package/test/test-col-ops-paging.js +154 -154
- package/test/test-col-ops.html +129 -129
- package/test/test-col-ops.js +337 -202
- package/test/test-col-widths.html +80 -80
- package/test/test-col-widths.js +40 -40
- package/test/test-cols-visibility-grid-layout.html +80 -80
- package/test/test-cols-visibility-grid-layout.js +165 -165
- package/test/test-cols-visibility.html +80 -80
- package/test/test-cols-visibility.js +121 -121
- package/test/test-custom-options.html +80 -80
- package/test/test-custom-options.js +139 -139
- package/test/test-data-types.html +377 -377
- package/test/test-data-types.js +392 -392
- package/test/test-date-type.html +356 -356
- package/test/test-date-type.js +159 -159
- package/test/test-disable-enter-key.html +77 -77
- package/test/test-disable-enter-key.js +29 -29
- package/test/test-disable-filter-onchange.html +77 -77
- package/test/test-disable-filter-onchange.js +40 -40
- package/test/test-dom-changes.html +77 -77
- package/test/test-dom-changes.js +166 -166
- package/test/test-dropdown.html +77 -77
- package/test/test-dropdown.js +246 -246
- package/test/test-emitter.html +77 -77
- package/test/test-emitter.js +57 -57
- package/test/test-empty-cells-filtering.html +8696 -8696
- package/test/test-empty-cells-filtering.js +45 -45
- package/test/test-exact-query-match.html +77 -77
- package/test/test-exact-query-match.js +56 -56
- package/test/test-excluded-rows.html +92 -92
- package/test/test-excluded-rows.js +129 -129
- package/test/test-external-filters.html +100 -100
- package/test/test-external-filters.js +219 -219
- package/test/test-filter-html-elements.html +88 -88
- package/test/test-filter-html-elements.js +63 -63
- package/test/test-filter-operators.html +80 -80
- package/test/test-filter-operators.js +264 -264
- package/test/test-filtering.html +53 -53
- package/test/test-filtering.js +293 -293
- package/test/test-filters-visibility-grid-layout.html +80 -80
- package/test/test-filters-visibility-grid-layout.js +50 -50
- package/test/test-filters-visibility-with-button.html +80 -80
- package/test/test-filters-visibility-with-button.js +48 -48
- package/test/test-filters-visibility.html +80 -80
- package/test/test-filters-visibility.js +48 -48
- package/test/test-grid-layout.html +7735 -7735
- package/test/test-grid-layout.js +39 -39
- package/test/test-grouped-headers.html +154 -154
- package/test/test-grouped-headers.js +107 -107
- package/test/test-hash.html +78 -78
- package/test/test-hash.js +88 -88
- package/test/test-help-responsive.html +78 -78
- package/test/test-help-responsive.js +70 -70
- package/test/test-help.html +77 -77
- package/test/test-help.js +217 -217
- package/test/test-highlight-keywords.html +77 -77
- package/test/test-highlight-keywords.js +94 -94
- package/test/test-ignore-diacritics.html +67 -57
- package/test/test-ignore-diacritics.js +117 -90
- package/test/test-integration-paging-sort.html +79 -79
- package/test/test-integration-paging-sort.js +60 -60
- package/test/test-linked-filters-disabled-options-grid-layout.html +80 -80
- package/test/test-linked-filters-disabled-options-grid-layout.js +73 -73
- package/test/test-linked-filters-grid-layout.html +80 -80
- package/test/test-linked-filters-grid-layout.js +72 -72
- package/test/test-linked-filters-load-filters-on-demand.html +80 -80
- package/test/test-linked-filters-load-filters-on-demand.js +99 -99
- package/test/test-linked-filters-paging.html +80 -80
- package/test/test-linked-filters-paging.js +99 -99
- package/test/test-linked-filters.html +80 -80
- package/test/test-linked-filters.js +138 -138
- package/test/test-load-filters-on-demand.html +77 -77
- package/test/test-load-filters-on-demand.js +124 -124
- package/test/test-loader.html +79 -79
- package/test/test-loader.js +159 -159
- package/test/test-no-config.html +80 -80
- package/test/test-no-config.js +63 -63
- package/test/test-no-filters.html +80 -80
- package/test/test-no-filters.js +172 -172
- package/test/test-no-headers.html +71 -71
- package/test/test-no-headers.js +99 -99
- package/test/test-no-results-message.html +262 -262
- package/test/test-no-results-message.js +222 -222
- package/test/test-no-rows.html +19 -19
- package/test/test-no-rows.js +10 -10
- package/test/test-one-row.html +29 -29
- package/test/test-one-row.js +18 -18
- package/test/test-paging.html +78 -78
- package/test/test-paging.js +273 -273
- package/test/test-popup-filter-one-row.html +38 -38
- package/test/test-popup-filter-one-row.js +138 -138
- package/test/test-popup-filter.html +78 -78
- package/test/test-popup-filter.js +384 -384
- package/test/test-popup-filters-grouped-headers.html +104 -104
- package/test/test-popup-filters-grouped-headers.js +206 -206
- package/test/test-rows-counter.html +77 -77
- package/test/test-rows-counter.js +114 -112
- package/test/test-single-filter.html +78 -78
- package/test/test-single-filter.js +138 -138
- package/test/test-sort-custom-sorter.html +243 -243
- package/test/test-sort-custom-sorter.js +74 -74
- package/test/test-sort-grid-layout.html +142 -142
- package/test/test-sort-grid-layout.js +86 -86
- package/test/test-sort-key.html +243 -243
- package/test/test-sort-key.js +67 -67
- package/test/test-sort.html +142 -142
- package/test/test-sort.js +126 -126
- package/test/test-state.html +78 -78
- package/test/test-state.js +369 -369
- package/test/test-status-bar.html +79 -79
- package/test/test-status-bar.js +149 -146
- package/test/test-storage-cookie.html +78 -78
- package/test/test-storage-cookie.js +82 -82
- package/test/test-storage-local.html +78 -78
- package/test/test-storage-local.js +82 -82
- package/test/test-tfoot.html +96 -96
- package/test/test-tfoot.js +123 -123
- package/test/test-thead.html +80 -80
- package/test/test-thead.js +69 -69
- package/test/test-toolbar.html +81 -81
- package/test/test-toolbar.js +218 -218
- package/test/test-uneven-rows.html +95 -95
- package/test/test-uneven-rows.js +61 -61
- package/test/test-watermark.html +80 -80
- package/test/test-watermark.js +103 -103
- package/test/test.html +141 -141
- package/test/test.js +162 -162
- package/vite.config.js +71 -0
- package/webpack.config.js +99 -87
- package/webpack.dev.config.js +25 -25
- package/webpack.test.config.js +44 -44
- package/.travis.yml +0 -53
- package/dist/tablefilter/tf-1-2aa33b10e0e549020c12.js +0 -1
|
@@ -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 };
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
// Component gate (#901): declarative configuration — the `config`
|
|
2
|
+
// JSON attribute merged with kebab-case attributes mapped onto the
|
|
3
|
+
// engine's snake_case options, attributes winning over the blob,
|
|
4
|
+
// valueless attributes enabling their flag, and HTML presentation
|
|
5
|
+
// attributes staying out of the engine config. Fails CI on regression.
|
|
6
|
+
|
|
7
|
+
const { test, expect } = require('@playwright/test');
|
|
8
|
+
|
|
9
|
+
const FIXTURE = '/test/test-emitter.html';
|
|
10
|
+
const COMPONENT = '/src/components/table-filter.js';
|
|
11
|
+
|
|
12
|
+
const VALID_TABLE =
|
|
13
|
+
'<table><tbody>' +
|
|
14
|
+
'<tr><th>City</th></tr>' +
|
|
15
|
+
'<tr><td>Sydney</td></tr>' +
|
|
16
|
+
'<tr><td>Adelaide</td></tr>' +
|
|
17
|
+
'</tbody></table>';
|
|
18
|
+
|
|
19
|
+
// Mounts a <table-filter> with the given extra markup inside the
|
|
20
|
+
// element tag, then reports selected engine state as primitives.
|
|
21
|
+
async function mount(page, elementAttrs, body) {
|
|
22
|
+
return page.evaluate(
|
|
23
|
+
async ({ elementAttrs, component, table, body }) => {
|
|
24
|
+
await import(component);
|
|
25
|
+
const host = document.createElement('div');
|
|
26
|
+
host.innerHTML =
|
|
27
|
+
'<table-filter' + elementAttrs + '>' + table +
|
|
28
|
+
'</table-filter>';
|
|
29
|
+
document.body.appendChild(host);
|
|
30
|
+
const el = host.querySelector('table-filter');
|
|
31
|
+
const tf = el.tf;
|
|
32
|
+
const result = {
|
|
33
|
+
hasTf: Boolean(tf),
|
|
34
|
+
initialized: Boolean(tf && tf.isInitialized()),
|
|
35
|
+
watermark: tf && tf.watermark,
|
|
36
|
+
caseSensitive: tf && tf.caseSensitive,
|
|
37
|
+
onSlcChange: tf && tf.onSlcChange,
|
|
38
|
+
paging: tf && tf.paging,
|
|
39
|
+
colTypes: tf && tf.colTypes,
|
|
40
|
+
hasConfig: tf && tf.hasConfig,
|
|
41
|
+
modCount: tf ? Object.keys(tf.Mod).length : null,
|
|
42
|
+
protoIsPlain: tf ?
|
|
43
|
+
Object.getPrototypeOf(tf.cfg) === Object.prototype :
|
|
44
|
+
null,
|
|
45
|
+
cfgKeys: tf ? Object.keys(tf.cfg) : null,
|
|
46
|
+
validRows: null,
|
|
47
|
+
filterValue: null,
|
|
48
|
+
basePath: tf && tf.basePath,
|
|
49
|
+
themes: tf && tf.themes,
|
|
50
|
+
fltCssClass: tf && tf.fltCssClass,
|
|
51
|
+
fltsRowCssClass: tf && tf.fltsRowCssClass,
|
|
52
|
+
fltMultiCssClass: tf && tf.fltMultiCssClass,
|
|
53
|
+
fltSmallCssClass: tf && tf.fltSmallCssClass,
|
|
54
|
+
singleFltCssClass: tf && tf.singleFltCssClass,
|
|
55
|
+
btnCssClass: tf && tf.btnCssClass
|
|
56
|
+
};
|
|
57
|
+
if (body === 'filter-lowercase') {
|
|
58
|
+
tf.setFilterValue(0, 'sydney');
|
|
59
|
+
tf.filter();
|
|
60
|
+
result.validRows = tf.getValidRowsNb();
|
|
61
|
+
}
|
|
62
|
+
if (body === 'filter-match') {
|
|
63
|
+
tf.setFilterValue(0, 'Sydney');
|
|
64
|
+
tf.filter();
|
|
65
|
+
result.validRows = tf.getValidRowsNb();
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
elementAttrs,
|
|
71
|
+
component: COMPONENT,
|
|
72
|
+
table: VALID_TABLE,
|
|
73
|
+
body: body || null
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
test('attributes map onto engine options', async ({ page }) => {
|
|
79
|
+
await page.goto(FIXTURE);
|
|
80
|
+
const result = await mount(
|
|
81
|
+
page,
|
|
82
|
+
' watermark="Search" case-sensitive="true" ' +
|
|
83
|
+
'col-types=\'["string"]\''
|
|
84
|
+
);
|
|
85
|
+
expect(result.watermark).toBe('Search');
|
|
86
|
+
expect(result.caseSensitive).toBe(true);
|
|
87
|
+
expect(result.colTypes).toEqual(['string']);
|
|
88
|
+
expect(result.initialized).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('config attribute maps a JSON object', async ({ page }) => {
|
|
92
|
+
await page.goto(FIXTURE);
|
|
93
|
+
const result = await mount(
|
|
94
|
+
page,
|
|
95
|
+
' config=\'{"watermark":"Blob","on_change":false}\''
|
|
96
|
+
);
|
|
97
|
+
expect(result.watermark).toBe('Blob');
|
|
98
|
+
expect(result.onSlcChange).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('attributes win over the config attribute', async ({ page }) => {
|
|
102
|
+
await page.goto(FIXTURE);
|
|
103
|
+
const result = await mount(
|
|
104
|
+
page,
|
|
105
|
+
' config=\'{"watermark":"Blob"}\' watermark="Explicit"'
|
|
106
|
+
);
|
|
107
|
+
expect(result.watermark).toBe('Explicit');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('for and id are never mapped into the config', async ({ page }) => {
|
|
111
|
+
await page.goto(FIXTURE);
|
|
112
|
+
const result = await mount(page, ' for="demo" id="host-el"');
|
|
113
|
+
expect(result.cfgKeys).not.toContain('for');
|
|
114
|
+
expect(result.cfgKeys).not.toContain('id');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('valueless attributes enable their flag (HTML convention)', async ({
|
|
118
|
+
page
|
|
119
|
+
}) => {
|
|
120
|
+
await page.goto(FIXTURE);
|
|
121
|
+
// <table-filter paging> is the roadmap's primary declarative usage:
|
|
122
|
+
// presence must enable paging, not `Boolean('') === false`.
|
|
123
|
+
const result = await mount(page, ' paging');
|
|
124
|
+
expect(result.paging).toBe(true);
|
|
125
|
+
expect(result.initialized).toBe(true);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('presentation attributes are not engine config', async ({ page }) => {
|
|
129
|
+
await page.goto(FIXTURE);
|
|
130
|
+
const result = await mount(
|
|
131
|
+
page,
|
|
132
|
+
' class="card" style="color:red" data-x="1" aria-label="grid" ' +
|
|
133
|
+
'role="region" title="Cities"'
|
|
134
|
+
);
|
|
135
|
+
// A stray class/style/data/aria attribute must not count as
|
|
136
|
+
// configuration: it would flip hasConfig and cut constructed
|
|
137
|
+
// features down to the config-path subset.
|
|
138
|
+
expect(result.cfgKeys).toEqual([]);
|
|
139
|
+
expect(result.hasConfig).toBe(false);
|
|
140
|
+
expect(result.modCount).toBeGreaterThan(3);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('boolean spellings the JSON parser rejects are coerced', async ({
|
|
144
|
+
page
|
|
145
|
+
}) => {
|
|
146
|
+
await page.goto(FIXTURE);
|
|
147
|
+
const result = await mount(
|
|
148
|
+
page,
|
|
149
|
+
' case-sensitive="False" on-change="FALSE"'
|
|
150
|
+
);
|
|
151
|
+
// Without coercion these stay strings and Boolean('False') is true.
|
|
152
|
+
expect(result.caseSensitive).toBe(false);
|
|
153
|
+
expect(result.onSlcChange).toBe(false);
|
|
154
|
+
|
|
155
|
+
const truthy = await mount(page, ' case-sensitive="True"');
|
|
156
|
+
expect(truthy.caseSensitive).toBe(true);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('prototype-reaching attribute names are ignored', async ({ page }) => {
|
|
160
|
+
await page.goto(FIXTURE);
|
|
161
|
+
const result = await mount(
|
|
162
|
+
page,
|
|
163
|
+
' __proto__=\'{"paging":true}\' constructor="x" prototype="y"'
|
|
164
|
+
);
|
|
165
|
+
// Assigning config['__proto__'] would invoke the Object.prototype
|
|
166
|
+
// setter and swap the config's prototype instead of setting paging.
|
|
167
|
+
expect(result.protoIsPlain).toBe(true);
|
|
168
|
+
expect(result.hasConfig).toBe(false);
|
|
169
|
+
expect(result.paging).toBe(false);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('no config keeps engine defaults and hasConfig false', async ({
|
|
173
|
+
page
|
|
174
|
+
}) => {
|
|
175
|
+
await page.goto(FIXTURE);
|
|
176
|
+
const result = await mount(page, '');
|
|
177
|
+
// An empty {} reaching the constructor would flip hasConfig and
|
|
178
|
+
// change feature instantiation; the mapping must omit it.
|
|
179
|
+
expect(result.hasConfig).toBe(false);
|
|
180
|
+
expect(result.watermark).toBe('');
|
|
181
|
+
expect(result.initialized).toBe(true);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('invalid config JSON warns and still inits on defaults', async ({
|
|
185
|
+
page
|
|
186
|
+
}) => {
|
|
187
|
+
await page.goto(FIXTURE);
|
|
188
|
+
const warnings = [];
|
|
189
|
+
page.on('console', (msg) => {
|
|
190
|
+
if (msg.type() === 'warning') {
|
|
191
|
+
warnings.push(msg.text());
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
const result = await mount(page, ' config="{not json"');
|
|
195
|
+
expect(result.initialized).toBe(true);
|
|
196
|
+
expect(result.watermark).toBe('');
|
|
197
|
+
expect(warnings.join('\n')).toContain('<table-filter>');
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// Styling configurability lives in the core engine, not only in the
|
|
201
|
+
// features (#993): the loader keys (base_path, themes) and the core
|
|
202
|
+
// filter class options must reach the engine through the declarative
|
|
203
|
+
// surface. NOTE: the `style_path` / `stylesheet` / `themes_path`
|
|
204
|
+
// overrides are currently ignored by the engine (#822), so asserting
|
|
205
|
+
// them here would encode the bug; that is tracked separately.
|
|
206
|
+
test('styling configuration reaches the engine', async ({ page }) => {
|
|
207
|
+
// base_path drives the stylesheet/theme the engine loads on init, and
|
|
208
|
+
// its loader throws from `file.onerror` when a file 404s. Serve the
|
|
209
|
+
// fake path so this test asserts config mapping, not asset
|
|
210
|
+
// availability (otherwise it emits unhandled load errors).
|
|
211
|
+
await page.route('**/assets/tf/**', (route) =>
|
|
212
|
+
route.fulfill({
|
|
213
|
+
status: 200,
|
|
214
|
+
contentType: 'text/css',
|
|
215
|
+
body: ''
|
|
216
|
+
}));
|
|
217
|
+
await page.goto(FIXTURE);
|
|
218
|
+
const result = await mount(
|
|
219
|
+
page,
|
|
220
|
+
' base-path="/assets/tf/" flt-css-class="my-flt" ' +
|
|
221
|
+
'flts-row-css-class="my-fltrow" btn-css-class="my-btn" ' +
|
|
222
|
+
'single-filter=\'{"css_class":"my-single"}\' ' +
|
|
223
|
+
'config=\'{"themes":[{"name":"skyblue"}],' +
|
|
224
|
+
'"flt_multi_css_class":"my-multi"}\''
|
|
225
|
+
);
|
|
226
|
+
expect(result.initialized).toBe(true);
|
|
227
|
+
// Core stylesheet/theme loader key.
|
|
228
|
+
expect(result.basePath).toBe('/assets/tf/');
|
|
229
|
+
expect(result.themes).toContainEqual({ name: 'skyblue' });
|
|
230
|
+
// Core filter class options.
|
|
231
|
+
expect(result.fltsRowCssClass).toBe('my-fltrow');
|
|
232
|
+
expect(result.fltCssClass).toBe('my-flt');
|
|
233
|
+
expect(result.fltMultiCssClass).toBe('my-multi');
|
|
234
|
+
expect(result.singleFltCssClass).toBe('my-single');
|
|
235
|
+
expect(result.btnCssClass).toBe('my-btn');
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
test('core styling defaults are unchanged when unset', async ({ page }) => {
|
|
239
|
+
await page.goto(FIXTURE);
|
|
240
|
+
const result = await mount(page, '');
|
|
241
|
+
expect(result.basePath).toBe('tablefilter/');
|
|
242
|
+
expect(result.fltsRowCssClass).toBe('fltrow');
|
|
243
|
+
expect(result.fltCssClass).toBe('flt');
|
|
244
|
+
expect(result.fltMultiCssClass).toBe('flt_multi');
|
|
245
|
+
expect(result.fltSmallCssClass).toBe('flt_s');
|
|
246
|
+
expect(result.singleFltCssClass).toBe('single_flt');
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test('mapped option drives filtering behaviour', async ({ page }) => {
|
|
250
|
+
await page.goto(FIXTURE);
|
|
251
|
+
const match = await mount(page, '', 'filter-match');
|
|
252
|
+
expect(match.validRows).toBe(1);
|
|
253
|
+
|
|
254
|
+
const caseSensitive = await mount(
|
|
255
|
+
page,
|
|
256
|
+
' case-sensitive="true"',
|
|
257
|
+
'filter-lowercase'
|
|
258
|
+
);
|
|
259
|
+
// case_sensitive is on: lowercase 'sydney' must not match 'Sydney'
|
|
260
|
+
expect(caseSensitive.validRows).toBe(0);
|
|
261
|
+
|
|
262
|
+
const insensitive = await mount(page, '', 'filter-lowercase');
|
|
263
|
+
// default is case-insensitive: 'sydney' matches
|
|
264
|
+
expect(insensitive.validRows).toBe(1);
|
|
265
|
+
});
|