@operato/data-grist 10.29.74 → 10.29.76

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.
Files changed (162) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/data-card/record-card.js +1 -1
  3. package/dist/src/data-card/record-card.js.map +1 -1
  4. package/dist/src/data-grid/data-grid-field.js +18 -0
  5. package/dist/src/data-grid/data-grid-field.js.map +1 -1
  6. package/dist/src/data-list/data-list-field.js +4 -1
  7. package/dist/src/data-list/data-list-field.js.map +1 -1
  8. package/dist/src/data-list/record-partial.js +15 -1
  9. package/dist/src/data-list/record-partial.js.map +1 -1
  10. package/dist/src/filters/filter-checkbox.js +1 -1
  11. package/dist/src/filters/filter-checkbox.js.map +1 -1
  12. package/dist/src/filters/filter-input-barcode.js +1 -1
  13. package/dist/src/filters/filter-input-barcode.js.map +1 -1
  14. package/dist/src/filters/filter-input.js +1 -1
  15. package/dist/src/filters/filter-input.js.map +1 -1
  16. package/dist/src/filters/filter-range-date.js +1 -1
  17. package/dist/src/filters/filter-range-date.js.map +1 -1
  18. package/dist/src/filters/filter-range-number.js +1 -1
  19. package/dist/src/filters/filter-range-number.js.map +1 -1
  20. package/dist/src/filters/filter-select-buttons.js +1 -1
  21. package/dist/src/filters/filter-select-buttons.js.map +1 -1
  22. package/dist/src/types.d.ts +1 -1
  23. package/dist/src/types.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +9 -9
  26. package/test/cell-button-row-height.test.ts +63 -0
  27. package/test/office-density.test.ts +57 -0
  28. package/dist/test/accessible-name.test.d.ts +0 -2
  29. package/dist/test/accessible-name.test.js +0 -324
  30. package/dist/test/accessible-name.test.js.map +0 -1
  31. package/dist/test/accumulator-labels.test.d.ts +0 -1
  32. package/dist/test/accumulator-labels.test.js +0 -32
  33. package/dist/test/accumulator-labels.test.js.map +0 -1
  34. package/dist/test/address-intents.test.d.ts +0 -1
  35. package/dist/test/address-intents.test.js +0 -201
  36. package/dist/test/address-intents.test.js.map +0 -1
  37. package/dist/test/card-selector.test.d.ts +0 -1
  38. package/dist/test/card-selector.test.js +0 -58
  39. package/dist/test/card-selector.test.js.map +0 -1
  40. package/dist/test/card-thumb.test.d.ts +0 -1
  41. package/dist/test/card-thumb.test.js +0 -44
  42. package/dist/test/card-thumb.test.js.map +0 -1
  43. package/dist/test/card-totals-narrow.test.d.ts +0 -1
  44. package/dist/test/card-totals-narrow.test.js +0 -103
  45. package/dist/test/card-totals-narrow.test.js.map +0 -1
  46. package/dist/test/column-resize.test.d.ts +0 -1
  47. package/dist/test/column-resize.test.js +0 -153
  48. package/dist/test/column-resize.test.js.map +0 -1
  49. package/dist/test/control-heights.test.d.ts +0 -1
  50. package/dist/test/control-heights.test.js +0 -25
  51. package/dist/test/control-heights.test.js.map +0 -1
  52. package/dist/test/count-handler.test.d.ts +0 -1
  53. package/dist/test/count-handler.test.js +0 -56
  54. package/dist/test/count-handler.test.js.map +0 -1
  55. package/dist/test/create-paste-policy.test.d.ts +0 -1
  56. package/dist/test/create-paste-policy.test.js +0 -159
  57. package/dist/test/create-paste-policy.test.js.map +0 -1
  58. package/dist/test/data-integrity.test.d.ts +0 -1
  59. package/dist/test/data-integrity.test.js +0 -145
  60. package/dist/test/data-integrity.test.js.map +0 -1
  61. package/dist/test/destructive-actions.test.d.ts +0 -11
  62. package/dist/test/destructive-actions.test.js +0 -147
  63. package/dist/test/destructive-actions.test.js.map +0 -1
  64. package/dist/test/edit-lifecycle.test.d.ts +0 -2
  65. package/dist/test/edit-lifecycle.test.js +0 -270
  66. package/dist/test/edit-lifecycle.test.js.map +0 -1
  67. package/dist/test/edit-rebase.test.d.ts +0 -1
  68. package/dist/test/edit-rebase.test.js +0 -185
  69. package/dist/test/edit-rebase.test.js.map +0 -1
  70. package/dist/test/editor-commit.test.d.ts +0 -2
  71. package/dist/test/editor-commit.test.js +0 -68
  72. package/dist/test/editor-commit.test.js.map +0 -1
  73. package/dist/test/fetch-failure-state.test.d.ts +0 -1
  74. package/dist/test/fetch-failure-state.test.js +0 -129
  75. package/dist/test/fetch-failure-state.test.js.map +0 -1
  76. package/dist/test/field-contains-content.test.d.ts +0 -1
  77. package/dist/test/field-contains-content.test.js +0 -101
  78. package/dist/test/field-contains-content.test.js.map +0 -1
  79. package/dist/test/field-hint.test.d.ts +0 -2
  80. package/dist/test/field-hint.test.js +0 -54
  81. package/dist/test/field-hint.test.js.map +0 -1
  82. package/dist/test/filter-labels.test.d.ts +0 -2
  83. package/dist/test/filter-labels.test.js +0 -140
  84. package/dist/test/filter-labels.test.js.map +0 -1
  85. package/dist/test/filter-ownership.test.d.ts +0 -1
  86. package/dist/test/filter-ownership.test.js +0 -83
  87. package/dist/test/filter-ownership.test.js.map +0 -1
  88. package/dist/test/filter-select-buttons-count.test.d.ts +0 -1
  89. package/dist/test/filter-select-buttons-count.test.js +0 -35
  90. package/dist/test/filter-select-buttons-count.test.js.map +0 -1
  91. package/dist/test/filter-typing.test.d.ts +0 -2
  92. package/dist/test/filter-typing.test.js +0 -66
  93. package/dist/test/filter-typing.test.js.map +0 -1
  94. package/dist/test/filters-phone-wrap.test.d.ts +0 -1
  95. package/dist/test/filters-phone-wrap.test.js +0 -17
  96. package/dist/test/filters-phone-wrap.test.js.map +0 -1
  97. package/dist/test/first-click-stays.test.d.ts +0 -1
  98. package/dist/test/first-click-stays.test.js +0 -77
  99. package/dist/test/first-click-stays.test.js.map +0 -1
  100. package/dist/test/fixed-column-opaque.test.d.ts +0 -1
  101. package/dist/test/fixed-column-opaque.test.js +0 -134
  102. package/dist/test/fixed-column-opaque.test.js.map +0 -1
  103. package/dist/test/flexible-columns.test.d.ts +0 -1
  104. package/dist/test/flexible-columns.test.js +0 -134
  105. package/dist/test/flexible-columns.test.js.map +0 -1
  106. package/dist/test/grid-single-scroller.test.d.ts +0 -1
  107. package/dist/test/grid-single-scroller.test.js +0 -107
  108. package/dist/test/grid-single-scroller.test.js.map +0 -1
  109. package/dist/test/group-heading.test.d.ts +0 -1
  110. package/dist/test/group-heading.test.js +0 -208
  111. package/dist/test/group-heading.test.js.map +0 -1
  112. package/dist/test/latest-fetch-wins.test.d.ts +0 -1
  113. package/dist/test/latest-fetch-wins.test.js +0 -91
  114. package/dist/test/latest-fetch-wins.test.js.map +0 -1
  115. package/dist/test/list-defaults.test.d.ts +0 -2
  116. package/dist/test/list-defaults.test.js +0 -145
  117. package/dist/test/list-defaults.test.js.map +0 -1
  118. package/dist/test/list-records.test.d.ts +0 -1
  119. package/dist/test/list-records.test.js +0 -46
  120. package/dist/test/list-records.test.js.map +0 -1
  121. package/dist/test/page-errors.d.ts +0 -1
  122. package/dist/test/page-errors.js +0 -44
  123. package/dist/test/page-errors.js.map +0 -1
  124. package/dist/test/paste-integrity.test.d.ts +0 -1
  125. package/dist/test/paste-integrity.test.js +0 -163
  126. package/dist/test/paste-integrity.test.js.map +0 -1
  127. package/dist/test/record-card-height.test.d.ts +0 -1
  128. package/dist/test/record-card-height.test.js +0 -15
  129. package/dist/test/record-card-height.test.js.map +0 -1
  130. package/dist/test/record-view-popup-editor.test.d.ts +0 -1
  131. package/dist/test/record-view-popup-editor.test.js +0 -71
  132. package/dist/test/record-view-popup-editor.test.js.map +0 -1
  133. package/dist/test/renderer-date-calendar-day.test.d.ts +0 -1
  134. package/dist/test/renderer-date-calendar-day.test.js +0 -48
  135. package/dist/test/renderer-date-calendar-day.test.js.map +0 -1
  136. package/dist/test/request-generation.test.d.ts +0 -1
  137. package/dist/test/request-generation.test.js +0 -153
  138. package/dist/test/request-generation.test.js.map +0 -1
  139. package/dist/test/resubmit.test.d.ts +0 -1
  140. package/dist/test/resubmit.test.js +0 -83
  141. package/dist/test/resubmit.test.js.map +0 -1
  142. package/dist/test/row-hover-visible.test.d.ts +0 -1
  143. package/dist/test/row-hover-visible.test.js +0 -139
  144. package/dist/test/row-hover-visible.test.js.map +0 -1
  145. package/dist/test/search-term.test.d.ts +0 -1
  146. package/dist/test/search-term.test.js +0 -108
  147. package/dist/test/search-term.test.js.map +0 -1
  148. package/dist/test/searchable-select.test.d.ts +0 -1
  149. package/dist/test/searchable-select.test.js +0 -65
  150. package/dist/test/searchable-select.test.js.map +0 -1
  151. package/dist/test/select-empty-value.test.d.ts +0 -1
  152. package/dist/test/select-empty-value.test.js +0 -61
  153. package/dist/test/select-empty-value.test.js.map +0 -1
  154. package/dist/test/shift-range-select.test.d.ts +0 -1
  155. package/dist/test/shift-range-select.test.js +0 -100
  156. package/dist/test/shift-range-select.test.js.map +0 -1
  157. package/dist/test/sparkline-renderer.test.d.ts +0 -1
  158. package/dist/test/sparkline-renderer.test.js +0 -36
  159. package/dist/test/sparkline-renderer.test.js.map +0 -1
  160. package/dist/test/wheel-one-scroller.test.d.ts +0 -2
  161. package/dist/test/wheel-one-scroller.test.js +0 -275
  162. package/dist/test/wheel-one-scroller.test.js.map +0 -1
@@ -1,91 +0,0 @@
1
- import { expect, fixture } from '@open-wc/testing';
2
- import { html } from 'lit';
3
- import '../src/data-grist.js';
4
- /**
5
- * The last fetch asked is the one the grid shows.
6
- *
7
- * A ledger opened from a dashboard card asked twice in a row - once with no conditions as it read its address,
8
- * then with the month the card named. The grid kept whichever answer arrived first - the read with no conditions -
9
- * and showed every line under a headroom that said October (2026-10-16).
10
- */
11
- const config = {
12
- columns: [
13
- { type: 'string', name: 'id', hidden: true },
14
- { type: 'string', name: 'name', header: 'name' }
15
- ],
16
- pagination: { pages: [20] }
17
- };
18
- const answer = (total) => ({
19
- total,
20
- records: Array.from({ length: Math.min(total, 20) }, (_, i) => ({ id: `${total}-${i}`, name: `row ${i}` }))
21
- });
22
- const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));
23
- describe('ox-grist with two fetches out at once', () => {
24
- /* Resizing inside a fixture trips Chrome's benign ResizeObserver loop error; it says nothing about fetching. */
25
- const ignoreResizeLoop = (e) => {
26
- if (String(e.message).includes('ResizeObserver loop')) {
27
- e.stopImmediatePropagation();
28
- e.preventDefault();
29
- }
30
- };
31
- let previousOnError = null;
32
- before(() => {
33
- window.addEventListener('error', ignoreResizeLoop, true);
34
- previousOnError = window.onerror;
35
- window.onerror = (message, ...rest) => String(message).includes('ResizeObserver loop') ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
36
- });
37
- after(() => {
38
- window.removeEventListener('error', ignoreResizeLoop, true);
39
- window.onerror = previousOnError;
40
- });
41
- /*
42
- * The answer depends on the conditions, as on the ledger: the read with none, asked first, comes back first; the
43
- * month's comes back after it. The grid fetches once by itself when attached; the test starts after that settled.
44
- */
45
- const MONTH = [{ name: 'month', operator: 'eq', value: 10 }];
46
- const byConditions = (failUnfiltered = false) => async ({ filters }) => {
47
- if (!(filters === null || filters === void 0 ? void 0 : filters.length)) {
48
- await wait(20);
49
- if (failUnfiltered)
50
- throw new Error('the unfiltered read failed');
51
- return answer(2908);
52
- }
53
- await wait(300);
54
- return answer(4);
55
- };
56
- async function attached(handler) {
57
- const el = (await fixture(html `<ox-grist style="height: 300px" .config=${config} .fetchHandler=${handler}></ox-grist>`));
58
- await wait(400);
59
- return el;
60
- }
61
- it('shows the answer to the later fetch, though the earlier one came back first', async () => {
62
- const el = await attached(byConditions());
63
- el.filters = [];
64
- const unfiltered = el.fetch();
65
- el.filters = MONTH;
66
- const month = el.fetch();
67
- await Promise.all([unfiltered, month]);
68
- await el.updateComplete;
69
- expect(el.data.total).to.equal(4);
70
- });
71
- it('does not report the failure of a fetch a later one replaced', async () => {
72
- const el = await attached(byConditions(true));
73
- el.filters = [];
74
- const unfiltered = el.fetch().then(() => 'kept quiet', () => 'reported');
75
- el.filters = MONTH;
76
- await el.fetch();
77
- expect(await unfiltered).to.equal('kept quiet');
78
- await el.updateComplete;
79
- expect(el.data.total).to.equal(4);
80
- /* The grid draws "could not load" from fetchFailed - a replaced read must not make it say so. */
81
- const body = el.renderRoot.querySelector('#grist');
82
- expect(!!(body === null || body === void 0 ? void 0 : body.renderRoot.querySelector('ox-empty-note'))).to.equal(false);
83
- });
84
- it('still shows a single fetch as before', async () => {
85
- const el = (await fixture(html `<ox-grist style="height: 300px" .config=${config} .fetchHandler=${async () => answer(7)}></ox-grist>`));
86
- await el.fetch();
87
- await el.updateComplete;
88
- expect(el.data.total).to.equal(7);
89
- });
90
- });
91
- //# sourceMappingURL=latest-fetch-wins.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"latest-fetch-wins.test.js","sourceRoot":"","sources":["../../test/latest-fetch-wins.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,sBAAsB,CAAA;AAE7B;;;;;;GAMG;AAEH,MAAM,MAAM,GAAG;IACb,OAAO,EAAE;QACP,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAC5C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;KACjD;IACD,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE;CAC5B,CAAA;AAED,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC;IACjC,KAAK;IACL,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,KAAK,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;CAC5G,CAAC,CAAA;AAEF,MAAM,IAAI,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CA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CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\n\n/**\n * The last fetch asked is the one the grid shows.\n *\n * A ledger opened from a dashboard card asked twice in a row - once with no conditions as it read its address,\n * then with the month the card named. The grid kept whichever answer arrived first - the read with no conditions -\n * and showed every line under a headroom that said October (2026-10-16).\n */\n\nconst config = {\n columns: [\n { type: 'string', name: 'id', hidden: true },\n { type: 'string', name: 'name', header: 'name' }\n ],\n pagination: { pages: [20] }\n}\n\nconst answer = (total: number) => ({\n total,\n records: Array.from({ length: Math.min(total, 20) }, (_, i) => ({ id: `${total}-${i}`, name: `row ${i}` }))\n})\n\nconst wait = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))\n\ntype Grist = HTMLElement & { fetch(): Promise<void>; data: { total: number }; updateComplete: Promise<unknown> }\n\ndescribe('ox-grist with two fetches out at once', () => {\n /* Resizing inside a fixture trips Chrome's benign ResizeObserver loop error; it says nothing about fetching. */\n const ignoreResizeLoop = (e: ErrorEvent) => {\n if (String(e.message).includes('ResizeObserver loop')) {\n e.stopImmediatePropagation()\n e.preventDefault()\n }\n }\n let previousOnError: OnErrorEventHandler = null\n before(() => {\n window.addEventListener('error', ignoreResizeLoop, true)\n previousOnError = window.onerror\n window.onerror = (message, ...rest) =>\n String(message).includes('ResizeObserver loop') ? true : previousOnError?.call(window, message, ...rest)\n })\n after(() => {\n window.removeEventListener('error', ignoreResizeLoop, true)\n window.onerror = previousOnError\n })\n\n /*\n * The answer depends on the conditions, as on the ledger: the read with none, asked first, comes back first; the\n * month's comes back after it. The grid fetches once by itself when attached; the test starts after that settled.\n */\n const MONTH = [{ name: 'month', operator: 'eq', value: 10 }]\n const byConditions = (failUnfiltered = false) => async ({ filters }: { filters?: unknown[] }) => {\n if (!filters?.length) {\n await wait(20)\n if (failUnfiltered) throw new Error('the unfiltered read failed')\n return answer(2908)\n }\n await wait(300)\n return answer(4)\n }\n\n async function attached(handler: any) {\n const el = (await fixture(html`<ox-grist style=\"height: 300px\" .config=${config} .fetchHandler=${handler}></ox-grist>`)) as Grist & {\n filters: unknown[]\n renderRoot: ShadowRoot\n }\n await wait(400)\n return el\n }\n\n it('shows the answer to the later fetch, though the earlier one came back first', async () => {\n const el = await attached(byConditions())\n\n el.filters = []\n const unfiltered = el.fetch()\n el.filters = MONTH\n const month = el.fetch()\n await Promise.all([unfiltered, month])\n await el.updateComplete\n\n expect(el.data.total).to.equal(4)\n })\n\n it('does not report the failure of a fetch a later one replaced', async () => {\n const el = await attached(byConditions(true))\n\n el.filters = []\n const unfiltered = el.fetch().then(\n () => 'kept quiet',\n () => 'reported'\n )\n el.filters = MONTH\n await el.fetch()\n\n expect(await unfiltered).to.equal('kept quiet')\n await el.updateComplete\n expect(el.data.total).to.equal(4)\n /* The grid draws \"could not load\" from fetchFailed - a replaced read must not make it say so. */\n const body = el.renderRoot.querySelector('#grist') as (HTMLElement & { renderRoot: ShadowRoot }) | null\n expect(!!body?.renderRoot.querySelector('ox-empty-note')).to.equal(false)\n })\n\n it('still shows a single fetch as before', async () => {\n const el = (await fixture(html`<ox-grist style=\"height: 300px\" .config=${config} .fetchHandler=${async () => answer(7)}></ox-grist>`)) as Grist\n await el.fetch()\n await el.updateComplete\n\n expect(el.data.total).to.equal(7)\n })\n})\n"]}
@@ -1,2 +0,0 @@
1
- import '../src/data-grist.js';
2
- import '../src/filters/filters-form.js';
@@ -1,145 +0,0 @@
1
- import { expect, fixture } from '@open-wc/testing';
2
- import { html } from 'lit';
3
- import { addressController, writeAddress } from '@operato/utils/address.js';
4
- import '../src/data-grist.js';
5
- import '../src/filters/filters-form.js';
6
- /*
7
- * An address without `filters` means the list's configured defaults, applied and written into the address; an
8
- * address with `filters=[]` means no conditions. A list operator's value is always an array, also when a default,
9
- * a link or a form gives one choice as a scalar. (address-centralization-problem-2026-10-19 §7 D7)
10
- */
11
- async function until(check, what) {
12
- for (let i = 0; i < 200; i++) {
13
- if (check())
14
- return;
15
- await new Promise(resolve => setTimeout(resolve, 5));
16
- }
17
- throw new Error(`did not settle: ${what}`);
18
- }
19
- const filtersInAddress = () => new URLSearchParams(location.search).get('filters');
20
- describe('list defaults and the shape of list operators', () => {
21
- let previousOnError;
22
- const resizeNotice = (event) => {
23
- if (event.message.includes('ResizeObserver loop')) {
24
- event.preventDefault();
25
- event.stopImmediatePropagation();
26
- }
27
- };
28
- before(() => {
29
- window.addEventListener('error', resizeNotice, true);
30
- previousOnError = window.onerror;
31
- window.onerror = (message, ...rest) => String(message).includes('ResizeObserver loop') ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
32
- });
33
- after(() => {
34
- window.removeEventListener('error', resizeNotice, true);
35
- window.onerror = previousOnError;
36
- });
37
- let reads = [];
38
- const typeColumn = { name: 'type', header: 'type', filter: { operator: 'in', value: 'main' } };
39
- const mount = async (columns = [typeColumn]) => {
40
- addressController().registerQuery();
41
- reads = [];
42
- const grist = await fixture(html `<ox-grist
43
- style="display:block;width:800px;height:400px"
44
- .urlParamsSensitive=${true}
45
- .config=${{
46
- columns,
47
- pagination: { limit: 20 }
48
- }}
49
- .fetchHandler=${async ({ filters }) => {
50
- reads.push(filters);
51
- return { records: [], total: 0 };
52
- }}
53
- ></ox-grist>`);
54
- return grist;
55
- };
56
- it('an address without filters reads with the defaults and then says so', async () => {
57
- await writeAddress('?defaults=start');
58
- await mount();
59
- await until(() => reads.length > 0, 'first read');
60
- expect(reads[reads.length - 1]).to.deep.equal([{ name: 'type', operator: 'in', value: ['main'] }]);
61
- await until(() => filtersInAddress() !== null, 'defaults written');
62
- expect(filtersInAddress()).to.equal("[{name:'type',operator:'in',value:['main']}]");
63
- expect(reads.every(read => read.length === 1)).to.equal(true);
64
- });
65
- it('a default whose list holds no choice is no condition: it is neither read nor written', async () => {
66
- // A board list's state default was `in []`; it reached the server as `state IN ()`, which postgres refuses.
67
- await writeAddress('?defaults=empty-list');
68
- await mount([typeColumn, { name: 'state', header: 'state', filter: { operator: 'in', value: [] } }]);
69
- await until(() => reads.length > 0, 'first read');
70
- expect(reads[reads.length - 1]).to.deep.equal([{ name: 'type', operator: 'in', value: ['main'] }]);
71
- await until(() => filtersInAddress() !== null, 'defaults written');
72
- expect(filtersInAddress()).to.equal("[{name:'type',operator:'in',value:['main']}]");
73
- });
74
- it('an address holding a list operator with no choice reads without it', async () => {
75
- await writeAddress("?filters=[{name:'type',operator:'in',value:['main']},{name:'state',operator:'in',value:[]}]");
76
- await mount([typeColumn, { name: 'state', header: 'state', filter: { operator: 'in', value: [] } }]);
77
- await until(() => reads.length > 0, 'first read');
78
- expect(reads.every(read => read.every((filter) => filter.name !== 'state'))).to.equal(true);
79
- expect(reads[reads.length - 1]).to.deep.equal([{ name: 'type', operator: 'in', value: ['main'] }]);
80
- });
81
- it('a default of false or 0 is a condition', async () => {
82
- await writeAddress('?defaults=falsy-values');
83
- await mount([
84
- { name: 'active', header: 'active', type: 'boolean', filter: { operator: 'eq', value: false } },
85
- { name: 'count', header: 'count', type: 'integer', filter: { operator: 'eq', value: 0 } }
86
- ]);
87
- await until(() => reads.length > 0, 'first read');
88
- expect(reads[reads.length - 1]).to.deep.equal([
89
- { name: 'active', operator: 'eq', value: false },
90
- { name: 'count', operator: 'eq', value: 0 }
91
- ]);
92
- });
93
- it('an address with filters=[] reads with no conditions and keeps it', async () => {
94
- await writeAddress('?filters=[]');
95
- await mount();
96
- await until(() => reads.length > 0, 'first read');
97
- expect(reads[reads.length - 1]).to.deep.equal([]);
98
- expect(filtersInAddress()).to.equal('[]');
99
- });
100
- it('clearing every condition of a list with defaults writes filters=[]', async () => {
101
- await writeAddress("?filters=[{name:'type',operator:'in',value:['sub']}]");
102
- const grist = await mount();
103
- await until(() => reads.length > 0, 'first read');
104
- grist.dispatchEvent(new CustomEvent('fetch-params-change', { bubbles: true, composed: true, detail: { filters: [], from: 'filters-form' } }));
105
- await until(() => filtersInAddress() === '[]', 'empty written');
106
- await until(() => { var _a; return ((_a = reads[reads.length - 1]) === null || _a === void 0 ? void 0 : _a.length) === 0; }, 'read with none');
107
- });
108
- /*
109
- * The form draws the conditions the list is read with. A select whose default was chosen away (filters=[]) shows no
110
- * choice - it once drew its default again, so 「진행」 sat above a list of every item.
111
- */
112
- it('a filter chosen away shows no choice in the form, its default neither', async () => {
113
- var _a, _b, _c;
114
- const stateColumn = { name: 'state', header: 'state', type: 'select', filter: { operator: 'eq', value: 'GOING', options: ['GOING', 'ENDED'] } };
115
- const shown = async (address) => {
116
- await writeAddress(address);
117
- addressController().registerQuery();
118
- reads = [];
119
- const grist = await fixture(html `<ox-grist
120
- style="display:block;width:800px;height:400px"
121
- .urlParamsSensitive=${true}
122
- .config=${{ columns: [stateColumn], pagination: { limit: 20 } }}
123
- .fetchHandler=${async ({ filters }) => {
124
- reads.push(filters);
125
- return { records: [], total: 0 };
126
- }}
127
- ><div slot="headroom"><ox-filters-form without-search></ox-filters-form></div
128
- ></ox-grist>`);
129
- await until(() => reads.length > 0, 'first read');
130
- const form = grist.querySelector('ox-filters-form');
131
- await form.updateComplete;
132
- return form.renderRoot.querySelector('ox-select[name="state"]');
133
- };
134
- expect((_a = (await shown('?defaults=select'))) === null || _a === void 0 ? void 0 : _a.value).to.equal('GOING');
135
- expect((_c = (_b = (await shown('?filters=[]'))) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : '').to.equal('');
136
- expect(reads[reads.length - 1]).to.deep.equal([]);
137
- });
138
- it('a single choice given as a scalar is read as a one-element array', async () => {
139
- await writeAddress("?filters=[{name:'type',operator:'in',value:'sub'}]");
140
- await mount();
141
- await until(() => reads.length > 0, 'first read');
142
- expect(reads[reads.length - 1]).to.deep.equal([{ name: 'type', operator: 'in', value: ['sub'] }]);
143
- });
144
- });
145
- //# sourceMappingURL=list-defaults.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list-defaults.test.js","sourceRoot":"","sources":["../../test/list-defaults.test.ts"],"names":[],"mappings":"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AAA;QACxE,MAAM,KAAK,EAAE,CAAA;QACb,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,YAAY,CAAC,CAAA;QACjD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;IACnG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\nimport { addressController, writeAddress } from '@operato/utils/address.js'\nimport type { DataGrist } from '../src/data-grist.js'\nimport '../src/data-grist.js'\nimport '../src/filters/filters-form.js'\n\n/*\n * An address without `filters` means the list's configured defaults, applied and written into the address; an\n * address with `filters=[]` means no conditions. A list operator's value is always an array, also when a default,\n * a link or a form gives one choice as a scalar. (address-centralization-problem-2026-10-19 §7 D7)\n */\n\nasync function until(check: () => boolean, what: string) {\n for (let i = 0; i < 200; i++) {\n if (check()) return\n await new Promise(resolve => setTimeout(resolve, 5))\n }\n throw new Error(`did not settle: ${what}`)\n}\n\nconst filtersInAddress = () => new URLSearchParams(location.search).get('filters')\n\ndescribe('list defaults and the shape of list operators', () => {\n let previousOnError: typeof window.onerror\n const resizeNotice = (event: ErrorEvent) => {\n if (event.message.includes('ResizeObserver loop')) {\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n }\n before(() => {\n window.addEventListener('error', resizeNotice, true)\n previousOnError = window.onerror\n window.onerror = (message, ...rest) =>\n String(message).includes('ResizeObserver loop') ? true : previousOnError?.call(window, message, ...rest)\n })\n after(() => {\n window.removeEventListener('error', resizeNotice, true)\n window.onerror = previousOnError\n })\n\n let reads: any[][] = []\n const typeColumn = { name: 'type', header: 'type', filter: { operator: 'in', value: 'main' } }\n const mount = async (columns: any[] = [typeColumn]) => {\n addressController().registerQuery()\n reads = []\n const grist = await fixture<DataGrist>(\n html`<ox-grist\n style=\"display:block;width:800px;height:400px\"\n .urlParamsSensitive=${true}\n .config=${{\n columns,\n pagination: { limit: 20 }\n }}\n .fetchHandler=${async ({ filters }: any) => {\n reads.push(filters)\n return { records: [], total: 0 }\n }}\n ></ox-grist>`\n )\n return grist\n }\n\n it('an address without filters reads with the defaults and then says so', async () => {\n await writeAddress('?defaults=start')\n await mount()\n await until(() => reads.length > 0, 'first read')\n expect(reads[reads.length - 1]).to.deep.equal([{ name: 'type', operator: 'in', value: ['main'] }])\n await until(() => filtersInAddress() !== null, 'defaults written')\n expect(filtersInAddress()).to.equal(\"[{name:'type',operator:'in',value:['main']}]\")\n expect(reads.every(read => read.length === 1)).to.equal(true)\n })\n\n it('a default whose list holds no choice is no condition: it is neither read nor written', async () => {\n // A board list's state default was `in []`; it reached the server as `state IN ()`, which postgres refuses.\n await writeAddress('?defaults=empty-list')\n await mount([typeColumn, { name: 'state', header: 'state', filter: { operator: 'in', value: [] } }])\n await until(() => reads.length > 0, 'first read')\n expect(reads[reads.length - 1]).to.deep.equal([{ name: 'type', operator: 'in', value: ['main'] }])\n await until(() => filtersInAddress() !== null, 'defaults written')\n expect(filtersInAddress()).to.equal(\"[{name:'type',operator:'in',value:['main']}]\")\n })\n\n it('an address holding a list operator with no choice reads without it', async () => {\n await writeAddress(\"?filters=[{name:'type',operator:'in',value:['main']},{name:'state',operator:'in',value:[]}]\")\n await mount([typeColumn, { name: 'state', header: 'state', filter: { operator: 'in', value: [] } }])\n await until(() => reads.length > 0, 'first read')\n expect(reads.every(read => read.every((filter: any) => filter.name !== 'state'))).to.equal(true)\n expect(reads[reads.length - 1]).to.deep.equal([{ name: 'type', operator: 'in', value: ['main'] }])\n })\n\n it('a default of false or 0 is a condition', async () => {\n await writeAddress('?defaults=falsy-values')\n await mount([\n { name: 'active', header: 'active', type: 'boolean', filter: { operator: 'eq', value: false } },\n { name: 'count', header: 'count', type: 'integer', filter: { operator: 'eq', value: 0 } }\n ])\n await until(() => reads.length > 0, 'first read')\n expect(reads[reads.length - 1]).to.deep.equal([\n { name: 'active', operator: 'eq', value: false },\n { name: 'count', operator: 'eq', value: 0 }\n ])\n })\n\n it('an address with filters=[] reads with no conditions and keeps it', async () => {\n await writeAddress('?filters=[]')\n await mount()\n await until(() => reads.length > 0, 'first read')\n expect(reads[reads.length - 1]).to.deep.equal([])\n expect(filtersInAddress()).to.equal('[]')\n })\n\n it('clearing every condition of a list with defaults writes filters=[]', async () => {\n await writeAddress(\"?filters=[{name:'type',operator:'in',value:['sub']}]\")\n const grist = await mount()\n await until(() => reads.length > 0, 'first read')\n grist.dispatchEvent(\n new CustomEvent('fetch-params-change', { bubbles: true, composed: true, detail: { filters: [], from: 'filters-form' } })\n )\n await until(() => filtersInAddress() === '[]', 'empty written')\n await until(() => reads[reads.length - 1]?.length === 0, 'read with none')\n })\n\n /*\n * The form draws the conditions the list is read with. A select whose default was chosen away (filters=[]) shows no\n * choice - it once drew its default again, so 「진행」 sat above a list of every item.\n */\n it('a filter chosen away shows no choice in the form, its default neither', async () => {\n const stateColumn = { name: 'state', header: 'state', type: 'select', filter: { operator: 'eq', value: 'GOING', options: ['GOING', 'ENDED'] } }\n const shown = async (address: string) => {\n await writeAddress(address)\n addressController().registerQuery()\n reads = []\n const grist = await fixture<DataGrist>(\n html`<ox-grist\n style=\"display:block;width:800px;height:400px\"\n .urlParamsSensitive=${true}\n .config=${{ columns: [stateColumn], pagination: { limit: 20 } }}\n .fetchHandler=${async ({ filters }: any) => {\n reads.push(filters)\n return { records: [], total: 0 }\n }}\n ><div slot=\"headroom\"><ox-filters-form without-search></ox-filters-form></div\n ></ox-grist>`\n )\n await until(() => reads.length > 0, 'first read')\n const form = grist.querySelector('ox-filters-form') as any\n await form.updateComplete\n return (form.renderRoot as ShadowRoot).querySelector('ox-select[name=\"state\"]') as any\n }\n expect((await shown('?defaults=select'))?.value).to.equal('GOING')\n expect((await shown('?filters=[]'))?.value ?? '').to.equal('')\n expect(reads[reads.length - 1]).to.deep.equal([])\n })\n\n it('a single choice given as a scalar is read as a one-element array', async () => {\n await writeAddress(\"?filters=[{name:'type',operator:'in',value:'sub'}]\")\n await mount()\n await until(() => reads.length > 0, 'first read')\n expect(reads[reads.length - 1]).to.deep.equal([{ name: 'type', operator: 'in', value: ['sub'] }])\n })\n})\n"]}
@@ -1 +0,0 @@
1
- import '../src/data-grist.js';
@@ -1,46 +0,0 @@
1
- /* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */
2
- import { expect, fixture } from '@open-wc/testing';
3
- import { html } from 'lit';
4
- import '../src/data-grist.js';
5
- import { failOnPageErrors } from './page-errors.js';
6
- /*
7
- * A list or card shows the records of its data, whenever its config arrives. The grist hands the data over at once
8
- * and the compiled config a render later - and a personal config loads later still - so a list that emptied itself
9
- * on a config change showed nothing until the next fetch (2026-10-26).
10
- */
11
- const records = [
12
- { id: '1', title: 'one' },
13
- { id: '2', title: 'two' }
14
- ];
15
- const config = (header) => ({
16
- columns: [{ type: 'string', name: 'title', header, record: { editable: true } }],
17
- rows: { appendable: false },
18
- list: { fields: ['title'] }
19
- });
20
- /* `updateComplete` resolves false while an update set another one going. */
21
- const idle = async (el) => {
22
- while (!((await el.updateComplete) && (await el.grist.updateComplete)))
23
- ;
24
- };
25
- for (const [mode, tag] of [
26
- ['LIST', 'ox-record-partial'],
27
- ['CARD', 'ox-record-card']
28
- ]) {
29
- describe(`a ${mode} and its config`, () => {
30
- failOnPageErrors();
31
- const shown = (el) => Array.from(el.grist.renderRoot.querySelectorAll(tag)).map(item => item.record.title);
32
- it('shows the records it was given with its config', async () => {
33
- const el = await fixture(html `<ox-grist style="height:300px" .mode=${mode} .config=${config('title')} .data=${{ records }}></ox-grist>`);
34
- await idle(el);
35
- expect(shown(el)).to.eql(['one', 'two']);
36
- });
37
- it('keeps its records when the config changes after them', async () => {
38
- const el = await fixture(html `<ox-grist style="height:300px" .mode=${mode} .config=${config('title')} .data=${{ records }}></ox-grist>`);
39
- await idle(el);
40
- el.config = config('renamed');
41
- await idle(el);
42
- expect(shown(el)).to.eql(['one', 'two']);
43
- });
44
- });
45
- }
46
- //# sourceMappingURL=list-records.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list-records.test.js","sourceRoot":"","sources":["../../test/list-records.test.ts"],"names":[],"mappings":"AAAA,kIAAkI;AAClI,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;GAIG;AAEH,MAAM,OAAO,GAAG;IACd,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;IACzB,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;CAC1B,CAAA;AACD,MAAM,MAAM,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC;IAClC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;IAChF,IAAI,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;IAC3B,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE;CAC5B,CAAC,CAAA;AAEF,4EAA4E;AAC5E,MAAM,IAAI,GAAG,KAAK,EAAE,EAAa,EAAE,EAAE;IACnC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAAC,CAAC;AAC1E,CAAC,CAAA;AAED,KAAK,MAAM,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AG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;QAC1C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */\nimport { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\nimport { DataGrist } from '../src/data-grist.js'\nimport { failOnPageErrors } from './page-errors.js'\n\n/*\n * A list or card shows the records of its data, whenever its config arrives. The grist hands the data over at once\n * and the compiled config a render later - and a personal config loads later still - so a list that emptied itself\n * on a config change showed nothing until the next fetch (2026-10-26).\n */\n\nconst records = [\n { id: '1', title: 'one' },\n { id: '2', title: 'two' }\n]\nconst config = (header: string) => ({\n columns: [{ type: 'string', name: 'title', header, record: { editable: true } }],\n rows: { appendable: false },\n list: { fields: ['title'] }\n})\n\n/* `updateComplete` resolves false while an update set another one going. */\nconst idle = async (el: DataGrist) => {\n while (!((await el.updateComplete) && (await el.grist.updateComplete)));\n}\n\nfor (const [mode, tag] of [\n ['LIST', 'ox-record-partial'],\n ['CARD', 'ox-record-card']\n] as const) {\n describe(`a ${mode} and its config`, () => {\n failOnPageErrors()\n\n const shown = (el: DataGrist) =>\n Array.from(el.grist.renderRoot.querySelectorAll(tag) as NodeListOf<any>).map(item => item.record.title)\n\n it('shows the records it was given with its config', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"height:300px\" .mode=${mode} .config=${config('title')} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n expect(shown(el)).to.eql(['one', 'two'])\n })\n\n it('keeps its records when the config changes after them', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"height:300px\" .mode=${mode} .config=${config('title')} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n el.config = config('renamed')\n await idle(el)\n expect(shown(el)).to.eql(['one', 'two'])\n })\n })\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function failOnPageErrors(): void;
@@ -1,44 +0,0 @@
1
- /*
2
- * Fail a test when the page throws while it runs - a render exception or a rejected promise nobody awaited. The
3
- * runner only logs those as 「thrown outside a test」 and the test still passes. The browser's ResizeObserver loop
4
- * notice is not an error of the page.
5
- */
6
- export function failOnPageErrors() {
7
- const errors = [];
8
- const benign = (message) => message.includes('ResizeObserver loop');
9
- const onError = (e) => {
10
- var _a;
11
- if (benign(String(e.message))) {
12
- e.stopImmediatePropagation();
13
- e.preventDefault();
14
- return;
15
- }
16
- errors.push(String(((_a = e.error) === null || _a === void 0 ? void 0 : _a.stack) || e.message));
17
- };
18
- const onRejection = (e) => {
19
- var _a;
20
- errors.push(String(((_a = e.reason) === null || _a === void 0 ? void 0 : _a.stack) || e.reason));
21
- };
22
- let previousOnError = null;
23
- before(() => {
24
- window.addEventListener('error', onError, true);
25
- window.addEventListener('unhandledrejection', onRejection);
26
- previousOnError = window.onerror;
27
- window.onerror = (message, ...rest) => benign(String(message)) ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
28
- });
29
- after(() => {
30
- window.removeEventListener('error', onError, true);
31
- window.removeEventListener('unhandledrejection', onRejection);
32
- window.onerror = previousOnError;
33
- });
34
- beforeEach(() => {
35
- errors.length = 0;
36
- });
37
- afterEach(async () => {
38
- /* Let renders the test started finish, so their errors land in this test. */
39
- await new Promise(resolve => setTimeout(resolve, 50));
40
- if (errors.length)
41
- throw new Error(`the page threw while the test ran:\n${errors.join('\n')}`);
42
- });
43
- }
44
- //# sourceMappingURL=page-errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"page-errors.js","sourceRoot":"","sources":["../../test/page-errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,MAAM,MAAM,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAA;IAE3E,MA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AoB,EAAE,WAAW,CAAC,CAAA;QAC7D,MAAM,CAAC,OAAO,GAAG,eAAe,CAAA;IAClC,CAAC,CAAC,CAAA;IACF,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;IACF,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,6EAA6E;QAC7E,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;QACrD,IAAI,MAAM,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAChG,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/*\n * Fail a test when the page throws while it runs - a render exception or a rejected promise nobody awaited. The\n * runner only logs those as 「thrown outside a test」 and the test still passes. The browser's ResizeObserver loop\n * notice is not an error of the page.\n */\nexport function failOnPageErrors() {\n const errors: string[] = []\n const benign = (message: string) => message.includes('ResizeObserver loop')\n\n const onError = (e: ErrorEvent) => {\n if (benign(String(e.message))) {\n e.stopImmediatePropagation()\n e.preventDefault()\n return\n }\n errors.push(String(e.error?.stack || e.message))\n }\n const onRejection = (e: PromiseRejectionEvent) => {\n errors.push(String(e.reason?.stack || e.reason))\n }\n let previousOnError: OnErrorEventHandler = null\n\n before(() => {\n window.addEventListener('error', onError, true)\n window.addEventListener('unhandledrejection', onRejection)\n previousOnError = window.onerror\n window.onerror = (message, ...rest) =>\n benign(String(message)) ? true : previousOnError?.call(window, message, ...rest)\n })\n after(() => {\n window.removeEventListener('error', onError, true)\n window.removeEventListener('unhandledrejection', onRejection)\n window.onerror = previousOnError\n })\n beforeEach(() => {\n errors.length = 0\n })\n afterEach(async () => {\n /* Let renders the test started finish, so their errors land in this test. */\n await new Promise(resolve => setTimeout(resolve, 50))\n if (errors.length) throw new Error(`the page threw while the test ran:\\n${errors.join('\\n')}`)\n })\n}\n"]}
@@ -1 +0,0 @@
1
- import '../src/data-grist.js';
@@ -1,163 +0,0 @@
1
- import { expect, fixture } from '@open-wc/testing';
2
- import { html } from 'lit';
3
- import '../src/data-grist.js';
4
- import { DataGridBody } from '../src/data-grid/data-grid-body.js';
5
- import { OxGristEditorNumber } from '../src/editors/ox-grist-editor-number.js';
6
- import { failOnPageErrors } from './page-errors.js';
7
- /* The clipboard holds `text` as `mime` while `run` reads it. */
8
- async function withClipboard(mime, text, run) {
9
- const previous = Object.getOwnPropertyDescriptor(navigator, 'clipboard');
10
- Object.defineProperty(navigator, 'clipboard', { configurable: true, value: {
11
- read: async () => [{ getType: async (requested) => {
12
- if (requested !== mime)
13
- throw Error('no type');
14
- return new Blob([text], { type: mime });
15
- } }]
16
- } });
17
- try {
18
- return await run();
19
- }
20
- finally {
21
- if (previous)
22
- Object.defineProperty(navigator, 'clipboard', previous);
23
- else
24
- delete navigator.clipboard;
25
- }
26
- }
27
- /* What a paste sends, read off a body that only records its field changes. */
28
- async function paste(mime, text, type = 'number', options = {}) {
29
- var _a, _b, _d;
30
- const changes = [];
31
- const body = {
32
- focused: { row: (_a = options.row) !== null && _a !== void 0 ? _a : 0, column: 0 }, data: { records: options.records || [{ id: 'a', value: 1 }] },
33
- columns: [{ name: 'value', type, record: { editable: (_b = options.editable) !== null && _b !== void 0 ? _b : true } }],
34
- config: { rows: { appendable: (_d = options.appendable) !== null && _d !== void 0 ? _d : false } }, appendRecord: { __dirty__: '+' },
35
- pasteTargets: DataGridBody.prototype.pasteTargets,
36
- resetEdit() { }, focus() { }, dispatchEvent(e) { changes.push(e.detail); }
37
- };
38
- await withClipboard(mime, text, () => DataGridBody.prototype.paste.call(body));
39
- return { body, changes };
40
- }
41
- const source = (mime, values) => mime === 'text/html'
42
- ? `<table>${values.map(value => `<tr><td>${value}</td></tr>`).join('')}</table>`
43
- : values.join('\n');
44
- describe('paste and input data contracts', () => {
45
- for (const mime of ['text/html', 'text/plain']) {
46
- for (const [type, input, expected] of [
47
- ['number', 'abc', 'abc'], ['number', '1,200', '1,200'],
48
- ['number', ' ', null], ['number', 'Infinity', 'Infinity'],
49
- ['number', '12.5', 12.5], ['integer', '12.5', 12], ['integer', '-1.5', -2],
50
- ['boolean', 'false', false], ['checkbox', 'true', true], ['number', '0', 0]
51
- ]) {
52
- it(`${mime} parses ${type} ${input}`, async () => {
53
- const { changes } = await paste(mime, source(mime, [input]), type);
54
- expect(changes[0].after).to.equal(expected);
55
- });
56
- }
57
- /* A blank cell clears an existing row's field and leaves a new row's to its default; id 0 is an existing row. */
58
- for (const [type, input, records, row, expected] of [
59
- ['number', ' ', [{ id: 0, value: 1 }], 0, null],
60
- ['string', ' ', [{ id: 'a', value: 'x' }], 1, undefined],
61
- ['number', ' ', [{ id: 'a', value: 1 }], 1, undefined],
62
- ['select', ' ', [{ id: 'a', value: 1 }], 1, undefined]
63
- ]) {
64
- it(`${mime} pastes a blank ${type} into ${row ? 'a new' : 'an existing'} row as ${expected}`, async () => {
65
- const { changes } = await paste(mime, source(mime, [input]), type, { records, row, appendable: true });
66
- expect(changes).to.have.length(1);
67
- expect(changes[0].after).to.equal(expected);
68
- });
69
- }
70
- it(`${mime} passes the destination row to editable`, async () => {
71
- const seen = [];
72
- await paste(mime, source(mime, ['1', '2']), 'number', {
73
- records: [{ id: 'a' }, { id: 'b' }],
74
- editable: (_v, _c, _r, row) => { seen.push(row); return true; }
75
- });
76
- expect(seen).to.eql([0, 1]);
77
- });
78
- }
79
- it('integer IME input uses the same conversion as the number editor', () => {
80
- let after;
81
- const column = { name: 'value', type: 'integer', record: { editable: true } };
82
- const body = { _imeBuffer: { value: '12.5' }, _resetIMEBuffer() { }, columns: [column],
83
- data: { records: [{ value: 1 }] }, dispatchEvent(e) { after = e.detail.after; } };
84
- DataGridBody.prototype._commitIMEBuffer.call(body, 0, 0);
85
- const expected = OxGristEditorNumber.prototype.formatFromEditor.call({ column }, '12.5');
86
- expect(after).to.equal(expected);
87
- });
88
- });
89
- /* Pasting into a rendered grid: the rows that end up in the grid, through its own field-change handling. */
90
- describe('paste into a grid', () => {
91
- failOnPageErrors();
92
- const mount = async (options) => {
93
- var _a, _b;
94
- const el = await fixture(html `<ox-grist
95
- style="height:300px"
96
- .config=${{
97
- columns: [
98
- { name: 'amount', type: 'number', header: 'amount', record: { editable: (_a = options.editable) !== null && _a !== void 0 ? _a : true }, validation: options.validation },
99
- { name: 'memo', type: 'string', header: 'memo', record: { editable: (_b = options.editable) !== null && _b !== void 0 ? _b : true } }
100
- ],
101
- rows: { appendable: options.appendable }
102
- }}
103
- .data=${{ records: [{ id: 'a', amount: 1, memo: 'kept' }] }}
104
- ></ox-grist>`);
105
- await el.updateComplete;
106
- await el.grist.updateComplete;
107
- return el;
108
- };
109
- const bodyOf = (el) => el.grist.renderRoot.querySelector('ox-grid-body');
110
- const pasteAt = async (el, row, mime, text, column = 0) => {
111
- const body = bodyOf(el);
112
- body.focused = { row, column };
113
- await withClipboard(mime, text, () => body.paste());
114
- await el.updateComplete;
115
- };
116
- const table = (mime, rows) => mime === 'text/html'
117
- ? `<table>${rows.map(cells => `<tr>${cells.map(cell => `<td>${cell}</td>`).join('')}</tr>`).join('')}</table>`
118
- : rows.map(cells => cells.join('\t')).join('\n');
119
- const rows = (el) => el.grist.data.records.map(({ amount, memo }) => ({ amount, memo }));
120
- for (const mime of ['text/html', 'text/plain']) {
121
- it(`${mime} stops at the last row when rows cannot be appended`, async () => {
122
- const el = await mount({ appendable: false });
123
- await pasteAt(el, 0, mime, table(mime, [['2', 'x'], ['3', 'y']]));
124
- expect(rows(el)).to.eql([{ amount: 2, memo: 'x' }]);
125
- });
126
- it(`${mime} appends new rows in order`, async () => {
127
- const el = await mount({ appendable: true });
128
- await pasteAt(el, 1, mime, table(mime, [['2', 'x'], ['3', 'y']]));
129
- expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 2, memo: 'x' }, { amount: 3, memo: 'y' }]);
130
- });
131
- it(`${mime} adds no row for read-only cells`, async () => {
132
- const el = await mount({ appendable: true, editable: false });
133
- await pasteAt(el, 1, mime, table(mime, [['2', 'x']]));
134
- expect(el.grist.data.records).to.have.length(1);
135
- });
136
- it(`${mime} adds no row for a blank new row`, async () => {
137
- const el = await mount({ appendable: true });
138
- await pasteAt(el, 1, mime, table(mime, [[' ', ' '], ['4', 'z']]));
139
- expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 4, memo: 'z' }]);
140
- expect(el.dirtyRecords).to.have.length(1);
141
- });
142
- it(`${mime} keeps a new row's cells together while one is being validated`, async () => {
143
- let resolve;
144
- const el = await mount({ appendable: true, validation: () => new Promise(done => (resolve = done)) });
145
- await pasteAt(el, 1, mime, table(mime, [['5', 'w']]));
146
- resolve(true);
147
- await new Promise(done => setTimeout(done));
148
- expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 5, memo: 'w' }]);
149
- });
150
- it(`${mime} into the append row and a key typed into it while the paste is validated make one row`, async () => {
151
- let resolve;
152
- const el = await mount({ appendable: true, validation: () => new Promise(done => (resolve = done)) });
153
- await pasteAt(el, 1, mime, table(mime, [['5']]));
154
- const body = bodyOf(el);
155
- body._imeBuffer.value = 'typed';
156
- body._commitIMEBuffer(1, 1);
157
- resolve(true);
158
- await new Promise(done => setTimeout(done));
159
- expect(rows(el)).to.eql([{ amount: 1, memo: 'kept' }, { amount: 5, memo: 'typed' }]);
160
- });
161
- }
162
- });
163
- //# sourceMappingURL=paste-integrity.test.js.map