@operato/data-grist 10.29.38 → 10.29.40

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 (58) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/coverage/lcov-report/index.html +166 -166
  3. package/coverage/lcov-report/webpack/bootstrap.html +1 -1
  4. package/coverage/lcov-report/webpack/index.html +1 -1
  5. package/coverage/lcov-report/webpack/runtime/define property getters.html +1 -1
  6. package/coverage/lcov-report/webpack/runtime/global.html +1 -1
  7. package/coverage/lcov-report/webpack/runtime/hasOwnProperty shorthand.html +1 -1
  8. package/coverage/lcov-report/webpack/runtime/index.html +1 -1
  9. package/coverage/lcov-report/webpack/runtime/make namespace object.html +1 -1
  10. package/coverage/lcov.info +58474 -56991
  11. package/dist/src/data-consumer.d.ts +7 -1
  12. package/dist/src/data-consumer.js.map +1 -1
  13. package/dist/src/data-grist.d.ts +19 -3
  14. package/dist/src/data-grist.js +163 -39
  15. package/dist/src/data-grist.js.map +1 -1
  16. package/dist/src/data-provider.d.ts +8 -1
  17. package/dist/src/data-provider.js +94 -46
  18. package/dist/src/data-provider.js.map +1 -1
  19. package/dist/src/editors/ox-grist-editor.d.ts +2 -0
  20. package/dist/src/editors/ox-grist-editor.js +17 -4
  21. package/dist/src/editors/ox-grist-editor.js.map +1 -1
  22. package/dist/src/filters/filter-checkbox.js +3 -2
  23. package/dist/src/filters/filter-checkbox.js.map +1 -1
  24. package/dist/src/filters/filter-input-barcode.js +2 -1
  25. package/dist/src/filters/filter-input-barcode.js.map +1 -1
  26. package/dist/src/filters/filter-input.js +2 -1
  27. package/dist/src/filters/filter-input.js.map +1 -1
  28. package/dist/src/filters/filter-ownership.d.ts +15 -0
  29. package/dist/src/filters/filter-ownership.js +48 -0
  30. package/dist/src/filters/filter-ownership.js.map +1 -0
  31. package/dist/src/filters/filter-range-date.js +3 -2
  32. package/dist/src/filters/filter-range-date.js.map +1 -1
  33. package/dist/src/filters/filter-range-number.js +3 -2
  34. package/dist/src/filters/filter-range-number.js.map +1 -1
  35. package/dist/src/filters/filter-select-buttons.js +2 -1
  36. package/dist/src/filters/filter-select-buttons.js.map +1 -1
  37. package/dist/src/filters/filters-form.js +80 -22
  38. package/dist/src/filters/filters-form.js.map +1 -1
  39. package/dist/src/utils/list-param.d.ts +5 -3
  40. package/dist/src/utils/list-param.js +6 -37
  41. package/dist/src/utils/list-param.js.map +1 -1
  42. package/dist/test/address-intents.test.d.ts +1 -0
  43. package/dist/test/address-intents.test.js +202 -0
  44. package/dist/test/address-intents.test.js.map +1 -0
  45. package/dist/test/filter-ownership.test.d.ts +1 -0
  46. package/dist/test/filter-ownership.test.js +40 -0
  47. package/dist/test/filter-ownership.test.js.map +1 -0
  48. package/dist/test/record-view-popup-editor.test.js +13 -0
  49. package/dist/test/record-view-popup-editor.test.js.map +1 -1
  50. package/dist/test/request-generation.test.d.ts +1 -0
  51. package/dist/test/request-generation.test.js +120 -0
  52. package/dist/test/request-generation.test.js.map +1 -0
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +11 -7
  55. package/test/address-intents.test.ts +203 -0
  56. package/test/filter-ownership.test.ts +51 -0
  57. package/test/record-view-popup-editor.test.ts +16 -0
  58. package/test/request-generation.test.ts +128 -0
@@ -0,0 +1,202 @@
1
+ import { expect, fixture } from '@open-wc/testing';
2
+ import { html } from 'lit';
3
+ import { addressController, writeAddress } from '@operato/utils/address.js';
4
+ import { encodeListQuery } from '@operato/utils/list-query.js';
5
+ import '../src/data-grist.js';
6
+ const turn = () => new Promise(resolve => setTimeout(resolve, 0));
7
+ const native = () => window.navigation;
8
+ const filters = (month) => [{ name: 'month', operator: 'eq', value: month }];
9
+ const address = (month) => `?${encodeListQuery({ filters: filters(month) })}`;
10
+ async function until(check) {
11
+ for (let i = 0; i < 200; i++) {
12
+ if (check())
13
+ return;
14
+ await new Promise(resolve => setTimeout(resolve, 5));
15
+ }
16
+ throw new Error('intent sequence did not settle');
17
+ }
18
+ /** Product oracle: only the latest accepted intent changes the query, records, edits or history. */
19
+ class Intended {
20
+ constructor() {
21
+ this.entries = [10];
22
+ this.cursor = 0;
23
+ this.edited = false;
24
+ this.reads = [10];
25
+ }
26
+ get month() {
27
+ return this.entries[this.cursor];
28
+ }
29
+ accept(month) {
30
+ if (month === this.month)
31
+ return;
32
+ this.entries.splice(++this.cursor);
33
+ this.entries.push(month);
34
+ this.edited = false;
35
+ this.reads.push(month);
36
+ }
37
+ back() {
38
+ this.cursor--;
39
+ this.edited = false;
40
+ this.reads.push(this.month);
41
+ }
42
+ }
43
+ describe('overlapping user intents against query and displayed state', () => {
44
+ let previousOnError;
45
+ const resizeNotice = (event) => {
46
+ if (event.message.includes('ResizeObserver loop')) {
47
+ event.preventDefault();
48
+ event.stopImmediatePropagation();
49
+ }
50
+ };
51
+ before(() => {
52
+ window.addEventListener('error', resizeNotice, true);
53
+ previousOnError = window.onerror;
54
+ window.onerror = (message, ...rest) => String(message).includes('ResizeObserver loop') ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
55
+ });
56
+ after(() => {
57
+ window.removeEventListener('error', resizeNotice, true);
58
+ window.onerror = previousOnError;
59
+ });
60
+ it('checks every edit, question, refusal, supersession, adoption and browser traversal', async () => {
61
+ const controller = addressController();
62
+ controller.registerQuery();
63
+ const coverage = new Set();
64
+ for (let seed = 1; seed <= 12; seed++) {
65
+ await writeAddress(address(10));
66
+ const floorKey = controller.entry.key;
67
+ const reads = [];
68
+ let shown = [];
69
+ const grist = await fixture(html `<ox-grist
70
+ style="display:block;width:800px;height:400px"
71
+ .urlParamsSensitive=${true}
72
+ .config=${{ columns: [{ name: 'month', header: 'month' }], pagination: { limit: 20 } }}
73
+ .fetchHandler=${async ({ filters: list }) => {
74
+ const month = Number(list.find((filter) => filter.name === 'month').value);
75
+ reads.push(month);
76
+ return { records: [{ id: String(month), month }], total: 1 };
77
+ }}
78
+ @list-adopted=${(event) => {
79
+ shown = event.detail.records.map((row) => row.month);
80
+ }}
81
+ ></ox-grist>`);
82
+ await until(() => { var _a, _b, _c; return ((_c = (_b = (_a = grist.data) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.month) === 10; });
83
+ const expected = new Intended();
84
+ // Initial configuration may make the initial read once or more; subsequent intent reads must match exactly.
85
+ reads.splice(0, reads.length, 10);
86
+ let decision;
87
+ let gated = false;
88
+ const stopGuard = controller.guard({
89
+ dirty: () => grist.dirtyRecords.length > 0,
90
+ approveSync: () => false,
91
+ approve: change => {
92
+ if (!grist.dirtyRecords.length)
93
+ return true;
94
+ return new Promise(resolve => {
95
+ const endQuestion = gated ? controller.beginQuestion() : () => { };
96
+ const finish = (answer) => {
97
+ endQuestion();
98
+ resolve(answer);
99
+ };
100
+ decision = finish;
101
+ change.signal.addEventListener('abort', () => finish(false), { once: true });
102
+ });
103
+ },
104
+ committed: () => grist.reset()
105
+ });
106
+ const verify = async (step) => {
107
+ await turn();
108
+ await grist.updateComplete;
109
+ expect(grist.filters, step).to.deep.equal(filters(expected.month));
110
+ expect(grist.data.records.map(row => row.month), step).to.deep.equal([expected.month]);
111
+ expect(shown, step).to.deep.equal([expected.month]);
112
+ expect(grist.dirtyRecords.length > 0, step).to.equal(expected.edited);
113
+ expect(reads, step).to.deep.equal(expected.reads);
114
+ const entries = native().entries();
115
+ const floor = entries.findIndex((entry) => entry.key === floorKey);
116
+ expect(floor, step).to.be.at.least(0);
117
+ expect(entries
118
+ .slice(floor)
119
+ .map((entry) => JSON.parse(new URL(entry.url).searchParams.get('filters'))[0].value), step).to.deep.equal(expected.entries);
120
+ expect(native().currentEntry.index - floor, step).to.equal(expected.cursor);
121
+ };
122
+ let random = seed;
123
+ try {
124
+ for (let step = 0; step < 18; step++) {
125
+ random = (Math.imul(random, 1664525) + 1013904223) >>> 0;
126
+ const action = random % 5;
127
+ coverage.add(action);
128
+ const label = `seed ${seed}, step ${step}, action ${action}`;
129
+ const next = 20 + seed * 100 + step;
130
+ // Real grid edit, independent of the oracle's edit flag.
131
+ grist.dirtyData.records[0].__dirty__ = 'M';
132
+ grist.dirtyData.records[0].memo = label;
133
+ grist.refresh();
134
+ expected.edited = true;
135
+ await verify(label + ' edited');
136
+ decision = undefined;
137
+ gated = action !== 2 && action !== 4;
138
+ const first = writeAddress(address(next));
139
+ await turn();
140
+ await verify(label + ' before decision');
141
+ await until(() => !!decision);
142
+ const answerFirst = decision;
143
+ await verify(label + ' question pending');
144
+ if (action === 0) {
145
+ answerFirst(false);
146
+ expect(await first, label).to.equal(false);
147
+ }
148
+ else if (action === 1) {
149
+ // Requests made under a real modal question are rejected without fetching or changing the view.
150
+ expect(await writeAddress(address(next + 10000)), label).to.equal(false);
151
+ await verify(label + ' outside request refused');
152
+ answerFirst(true);
153
+ expect(await first, label).to.equal(true);
154
+ expected.accept(next);
155
+ }
156
+ else if (action === 2) {
157
+ // An asynchronous owner decision can be superseded before a dialog is installed.
158
+ decision = undefined;
159
+ const second = writeAddress(address(next + 10000));
160
+ await until(() => !!decision);
161
+ decision(true);
162
+ expect(await second, label).to.equal(true);
163
+ expected.accept(next + 10000);
164
+ answerFirst(true);
165
+ expect(await first, label).to.equal(false);
166
+ }
167
+ else if (action === 3) {
168
+ answerFirst(true);
169
+ expect(await first, label).to.equal(true);
170
+ expected.accept(next);
171
+ }
172
+ else {
173
+ if (expected.cursor > 0) {
174
+ // Browser navigation aborts the outstanding application approval; an old yes cannot revive it.
175
+ decision = undefined;
176
+ const movement = native().back();
177
+ movement.finished.catch(() => { });
178
+ await until(() => !!decision);
179
+ decision(true);
180
+ await movement.finished;
181
+ expected.back();
182
+ answerFirst(true);
183
+ expect(await first, label).to.equal(false);
184
+ }
185
+ else {
186
+ answerFirst(false);
187
+ expect(await first, label).to.equal(false);
188
+ }
189
+ }
190
+ await until(() => { var _a; return ((_a = grist.data.records[0]) === null || _a === void 0 ? void 0 : _a.month) === expected.month; });
191
+ await verify(label + ' completed');
192
+ }
193
+ }
194
+ finally {
195
+ stopGuard();
196
+ grist.remove();
197
+ }
198
+ }
199
+ expect([...coverage].sort()).to.deep.equal([0, 1, 2, 3, 4]);
200
+ }).timeout(45000);
201
+ });
202
+ //# sourceMappingURL=address-intents.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-intents.test.js","sourceRoot":"","sources":["../../test/address-intents.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE9D,OAAO,sBAAsB,CAAA;AAE7B,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAA;AACjE,MAAM,MAAM,GAAG,GAAG,EAAE,CAAE,MAAc,CAAC,UAAU,CAAA;AAC/C,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;AACpF,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;AACrF,KAAK,UAAU,KAAK,CAAC,KAAoB;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,IAAI,KAAK,EAAE;YAAE,OAAM;QACnB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UA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AAS,CAAC;gBACT,SAAS,EAAE,CAAA;gBACX,KAAK,CAAC,MAAM,EAAE,CAAA;YAChB,CAAC;QACH,CAAC;QACD,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AACnB,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\nimport { addressController, writeAddress } from '@operato/utils/address.js'\nimport { encodeListQuery } from '@operato/utils/list-query.js'\nimport type { DataGrist } from '../src/data-grist.js'\nimport '../src/data-grist.js'\n\nconst turn = () => new Promise(resolve => setTimeout(resolve, 0))\nconst native = () => (window as any).navigation\nconst filters = (month: number) => [{ name: 'month', operator: 'eq', value: month }]\nconst address = (month: number) => `?${encodeListQuery({ filters: filters(month) })}`\nasync function until(check: () => boolean) {\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('intent sequence did not settle')\n}\n\n/** Product oracle: only the latest accepted intent changes the query, records, edits or history. */\nclass Intended {\n entries: number[] = [10]\n cursor = 0\n edited = false\n reads = [10]\n get month() {\n return this.entries[this.cursor]\n }\n accept(month: number) {\n if (month === this.month) return\n this.entries.splice(++this.cursor)\n this.entries.push(month)\n this.edited = false\n this.reads.push(month)\n }\n back() {\n this.cursor--\n this.edited = false\n this.reads.push(this.month)\n }\n}\n\ndescribe('overlapping user intents against query and displayed state', () => {\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 it('checks every edit, question, refusal, supersession, adoption and browser traversal', async () => {\n const controller = addressController()\n controller.registerQuery()\n const coverage = new Set<number>()\n for (let seed = 1; seed <= 12; seed++) {\n await writeAddress(address(10))\n const floorKey = controller.entry.key\n const reads: number[] = []\n let shown: number[] = []\n const grist = await fixture<DataGrist>(\n html`<ox-grist\n style=\"display:block;width:800px;height:400px\"\n .urlParamsSensitive=${true}\n .config=${{ columns: [{ name: 'month', header: 'month' }], pagination: { limit: 20 } }}\n .fetchHandler=${async ({ filters: list }: any) => {\n const month = Number(list.find((filter: any) => filter.name === 'month').value)\n reads.push(month)\n return { records: [{ id: String(month), month }], total: 1 }\n }}\n @list-adopted=${(event: CustomEvent) => {\n shown = event.detail.records.map((row: any) => row.month)\n }}\n ></ox-grist>`\n )\n await until(() => grist.data?.records?.[0]?.month === 10)\n const expected = new Intended()\n // Initial configuration may make the initial read once or more; subsequent intent reads must match exactly.\n reads.splice(0, reads.length, 10)\n let decision: ((answer: boolean) => void) | undefined\n let gated = false\n const stopGuard = controller.guard({\n dirty: () => grist.dirtyRecords.length > 0,\n approveSync: () => false,\n approve: change => {\n if (!grist.dirtyRecords.length) return true\n return new Promise<boolean>(resolve => {\n const endQuestion = gated ? controller.beginQuestion() : () => {}\n const finish = (answer: boolean) => {\n endQuestion()\n resolve(answer)\n }\n decision = finish\n change.signal.addEventListener('abort', () => finish(false), { once: true })\n })\n },\n committed: () => grist.reset()\n })\n const verify = async (step: string) => {\n await turn()\n await grist.updateComplete\n expect(grist.filters, step).to.deep.equal(filters(expected.month))\n expect(\n grist.data.records.map(row => row.month),\n step\n ).to.deep.equal([expected.month])\n expect(shown, step).to.deep.equal([expected.month])\n expect(grist.dirtyRecords.length > 0, step).to.equal(expected.edited)\n expect(reads, step).to.deep.equal(expected.reads)\n const entries = native().entries()\n const floor = entries.findIndex((entry: any) => entry.key === floorKey)\n expect(floor, step).to.be.at.least(0)\n expect(\n entries\n .slice(floor)\n .map((entry: any) => JSON.parse(new URL(entry.url).searchParams.get('filters')!)[0].value),\n step\n ).to.deep.equal(expected.entries)\n expect(native().currentEntry.index - floor, step).to.equal(expected.cursor)\n }\n let random = seed\n try {\n for (let step = 0; step < 18; step++) {\n random = (Math.imul(random, 1664525) + 1013904223) >>> 0\n const action = random % 5\n coverage.add(action)\n const label = `seed ${seed}, step ${step}, action ${action}`\n const next = 20 + seed * 100 + step\n // Real grid edit, independent of the oracle's edit flag.\n grist.dirtyData.records[0].__dirty__ = 'M'\n grist.dirtyData.records[0].memo = label\n grist.refresh()\n expected.edited = true\n await verify(label + ' edited')\n decision = undefined\n gated = action !== 2 && action !== 4\n const first = writeAddress(address(next))\n await turn()\n await verify(label + ' before decision')\n await until(() => !!decision)\n const answerFirst = decision!\n await verify(label + ' question pending')\n if (action === 0) {\n answerFirst(false)\n expect(await first, label).to.equal(false)\n } else if (action === 1) {\n // Requests made under a real modal question are rejected without fetching or changing the view.\n expect(await writeAddress(address(next + 10000)), label).to.equal(false)\n await verify(label + ' outside request refused')\n answerFirst(true)\n expect(await first, label).to.equal(true)\n expected.accept(next)\n } else if (action === 2) {\n // An asynchronous owner decision can be superseded before a dialog is installed.\n decision = undefined\n const second = writeAddress(address(next + 10000))\n await until(() => !!decision)\n decision!(true)\n expect(await second, label).to.equal(true)\n expected.accept(next + 10000)\n answerFirst(true)\n expect(await first, label).to.equal(false)\n } else if (action === 3) {\n answerFirst(true)\n expect(await first, label).to.equal(true)\n expected.accept(next)\n } else {\n if (expected.cursor > 0) {\n // Browser navigation aborts the outstanding application approval; an old yes cannot revive it.\n decision = undefined\n const movement = native().back()\n movement.finished.catch(() => {})\n await until(() => !!decision)\n decision!(true)\n await movement.finished\n expected.back()\n answerFirst(true)\n expect(await first, label).to.equal(false)\n } else {\n answerFirst(false)\n expect(await first, label).to.equal(false)\n }\n }\n await until(() => grist.data.records[0]?.month === expected.month)\n await verify(label + ' completed')\n }\n } finally {\n stopGuard()\n grist.remove()\n }\n }\n expect([...coverage].sort()).to.deep.equal([0, 1, 2, 3, 4])\n }).timeout(45000)\n})\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { externalFilters, ownedFilterIndex, patchFilterFields } from '../src/filters/filter-ownership.js';
3
+ describe('filter field ownership', () => {
4
+ const year = { name: 'year', filter: { operator: 'eq' } };
5
+ const month = { name: 'month', filter: { operator: 'eq' } };
6
+ const predicate = (name, operator, value) => ({ name, operator, value });
7
+ it('changing a month preserves same-name bounds and an external amount', () => {
8
+ const base = [
9
+ predicate('year', 'eq', 2026),
10
+ predicate('year', 'gte', 2025),
11
+ predicate('year', 'lte', 2026),
12
+ predicate('month', 'eq', 10),
13
+ predicate('amount', 'gte', 100000)
14
+ ];
15
+ const result = patchFilterFields(base, [predicate('year', 'eq', 2026), predicate('month', 'eq', 11)], [year, month], ['month']);
16
+ expect(result).to.deep.equal([base[0], base[1], base[2], predicate('month', 'eq', 11), base[4]]);
17
+ expect(externalFilters(result, [year, month]).map(one => one.filter)).to.deep.equal([base[1], base[2], base[4]]);
18
+ });
19
+ it('a field changed to the value it holds leaves the filters as they were, order included', () => {
20
+ const base = [predicate('year', 'eq', '2026'), predicate('month', 'eq', '10')];
21
+ const fields = [predicate('year', 'eq', '2026'), predicate('month', 'eq', '10')];
22
+ expect(patchFilterFields(base, fields, [year, month], ['year'])).to.deep.equal(base);
23
+ });
24
+ it('a field that held nothing adds its predicate after the others', () => {
25
+ const base = [predicate('amount', 'gte', 100000)];
26
+ expect(patchFilterFields(base, [predicate('month', 'eq', '9')], [year, month], ['month'])).to.deep.equal([
27
+ base[0],
28
+ predicate('month', 'eq', '9')
29
+ ]);
30
+ });
31
+ it('ambiguous equalities both stay as chips and leave the field empty', () => {
32
+ const base = [predicate('year', 'eq', 2025), predicate('year', 'eq', 2026)];
33
+ expect(ownedFilterIndex(base, year)).to.equal(-1);
34
+ expect(externalFilters(base, [year]).length).to.equal(2);
35
+ });
36
+ it('a scalar field does not claim an array predicate', () => {
37
+ expect(ownedFilterIndex([predicate('year', 'eq', [2025, 2026])], year)).to.equal(-1);
38
+ });
39
+ });
40
+ //# sourceMappingURL=filter-ownership.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-ownership.test.js","sourceRoot":"","sources":["../../test/filter-ownership.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAGzG,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAkB,CAAA;IACzE,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAkB,CAAA;IAC3E,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,QAAgB,EAAE,KAAU,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAgB,CAAA;IAE5G,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,MAAM,IAAI,GAAG;YACX,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC;YAC7B,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC;YAC9B,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC;YAC9B,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;YAC5B,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC;SACnC,CAAA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,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;IACtF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect } from '@open-wc/testing'\nimport { externalFilters, ownedFilterIndex, patchFilterFields } from '../src/filters/filter-ownership.js'\nimport type { ColumnConfig, FilterValue } from '../src/types.js'\n\ndescribe('filter field ownership', () => {\n const year = { name: 'year', filter: { operator: 'eq' } } as ColumnConfig\n const month = { name: 'month', filter: { operator: 'eq' } } as ColumnConfig\n const predicate = (name: string, operator: string, value: any) => ({ name, operator, value }) as FilterValue\n\n it('changing a month preserves same-name bounds and an external amount', () => {\n const base = [\n predicate('year', 'eq', 2026),\n predicate('year', 'gte', 2025),\n predicate('year', 'lte', 2026),\n predicate('month', 'eq', 10),\n predicate('amount', 'gte', 100000)\n ]\n const result = patchFilterFields(\n base,\n [predicate('year', 'eq', 2026), predicate('month', 'eq', 11)],\n [year, month],\n ['month']\n )\n expect(result).to.deep.equal([base[0], base[1], base[2], predicate('month', 'eq', 11), base[4]])\n expect(externalFilters(result, [year, month]).map(one => one.filter)).to.deep.equal([base[1], base[2], base[4]])\n })\n\n it('a field changed to the value it holds leaves the filters as they were, order included', () => {\n const base = [predicate('year', 'eq', '2026'), predicate('month', 'eq', '10')]\n const fields = [predicate('year', 'eq', '2026'), predicate('month', 'eq', '10')]\n expect(patchFilterFields(base, fields, [year, month], ['year'])).to.deep.equal(base)\n })\n\n it('a field that held nothing adds its predicate after the others', () => {\n const base = [predicate('amount', 'gte', 100000)]\n expect(patchFilterFields(base, [predicate('month', 'eq', '9')], [year, month], ['month'])).to.deep.equal([\n base[0],\n predicate('month', 'eq', '9')\n ])\n })\n\n it('ambiguous equalities both stay as chips and leave the field empty', () => {\n const base = [predicate('year', 'eq', 2025), predicate('year', 'eq', 2026)]\n expect(ownedFilterIndex(base, year)).to.equal(-1)\n expect(externalFilters(base, [year]).length).to.equal(2)\n })\n\n it('a scalar field does not claim an array predicate', () => {\n expect(ownedFilterIndex([predicate('year', 'eq', [2025, 2026])], year)).to.equal(-1)\n })\n})\n"]}
@@ -22,6 +22,19 @@ customElements.define('probe-popup-editor', ProbePopupEditor);
22
22
  registerEditor('probe-popup', ProbePopupEditor);
23
23
  const settle = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms));
24
24
  describe('a popup field in a form', () => {
25
+ it('does not emit the old inline value after a popup has confirmed a different value', async () => {
26
+ const record = { body: 'old' };
27
+ const editor = await fixture(html `<probe-popup-editor
28
+ .column=${buildColumn({ type: 'probe-popup', name: 'body', record: { editable: true } })}
29
+ .record=${record}
30
+ ></probe-popup-editor>`);
31
+ let changes = 0;
32
+ editor.addEventListener('field-change', () => changes++);
33
+ record.body = 'confirmed';
34
+ editor._onfocusout();
35
+ expect(changes).to.equal(0);
36
+ expect(record.body).to.equal('confirmed');
37
+ });
25
38
  it('opens its popup on the first press', async () => {
26
39
  opened = 0;
27
40
  const columns = [
@@ -1 +1 @@
1
- {"version":3,"file":"record-view-popup-editor.test.js","sourceRoot":"","sources":["../../test/record-view-popup-editor.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,mCAAmC,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAE3D;;;;GAIG;AAEH,IAAI,MAAM,GAAG,CAAC,CAAA;AAEd,MAAM,gBAAiB,SAAQ,aAAa;IAG1C,QAAQ,CAAC,CAAQ;QACf,CAAC,CAAC,eAAe,EAAE,CAAA;QACnB,MAAM,EAAE,CAAA;IACV,CAAC;;AALM,2BAAU,GA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,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACtD,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","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/record-view/record-view.js'\nimport { buildColumn } from '../src/configure/column-builder.js'\nimport { OxGristEditor } from '../src/editors/ox-grist-editor.js'\nimport { registerEditor } from '../src/editors/registry.js'\n\n/*\n * In a form (ox-record-view - the 「만들기」 dialog of a grid) a field is pressed to be edited. A field whose editor\n * opens a popup used to become 「editing」 on the first press but open nothing until its editor was pressed again,\n * so what was typed after the first press went nowhere (pdf template 「만들기」, body HTML, 2026-10-10).\n */\n\nlet opened = 0\n\nclass ProbePopupEditor extends OxGristEditor {\n static opensPopup = true\n\n _onclick(e: Event): void {\n e.stopPropagation()\n opened++\n }\n}\ncustomElements.define('probe-popup-editor', ProbePopupEditor)\nregisterEditor('probe-popup', ProbePopupEditor)\n\nconst settle = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms))\n\ndescribe('a popup field in a form', () => {\n it('opens its popup on the first press', async () => {\n opened = 0\n const columns = [\n buildColumn({ type: 'string', name: 'name', header: 'name', record: { editable: true } } as any),\n buildColumn({ type: 'probe-popup', name: 'body', header: 'body', record: { editable: true } } as any)\n ]\n const view = (await fixture(html`<ox-record-view .columns=${columns} .record=${{}}></ox-record-view>`)) as any\n await view.updateComplete\n await settle()\n\n const body = view.renderRoot.querySelector('ox-record-view-body') as any\n await body.updateComplete\n const field = Array.from(body.renderRoot.querySelectorAll('ox-grid-field') as NodeListOf<any>).find(one => one.column?.name === 'body')\n expect(!!field, 'the body field is drawn').to.equal(true)\n\n field.click()\n await settle(200)\n\n expect(field.getAttribute('editing'), 'the field is being edited').to.equal('true')\n expect(opened, 'the popup editor was opened once').to.equal(1)\n })\n\n it('leaves a field edited in place as it was - nothing extra is pressed', async () => {\n opened = 0\n const columns = [buildColumn({ type: 'string', name: 'name', header: 'name', record: { editable: true } } as any)]\n const view = (await fixture(html`<ox-record-view .columns=${columns} .record=${{}}></ox-record-view>`)) as any\n await view.updateComplete\n await settle()\n const body = view.renderRoot.querySelector('ox-record-view-body') as any\n await body.updateComplete\n const field = body.renderRoot.querySelector('ox-grid-field') as any\n field.click()\n await settle(200)\n expect(field.getAttribute('editing')).to.equal('true')\n expect(opened).to.equal(0)\n })\n})\n"]}
1
+ {"version":3,"file":"record-view-popup-editor.test.js","sourceRoot":"","sources":["../../test/record-view-popup-editor.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,mCAAmC,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAE3D;;;;GAIG;AAEH,IAAI,MAAM,GAAG,CAAC,CAAA;AAEd,MAAM,gBAAiB,SAAQ,aAAa;IAG1C,QAAQ,CAAC,CAAQ;QACf,CAAC,CAAC,eAAe,EAAE,CAAA;QACnB,MAAM,EAAE,CAAA;IACV,CAAC;;AALM,2BAAU,GAAG,IAAI,CAAA;AAO1B,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAA;AAC7D,cAAc,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAA;AAE/C,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE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;QAClH,MAAM,IAAI,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAA,4BAA4B,OAAO,YAAY,EAAE,oBAAoB,CAAC,CAAQ,CAAA;QAC9G,MAAM,IAAI,CAAC,cAAc,CAAA;QACzB,MAAM,MAAM,EAAE,CAAA;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,qBAAqB,CAAQ,CAAA;QACxE,MAAM,IAAI,CAAC,cAAc,CAAA;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,eAAe,CAAQ,CAAA;QACnE,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,MAAM,MAAM,CAAC,GAAG,CAAC,CAAA;QACjB,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACtD,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","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/record-view/record-view.js'\nimport { buildColumn } from '../src/configure/column-builder.js'\nimport { OxGristEditor } from '../src/editors/ox-grist-editor.js'\nimport { registerEditor } from '../src/editors/registry.js'\n\n/*\n * In a form (ox-record-view - the 「만들기」 dialog of a grid) a field is pressed to be edited. A field whose editor\n * opens a popup used to become 「editing」 on the first press but open nothing until its editor was pressed again,\n * so what was typed after the first press went nowhere (pdf template 「만들기」, body HTML, 2026-10-10).\n */\n\nlet opened = 0\n\nclass ProbePopupEditor extends OxGristEditor {\n static opensPopup = true\n\n _onclick(e: Event): void {\n e.stopPropagation()\n opened++\n }\n}\ncustomElements.define('probe-popup-editor', ProbePopupEditor)\nregisterEditor('probe-popup', ProbePopupEditor)\n\nconst settle = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms))\n\ndescribe('a popup field in a form', () => {\n it('does not emit the old inline value after a popup has confirmed a different value', async () => {\n const record = { body: 'old' }\n const editor = await fixture<ProbePopupEditor>(\n html`<probe-popup-editor\n .column=${buildColumn({ type: 'probe-popup', name: 'body', record: { editable: true } } as any)}\n .record=${record}\n ></probe-popup-editor>`\n )\n let changes = 0\n editor.addEventListener('field-change', () => changes++)\n record.body = 'confirmed'\n editor._onfocusout()\n expect(changes).to.equal(0)\n expect(record.body).to.equal('confirmed')\n })\n\n it('opens its popup on the first press', async () => {\n opened = 0\n const columns = [\n buildColumn({ type: 'string', name: 'name', header: 'name', record: { editable: true } } as any),\n buildColumn({ type: 'probe-popup', name: 'body', header: 'body', record: { editable: true } } as any)\n ]\n const view = (await fixture(html`<ox-record-view .columns=${columns} .record=${{}}></ox-record-view>`)) as any\n await view.updateComplete\n await settle()\n\n const body = view.renderRoot.querySelector('ox-record-view-body') as any\n await body.updateComplete\n const field = Array.from(body.renderRoot.querySelectorAll('ox-grid-field') as NodeListOf<any>).find(one => one.column?.name === 'body')\n expect(!!field, 'the body field is drawn').to.equal(true)\n\n field.click()\n await settle(200)\n\n expect(field.getAttribute('editing'), 'the field is being edited').to.equal('true')\n expect(opened, 'the popup editor was opened once').to.equal(1)\n })\n\n it('leaves a field edited in place as it was - nothing extra is pressed', async () => {\n opened = 0\n const columns = [buildColumn({ type: 'string', name: 'name', header: 'name', record: { editable: true } } as any)]\n const view = (await fixture(html`<ox-record-view .columns=${columns} .record=${{}}></ox-record-view>`)) as any\n await view.updateComplete\n await settle()\n const body = view.renderRoot.querySelector('ox-record-view-body') as any\n await body.updateComplete\n const field = body.renderRoot.querySelector('ox-grid-field') as any\n field.click()\n await settle(200)\n expect(field.getAttribute('editing')).to.equal('true')\n expect(opened).to.equal(0)\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,120 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { DataProvider } from '../src/data-provider.js';
3
+ function pending() {
4
+ let resolve;
5
+ let reject;
6
+ const promise = new Promise((yes, no) => {
7
+ resolve = yes;
8
+ reject = no;
9
+ });
10
+ return { promise, resolve, reject };
11
+ }
12
+ function setup() {
13
+ const calls = [];
14
+ const events = [];
15
+ let data = { records: [] };
16
+ let spinning = false;
17
+ const consumer = Object.assign(new EventTarget(), {
18
+ mode: 'GRID',
19
+ get data() {
20
+ return data;
21
+ },
22
+ set data(next) {
23
+ data = next;
24
+ },
25
+ _data: data,
26
+ checkDirties() { },
27
+ showSpinner() {
28
+ spinning = true;
29
+ },
30
+ hideSpinner() {
31
+ spinning = false;
32
+ },
33
+ fetchHandler(options) {
34
+ const result = pending();
35
+ calls.push({ options, result });
36
+ return result.promise;
37
+ }
38
+ });
39
+ // The grid's dirty copy follows adoption; an append must preserve its edited values.
40
+ consumer.addEventListener('list-adopted', event => {
41
+ const detail = event.detail;
42
+ events.push(detail);
43
+ consumer._data = { ...detail };
44
+ });
45
+ return { provider: new DataProvider(consumer), consumer, calls, events, spinning: () => spinning };
46
+ }
47
+ const answer = (...ids) => ({ total: 100, records: ids.map(id => ({ id })) });
48
+ describe('query generations', () => {
49
+ it('never appends an old query page to a replacement', async () => {
50
+ const { provider, calls, events } = setup();
51
+ const initial = provider.fetch();
52
+ calls[0].result.resolve(answer('old-1'));
53
+ await initial;
54
+ const oldPage = provider.attach();
55
+ const replacement = provider.fetch();
56
+ calls[2].result.resolve(answer('new-1'));
57
+ await replacement;
58
+ calls[1].result.resolve(answer('old-2'));
59
+ await oldPage;
60
+ expect(provider.records.map(row => row.id)).to.deep.equal(['new-1']);
61
+ expect(events.map(event => event.kind)).to.deep.equal(['replace', 'replace']);
62
+ });
63
+ it('coalesces next-page triggers, preserves edits and deduplicates ids', async () => {
64
+ const { provider, consumer, calls, events } = setup();
65
+ const initial = provider.attach(true);
66
+ calls[0].result.resolve(answer('one'));
67
+ await initial;
68
+ consumer._data.records[0].edited = true;
69
+ const a = provider.attach();
70
+ const b = provider.attach();
71
+ expect(a).to.equal(b);
72
+ expect(calls.length).to.equal(2);
73
+ calls[1].result.resolve(answer('one', 'two', 'two'));
74
+ await a;
75
+ expect(provider.records).to.deep.equal([{ id: 'one', edited: true }, { id: 'two' }]);
76
+ expect(events[1].page).to.equal(2);
77
+ expect(events[1].records.length).to.equal(2);
78
+ expect(events[1].pageRecords.length).to.equal(3);
79
+ });
80
+ it('keeps rows and retries the same page after a failed append', async () => {
81
+ const { provider, calls } = setup();
82
+ const initial = provider.fetch();
83
+ calls[0].result.resolve(answer('one'));
84
+ await initial;
85
+ const append = provider.attach();
86
+ calls[1].result.reject(new Error('offline'));
87
+ try {
88
+ await append;
89
+ }
90
+ catch (_a) { }
91
+ expect(provider.records.map(row => row.id)).to.deep.equal(['one']);
92
+ const retry = provider.attach();
93
+ expect(calls[2].options.page).to.equal(2);
94
+ calls[2].result.resolve(answer('two'));
95
+ await retry;
96
+ expect(provider.records.map(row => row.id)).to.deep.equal(['one', 'two']);
97
+ });
98
+ it('a stale response cannot stop the current spinner or announce adoption', async () => {
99
+ const { provider, calls, events, spinning } = setup();
100
+ const old = provider.fetch();
101
+ const next = provider.fetch();
102
+ calls[0].result.resolve(answer('old'));
103
+ await old;
104
+ expect(spinning()).to.equal(true);
105
+ expect(events.length).to.equal(0);
106
+ calls[1].result.resolve(answer('new'));
107
+ await next;
108
+ expect(spinning()).to.equal(false);
109
+ expect(events.length).to.equal(1);
110
+ });
111
+ it('disposal invalidates replacement and append responses', async () => {
112
+ const { provider, calls, events } = setup();
113
+ const request = provider.fetch();
114
+ provider.dispose();
115
+ calls[0].result.resolve(answer('late'));
116
+ await request;
117
+ expect(events.length).to.equal(0);
118
+ });
119
+ });
120
+ //# sourceMappingURL=request-generation.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-generation.test.js","sourceRoot":"","sources":["../../test/request-generation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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CAAC,CAAA;QACtC,MAAM,IAAI,CAAA;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAClC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACrE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAA;QAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAA;QAChC,QAAQ,CAAC,OAAO,EAAE,CAAA;QAClB,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;QACvC,MAAM,OAAO,CAAA;QACb,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACnC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect } from '@open-wc/testing'\nimport { DataProvider } from '../src/data-provider.js'\nimport type { DataConsumer } from '../src/data-consumer.js'\nimport type { FetchOption, FetchResult } from '../src/types.js'\n\nfunction pending() {\n let resolve!: (result: FetchResult) => void\n let reject!: (error: Error) => void\n const promise = new Promise<FetchResult>((yes, no) => {\n resolve = yes\n reject = no\n })\n return { promise, resolve, reject }\n}\n\nfunction setup() {\n const calls: { options: FetchOption; result: ReturnType<typeof pending> }[] = []\n const events: any[] = []\n let data: any = { records: [] }\n let spinning = false\n const consumer = Object.assign(new EventTarget(), {\n mode: 'GRID' as const,\n get data() {\n return data\n },\n set data(next) {\n data = next\n },\n _data: data,\n checkDirties() {},\n showSpinner() {\n spinning = true\n },\n hideSpinner() {\n spinning = false\n },\n fetchHandler(options: FetchOption) {\n const result = pending()\n calls.push({ options, result })\n return result.promise\n }\n }) as DataConsumer\n // The grid's dirty copy follows adoption; an append must preserve its edited values.\n consumer.addEventListener('list-adopted', event => {\n const detail = (event as CustomEvent).detail\n events.push(detail)\n consumer._data = { ...detail }\n })\n return { provider: new DataProvider(consumer), consumer, calls, events, spinning: () => spinning }\n}\n\nconst answer = (...ids: string[]): FetchResult => ({ total: 100, records: ids.map(id => ({ id })) })\n\ndescribe('query generations', () => {\n it('never appends an old query page to a replacement', async () => {\n const { provider, calls, events } = setup()\n const initial = provider.fetch()\n calls[0].result.resolve(answer('old-1'))\n await initial\n const oldPage = provider.attach()\n const replacement = provider.fetch()\n calls[2].result.resolve(answer('new-1'))\n await replacement\n calls[1].result.resolve(answer('old-2'))\n await oldPage\n expect(provider.records.map(row => row.id)).to.deep.equal(['new-1'])\n expect(events.map(event => event.kind)).to.deep.equal(['replace', 'replace'])\n })\n\n it('coalesces next-page triggers, preserves edits and deduplicates ids', async () => {\n const { provider, consumer, calls, events } = setup()\n const initial = provider.attach(true)\n calls[0].result.resolve(answer('one'))\n await initial\n consumer._data.records[0].edited = true\n const a = provider.attach()\n const b = provider.attach()\n expect(a).to.equal(b)\n expect(calls.length).to.equal(2)\n calls[1].result.resolve(answer('one', 'two', 'two'))\n await a\n expect(provider.records).to.deep.equal([{ id: 'one', edited: true }, { id: 'two' }])\n expect(events[1].page).to.equal(2)\n expect(events[1].records.length).to.equal(2)\n expect(events[1].pageRecords.length).to.equal(3)\n })\n\n it('keeps rows and retries the same page after a failed append', async () => {\n const { provider, calls } = setup()\n const initial = provider.fetch()\n calls[0].result.resolve(answer('one'))\n await initial\n const append = provider.attach()\n calls[1].result.reject(new Error('offline'))\n try {\n await append\n } catch {}\n expect(provider.records.map(row => row.id)).to.deep.equal(['one'])\n const retry = provider.attach()\n expect(calls[2].options.page).to.equal(2)\n calls[2].result.resolve(answer('two'))\n await retry\n expect(provider.records.map(row => row.id)).to.deep.equal(['one', 'two'])\n })\n\n it('a stale response cannot stop the current spinner or announce adoption', async () => {\n const { provider, calls, events, spinning } = setup()\n const old = provider.fetch()\n const next = provider.fetch()\n calls[0].result.resolve(answer('old'))\n await old\n expect(spinning()).to.equal(true)\n expect(events.length).to.equal(0)\n calls[1].result.resolve(answer('new'))\n await next\n expect(spinning()).to.equal(false)\n expect(events.length).to.equal(1)\n })\n\n it('disposal invalidates replacement and append responses', async () => {\n const { provider, calls, events } = setup()\n const request = provider.fetch()\n provider.dispose()\n calls[0].result.resolve(answer('late'))\n await request\n expect(events.length).to.equal(0)\n })\n})\n"]}