@operato/data-grist 10.29.51 → 10.29.56

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 (54) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/src/data-card/data-card.js +5 -5
  3. package/dist/src/data-card/data-card.js.map +1 -1
  4. package/dist/src/data-grid/data-grid-body.d.ts +8 -0
  5. package/dist/src/data-grid/data-grid-body.js +44 -27
  6. package/dist/src/data-grid/data-grid-body.js.map +1 -1
  7. package/dist/src/data-grid/data-grid.d.ts +1 -1
  8. package/dist/src/data-grid/data-grid.js +3 -2
  9. package/dist/src/data-grid/data-grid.js.map +1 -1
  10. package/dist/src/data-grist.js +17 -17
  11. package/dist/src/data-grist.js.map +1 -1
  12. package/dist/src/data-list/data-list.js +5 -5
  13. package/dist/src/data-list/data-list.js.map +1 -1
  14. package/dist/src/data-manipulator.d.ts +16 -1
  15. package/dist/src/data-manipulator.js +57 -14
  16. package/dist/src/data-manipulator.js.map +1 -1
  17. package/dist/src/editors/ox-grist-editor-number.js +2 -7
  18. package/dist/src/editors/ox-grist-editor-number.js.map +1 -1
  19. package/dist/src/editors/ox-grist-editor-select.d.ts +14 -0
  20. package/dist/src/editors/ox-grist-editor-select.js +71 -12
  21. package/dist/src/editors/ox-grist-editor-select.js.map +1 -1
  22. package/dist/src/editors/ox-grist-editor.js +15 -13
  23. package/dist/src/editors/ox-grist-editor.js.map +1 -1
  24. package/dist/src/types.d.ts +5 -0
  25. package/dist/src/types.js.map +1 -1
  26. package/dist/src/utils/field-value.d.ts +11 -0
  27. package/dist/src/utils/field-value.js +38 -0
  28. package/dist/src/utils/field-value.js.map +1 -0
  29. package/dist/test/data-integrity.test.d.ts +1 -0
  30. package/dist/test/data-integrity.test.js +145 -0
  31. package/dist/test/data-integrity.test.js.map +1 -0
  32. package/dist/test/edit-lifecycle.test.d.ts +2 -0
  33. package/dist/test/edit-lifecycle.test.js +270 -0
  34. package/dist/test/edit-lifecycle.test.js.map +1 -0
  35. package/dist/test/list-records.test.d.ts +1 -0
  36. package/dist/test/list-records.test.js +46 -0
  37. package/dist/test/list-records.test.js.map +1 -0
  38. package/dist/test/page-errors.d.ts +1 -0
  39. package/dist/test/page-errors.js +44 -0
  40. package/dist/test/page-errors.js.map +1 -0
  41. package/dist/test/paste-integrity.test.d.ts +1 -0
  42. package/dist/test/paste-integrity.test.js +163 -0
  43. package/dist/test/paste-integrity.test.js.map +1 -0
  44. package/dist/test/searchable-select.test.d.ts +1 -0
  45. package/dist/test/searchable-select.test.js +65 -0
  46. package/dist/test/searchable-select.test.js.map +1 -0
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +5 -5
  49. package/test/data-integrity.test.ts +150 -0
  50. package/test/edit-lifecycle.test.ts +302 -0
  51. package/test/list-records.test.ts +58 -0
  52. package/test/page-errors.ts +43 -0
  53. package/test/paste-integrity.test.ts +168 -0
  54. package/test/searchable-select.test.ts +77 -0
@@ -0,0 +1,270 @@
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 '../src/record-view/record-view.js';
6
+ import { RecordDelete } from '../src/handlers/record-delete.js';
7
+ import { failOnPageErrors } from './page-errors.js';
8
+ /*
9
+ * An edit waits while its column's validation runs (a server check, say). What happens to the rows meanwhile decides
10
+ * whether it still applies: selecting, refreshing and adding rows keep the row it was typed into, so it applies;
11
+ * deleting that row, undo and a reset replace it, so it does not. Typing the shown value again supersedes it. The
12
+ * edits here go through the real editors - typed into the input and committed the way leaving the cell commits.
13
+ */
14
+ const deferred = () => {
15
+ let resolve;
16
+ const promise = new Promise(done => (resolve = done));
17
+ return { promise, resolve };
18
+ };
19
+ const settle = (ms = 0) => new Promise(resolve => setTimeout(resolve, ms));
20
+ /* The title column waits for the validation the test hands it; `other` has none. */
21
+ let validating;
22
+ const columns = [
23
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
24
+ {
25
+ type: 'string',
26
+ name: 'title',
27
+ header: 'title',
28
+ record: { editable: true },
29
+ validation: () => validating !== null && validating !== void 0 ? validating : true
30
+ },
31
+ { type: 'string', name: 'other', header: 'other', record: { editable: true } }
32
+ ];
33
+ const mount = async (mode, records) => {
34
+ const el = await fixture(html `<ox-grist
35
+ style="height:300px"
36
+ .mode=${mode}
37
+ .config=${{ columns, rows: { appendable: true, selectable: { multiple: true } }, list: { fields: ['title'] } }}
38
+ .data=${{ records }}
39
+ ></ox-grist>`);
40
+ await idle(el);
41
+ return el;
42
+ };
43
+ const rows = (el) => el.grist.data.records;
44
+ /* `updateComplete` resolves false while an update set another one going (a list takes its records in `updated`). */
45
+ const idle = async (el) => {
46
+ while (!((await el.updateComplete) && (await el.grist.updateComplete)))
47
+ ;
48
+ };
49
+ /* Type into the editor of a field and commit it as leaving the cell does. */
50
+ const typeInto = async (editor, text) => {
51
+ await editor.updateComplete;
52
+ const input = editor.renderRoot.querySelector('input');
53
+ input.value = text;
54
+ input.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
55
+ input.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
56
+ editor.flush();
57
+ };
58
+ /* A grid cell: open its editor the way a double-click does, type, commit, close. */
59
+ const typeInGrid = async (el, row, name, text) => {
60
+ await idle(el);
61
+ const body = el.grist.renderRoot.querySelector('ox-grid-body');
62
+ const column = body.columns.filter((column) => !column.hidden).findIndex((column) => column.name === name);
63
+ body.startEditTarget(row, column);
64
+ await body.updateComplete;
65
+ const field = body.renderRoot.querySelector(`#cell-${row}-${column}`);
66
+ await field.updateComplete;
67
+ await typeInto(field.renderRoot.querySelector('*'), text);
68
+ body.resetEdit();
69
+ await body.updateComplete;
70
+ };
71
+ /*
72
+ * A list item or card: its record view, as `RecordViewHandler` opens it for that item and hands its changes to the
73
+ * item. Built here in place of the popup; it is the item's own child, so its changes reach the list the same way.
74
+ */
75
+ const typeInItem = async (el, index, name, text) => {
76
+ /* Anything may draw the list again before the next edit (a page attached on scroll, a selection). */
77
+ el.grist.requestUpdate();
78
+ await idle(el);
79
+ const items = el.grist.renderRoot.querySelectorAll('ox-record-partial, ox-record-card');
80
+ const item = items[index];
81
+ const view = document.createElement('ox-record-view');
82
+ Object.assign(view, { columns: el.compiledConfig.columns, record: item.record, rowIndex: item.rowIndex });
83
+ item.appendChild(view);
84
+ await view.updateComplete;
85
+ const body = view.renderRoot.querySelector('ox-record-view-body');
86
+ await body.updateComplete;
87
+ const field = Array.from(body.renderRoot.querySelectorAll('ox-grid-field')).find(one => { var _a; return ((_a = one.column) === null || _a === void 0 ? void 0 : _a.name) === name; });
88
+ field.editing = true;
89
+ await field.updateComplete;
90
+ await typeInto(field.renderRoot.querySelector('*'), text);
91
+ view.remove();
92
+ };
93
+ describe('an edit waiting for validation', () => {
94
+ failOnPageErrors();
95
+ afterEach(() => {
96
+ validating = undefined;
97
+ });
98
+ it('applies after another field of the row was edited meanwhile', async () => {
99
+ const el = await mount('GRID', [{ id: '1', title: 'A', other: 'x' }]);
100
+ const pending = deferred();
101
+ validating = pending.promise;
102
+ await typeInGrid(el, 0, 'title', 'checked');
103
+ validating = undefined;
104
+ await typeInGrid(el, 0, 'other', 'y');
105
+ pending.resolve(true);
106
+ await settle();
107
+ expect(rows(el)[0]).to.include({ title: 'checked', other: 'y' });
108
+ });
109
+ it('applies after rows were selected, which rebuilds the rows around the same records', async () => {
110
+ const el = await mount('GRID', [
111
+ { id: '1', title: 'A' },
112
+ { id: '2', title: 'B' }
113
+ ]);
114
+ const pending = deferred();
115
+ validating = pending.promise;
116
+ await typeInGrid(el, 0, 'title', 'checked');
117
+ const before = rows(el);
118
+ el.select(record => record.id === '2');
119
+ await idle(el);
120
+ expect(rows(el) !== before).to.equal(true);
121
+ pending.resolve(true);
122
+ await settle();
123
+ expect(rows(el)[0].title).to.equal('checked');
124
+ expect(rows(el)[1].title).to.equal('B');
125
+ });
126
+ it('applies to its row after a row was added on top', async () => {
127
+ const el = await mount('GRID', [{ id: '1', title: 'A' }]);
128
+ const pending = deferred();
129
+ validating = pending.promise;
130
+ await typeInGrid(el, 0, 'title', 'checked');
131
+ el.addRecordToTop({ title: 'top' });
132
+ await idle(el);
133
+ pending.resolve(true);
134
+ await settle();
135
+ expect(rows(el).map(record => record.title)).to.eql(['top', 'checked']);
136
+ });
137
+ it('is superseded by typing the shown value again', async () => {
138
+ const el = await mount('GRID', [{ id: '1', title: 'A' }]);
139
+ const pending = deferred();
140
+ validating = pending.promise;
141
+ await typeInGrid(el, 0, 'title', 'mistake');
142
+ validating = undefined;
143
+ await typeInGrid(el, 0, 'title', 'A');
144
+ pending.resolve(true);
145
+ await settle();
146
+ expect(rows(el)[0].title).to.equal('A');
147
+ expect(el.dirtyRecords).to.have.length(0);
148
+ });
149
+ it('does not apply to a row deleted meanwhile', async () => {
150
+ const el = await mount('GRID', [
151
+ { id: '1', title: 'A' },
152
+ { id: '2', title: 'B' }
153
+ ]);
154
+ const pending = deferred();
155
+ validating = pending.promise;
156
+ await typeInGrid(el, 1, 'title', 'checked');
157
+ const record = rows(el)[1];
158
+ const field = el.grist.renderRoot.querySelector('ox-grid-body').renderRoot.querySelector('#cell-1-1');
159
+ RecordDelete(el.compiledConfig.columns, el.grist.data, field.column, record, 1, field);
160
+ pending.resolve(true);
161
+ await settle();
162
+ expect(rows(el).map(record => record.title)).to.eql(['A']);
163
+ expect(record.title).to.equal('B');
164
+ });
165
+ it('does not apply after undo, and an edit after undo does', async () => {
166
+ const el = await mount('GRID', [{ id: '1', title: 'A' }]);
167
+ /* Snapshots for undo are taken at most once a second, by one timer for every grid on the page. */
168
+ await settle(1100);
169
+ await typeInGrid(el, 0, 'other', 'first');
170
+ const pending = deferred();
171
+ validating = pending.promise;
172
+ await typeInGrid(el, 0, 'title', 'checked');
173
+ el.undo();
174
+ await idle(el);
175
+ pending.resolve(true);
176
+ await settle();
177
+ expect(rows(el)[0]).to.include({ title: 'A' });
178
+ expect(rows(el)[0].other).to.equal(undefined);
179
+ validating = undefined;
180
+ await typeInGrid(el, 0, 'title', 'after undo');
181
+ expect(rows(el)[0].title).to.equal('after undo');
182
+ }).timeout(5000);
183
+ it('does not apply after a reset', async () => {
184
+ const el = await mount('GRID', [{ id: '1', title: 'A' }]);
185
+ const pending = deferred();
186
+ validating = pending.promise;
187
+ await typeInGrid(el, 1, 'title', 'new row');
188
+ el.reset();
189
+ await idle(el);
190
+ pending.resolve(true);
191
+ await settle();
192
+ expect(rows(el).map(record => record.title)).to.eql(['A']);
193
+ });
194
+ });
195
+ /* The owner replacing the rows: a new row still being validated was typed into rows that are gone. */
196
+ describe('a new row waiting for validation', () => {
197
+ failOnPageErrors();
198
+ afterEach(() => {
199
+ validating = undefined;
200
+ });
201
+ /* [name, what comes before the edit, the replacement] */
202
+ const replacements = [
203
+ ['undo', () => { }, el => el.undo()],
204
+ ['redo', el => el.undo(), el => el.redo()],
205
+ ['a restored draft', () => { }, el => el.restoreUnsavedDraft({ records: [{ id: '1', title: 'draft' }] }, null)]
206
+ ];
207
+ for (const [name, before, replace] of replacements) {
208
+ it(`is not added after ${name}`, async () => {
209
+ const el = await mount('GRID', [{ id: '1', title: 'A' }]);
210
+ /* Snapshots for undo are taken at most once a second, by one timer for every grid on the page. */
211
+ await settle(1100);
212
+ await typeInGrid(el, 0, 'other', 'first');
213
+ before(el);
214
+ await idle(el);
215
+ const pending = deferred();
216
+ validating = pending.promise;
217
+ await typeInGrid(el, 1, 'title', 'new row');
218
+ replace(el);
219
+ await idle(el);
220
+ pending.resolve(true);
221
+ await settle();
222
+ expect(rows(el)).to.have.length(1);
223
+ }).timeout(5000);
224
+ }
225
+ });
226
+ for (const mode of ['GRID', 'LIST', 'CARD']) {
227
+ describe(`the append row of a ${mode}`, () => {
228
+ failOnPageErrors();
229
+ afterEach(() => {
230
+ validating = undefined;
231
+ });
232
+ const type = (el, row, name, text) => mode === 'GRID' ? typeInGrid(el, row, name, text) : typeInItem(el, row, name, text);
233
+ it('takes a field still being validated and one typed meanwhile into one new row', async () => {
234
+ const el = await mount(mode, [{ id: '1', title: 'A' }]);
235
+ const pending = deferred();
236
+ validating = pending.promise;
237
+ await type(el, 1, 'title', 'new');
238
+ validating = undefined;
239
+ await type(el, 1, 'other', 'meanwhile');
240
+ pending.resolve(true);
241
+ await settle();
242
+ await idle(el);
243
+ expect(rows(el)).to.have.length(2);
244
+ expect(rows(el)[1]).to.include({ title: 'new', other: 'meanwhile', __dirty__: '+' });
245
+ expect(el.exportPatchList({})).to.eql([{ patchFlag: '+', title: 'new', other: 'meanwhile' }]);
246
+ });
247
+ it('offers a fresh empty row once its row was added', async () => {
248
+ const el = await mount(mode, []);
249
+ await type(el, 0, 'title', 'first');
250
+ await idle(el);
251
+ await type(el, 1, 'title', 'second');
252
+ expect(rows(el).map(record => record.title)).to.eql(['first', 'second']);
253
+ });
254
+ it('is not added again when its new row was deleted while a field waited', async () => {
255
+ const el = await mount(mode, []);
256
+ const pending = deferred();
257
+ validating = pending.promise;
258
+ await type(el, 0, 'title', 'waits');
259
+ validating = undefined;
260
+ await type(el, 0, 'other', 'adds the row');
261
+ await idle(el);
262
+ /* Resetting a new row removes it (`record-reset` of a row that has no origin). */
263
+ el.grist.onRecordChanged(undefined, 0, null);
264
+ pending.resolve(true);
265
+ await settle();
266
+ expect(rows(el)).to.have.length(0);
267
+ });
268
+ });
269
+ }
270
+ //# sourceMappingURL=edit-lifecycle.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-lifecycle.test.js","sourceRoot":"","sources":["../../test/edit-lifecycle.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;AAC7B,OAAO,mCAAmC,CAAA;AAG1C,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;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,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;QAC1E,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;YACpF,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;YAChC,MAAM,OAAO,GAAG,QAAQ,EAAE,CAAA;YAC1B,UAAU,GAAG,OAAO,CAAC,OAAO,CAAA;YAC5B,MAAM,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;YACnC,UAAU,GAAG,SAAS,CAAA;YACtB,MAAM,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC,CAAA;YAC1C,MAAM,IAAI,CAAC,EAAE,CAAC,CAAA;YACd,kFAAkF;YAClF,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,SAAgB,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;YACnD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YACrB,MAAM,MAAM,EAAE,CAAA;YACd,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QACpC,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 '../src/record-view/record-view.js'\nimport { DataGrist } from '../src/data-grist.js'\nimport { OxGristEditor } from '../src/editors/ox-grist-editor.js'\nimport { RecordDelete } from '../src/handlers/record-delete.js'\nimport { failOnPageErrors } from './page-errors.js'\n\n/*\n * An edit waits while its column's validation runs (a server check, say). What happens to the rows meanwhile decides\n * whether it still applies: selecting, refreshing and adding rows keep the row it was typed into, so it applies;\n * deleting that row, undo and a reset replace it, so it does not. Typing the shown value again supersedes it. The\n * edits here go through the real editors - typed into the input and committed the way leaving the cell commits.\n */\n\nconst deferred = () => {\n let resolve!: (value: boolean) => void\n const promise = new Promise<boolean>(done => (resolve = done))\n return { promise, resolve }\n}\nconst settle = (ms = 0) => new Promise(resolve => setTimeout(resolve, ms))\n\n/* The title column waits for the validation the test hands it; `other` has none. */\nlet validating: Promise<boolean> | undefined\nconst columns = [\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'string',\n name: 'title',\n header: 'title',\n record: { editable: true },\n validation: () => validating ?? true\n },\n { type: 'string', name: 'other', header: 'other', record: { editable: true } }\n]\n\nconst mount = async (mode: 'GRID' | 'LIST' | 'CARD', records: any[]) => {\n const el = await fixture<DataGrist>(html`<ox-grist\n style=\"height:300px\"\n .mode=${mode}\n .config=${{ columns, rows: { appendable: true, selectable: { multiple: true } }, list: { fields: ['title'] } }}\n .data=${{ records }}\n ></ox-grist>`)\n await idle(el)\n return el\n}\n\nconst rows = (el: DataGrist) => el.grist.data.records\n\n/* `updateComplete` resolves false while an update set another one going (a list takes its records in `updated`). */\nconst idle = async (el: DataGrist) => {\n while (!((await el.updateComplete) && (await el.grist.updateComplete)));\n}\n\n/* Type into the editor of a field and commit it as leaving the cell does. */\nconst typeInto = async (editor: OxGristEditor, text: string) => {\n await editor.updateComplete\n const input = editor.renderRoot.querySelector('input') as HTMLInputElement\n input.value = text\n input.dispatchEvent(new Event('input', { bubbles: true, composed: true }))\n input.dispatchEvent(new Event('change', { bubbles: true, composed: true }))\n editor.flush()\n}\n\n/* A grid cell: open its editor the way a double-click does, type, commit, close. */\nconst typeInGrid = async (el: DataGrist, row: number, name: string, text: string) => {\n await idle(el)\n const body = el.grist.renderRoot.querySelector('ox-grid-body') as any\n const column = body.columns.filter((column: any) => !column.hidden).findIndex((column: any) => column.name === name)\n body.startEditTarget(row, column)\n await body.updateComplete\n const field = body.renderRoot.querySelector(`#cell-${row}-${column}`) as any\n await field.updateComplete\n await typeInto(field.renderRoot.querySelector('*') as OxGristEditor, text)\n body.resetEdit()\n await body.updateComplete\n}\n\n/*\n * A list item or card: its record view, as `RecordViewHandler` opens it for that item and hands its changes to the\n * item. Built here in place of the popup; it is the item's own child, so its changes reach the list the same way.\n */\nconst typeInItem = async (el: DataGrist, index: number, name: string, text: string) => {\n /* Anything may draw the list again before the next edit (a page attached on scroll, a selection). */\n el.grist.requestUpdate()\n await idle(el)\n const items = el.grist.renderRoot.querySelectorAll('ox-record-partial, ox-record-card')\n const item = items[index] as any\n const view = document.createElement('ox-record-view') as any\n Object.assign(view, { columns: el.compiledConfig.columns, record: item.record, rowIndex: item.rowIndex })\n item.appendChild(view)\n await view.updateComplete\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(\n one => one.column?.name === name\n )\n field.editing = true\n await field.updateComplete\n await typeInto(field.renderRoot.querySelector('*') as OxGristEditor, text)\n view.remove()\n}\n\ndescribe('an edit waiting for validation', () => {\n failOnPageErrors()\n\n afterEach(() => {\n validating = undefined\n })\n\n it('applies after another field of the row was edited meanwhile', async () => {\n const el = await mount('GRID', [{ id: '1', title: 'A', other: 'x' }])\n const pending = deferred()\n validating = pending.promise\n await typeInGrid(el, 0, 'title', 'checked')\n validating = undefined\n await typeInGrid(el, 0, 'other', 'y')\n pending.resolve(true)\n await settle()\n expect(rows(el)[0]).to.include({ title: 'checked', other: 'y' })\n })\n\n it('applies after rows were selected, which rebuilds the rows around the same records', async () => {\n const el = await mount('GRID', [\n { id: '1', title: 'A' },\n { id: '2', title: 'B' }\n ])\n const pending = deferred()\n validating = pending.promise\n await typeInGrid(el, 0, 'title', 'checked')\n const before = rows(el)\n el.select(record => record.id === '2')\n await idle(el)\n expect(rows(el) !== before).to.equal(true)\n pending.resolve(true)\n await settle()\n expect(rows(el)[0].title).to.equal('checked')\n expect(rows(el)[1].title).to.equal('B')\n })\n\n it('applies to its row after a row was added on top', async () => {\n const el = await mount('GRID', [{ id: '1', title: 'A' }])\n const pending = deferred()\n validating = pending.promise\n await typeInGrid(el, 0, 'title', 'checked')\n el.addRecordToTop({ title: 'top' })\n await idle(el)\n pending.resolve(true)\n await settle()\n expect(rows(el).map(record => record.title)).to.eql(['top', 'checked'])\n })\n\n it('is superseded by typing the shown value again', async () => {\n const el = await mount('GRID', [{ id: '1', title: 'A' }])\n const pending = deferred()\n validating = pending.promise\n await typeInGrid(el, 0, 'title', 'mistake')\n validating = undefined\n await typeInGrid(el, 0, 'title', 'A')\n pending.resolve(true)\n await settle()\n expect(rows(el)[0].title).to.equal('A')\n expect(el.dirtyRecords).to.have.length(0)\n })\n\n it('does not apply to a row deleted meanwhile', async () => {\n const el = await mount('GRID', [\n { id: '1', title: 'A' },\n { id: '2', title: 'B' }\n ])\n const pending = deferred()\n validating = pending.promise\n await typeInGrid(el, 1, 'title', 'checked')\n const record = rows(el)[1]\n const field = (el.grist.renderRoot.querySelector('ox-grid-body') as any).renderRoot.querySelector('#cell-1-1')\n RecordDelete(el.compiledConfig.columns, el.grist.data, field.column, record, 1, field)\n pending.resolve(true)\n await settle()\n expect(rows(el).map(record => record.title)).to.eql(['A'])\n expect(record.title).to.equal('B')\n })\n\n it('does not apply after undo, and an edit after undo does', async () => {\n const el = await mount('GRID', [{ id: '1', title: 'A' }])\n /* Snapshots for undo are taken at most once a second, by one timer for every grid on the page. */\n await settle(1100)\n await typeInGrid(el, 0, 'other', 'first')\n const pending = deferred()\n validating = pending.promise\n await typeInGrid(el, 0, 'title', 'checked')\n el.undo()\n await idle(el)\n pending.resolve(true)\n await settle()\n expect(rows(el)[0]).to.include({ title: 'A' })\n expect(rows(el)[0].other).to.equal(undefined)\n validating = undefined\n await typeInGrid(el, 0, 'title', 'after undo')\n expect(rows(el)[0].title).to.equal('after undo')\n }).timeout(5000)\n\n it('does not apply after a reset', async () => {\n const el = await mount('GRID', [{ id: '1', title: 'A' }])\n const pending = deferred()\n validating = pending.promise\n await typeInGrid(el, 1, 'title', 'new row')\n el.reset()\n await idle(el)\n pending.resolve(true)\n await settle()\n expect(rows(el).map(record => record.title)).to.eql(['A'])\n })\n})\n\n/* The owner replacing the rows: a new row still being validated was typed into rows that are gone. */\ndescribe('a new row waiting for validation', () => {\n failOnPageErrors()\n\n afterEach(() => {\n validating = undefined\n })\n\n /* [name, what comes before the edit, the replacement] */\n const replacements: [string, (el: DataGrist) => void, (el: DataGrist) => void][] = [\n ['undo', () => {}, el => el.undo()],\n ['redo', el => el.undo(), el => el.redo()],\n ['a restored draft', () => {}, el => el.restoreUnsavedDraft({ records: [{ id: '1', title: 'draft' }] }, null)]\n ]\n\n for (const [name, before, replace] of replacements) {\n it(`is not added after ${name}`, async () => {\n const el = await mount('GRID', [{ id: '1', title: 'A' }])\n /* Snapshots for undo are taken at most once a second, by one timer for every grid on the page. */\n await settle(1100)\n await typeInGrid(el, 0, 'other', 'first')\n before(el)\n await idle(el)\n const pending = deferred()\n validating = pending.promise\n await typeInGrid(el, 1, 'title', 'new row')\n replace(el)\n await idle(el)\n pending.resolve(true)\n await settle()\n expect(rows(el)).to.have.length(1)\n }).timeout(5000)\n }\n})\n\nfor (const mode of ['GRID', 'LIST', 'CARD'] as const) {\n describe(`the append row of a ${mode}`, () => {\n failOnPageErrors()\n\n afterEach(() => {\n validating = undefined\n })\n\n const type = (el: DataGrist, row: number, name: string, text: string) =>\n mode === 'GRID' ? typeInGrid(el, row, name, text) : typeInItem(el, row, name, text)\n\n it('takes a field still being validated and one typed meanwhile into one new row', async () => {\n const el = await mount(mode, [{ id: '1', title: 'A' }])\n const pending = deferred()\n validating = pending.promise\n await type(el, 1, 'title', 'new')\n validating = undefined\n await type(el, 1, 'other', 'meanwhile')\n pending.resolve(true)\n await settle()\n await idle(el)\n expect(rows(el)).to.have.length(2)\n expect(rows(el)[1]).to.include({ title: 'new', other: 'meanwhile', __dirty__: '+' })\n expect(el.exportPatchList({})).to.eql([{ patchFlag: '+', title: 'new', other: 'meanwhile' }])\n })\n\n it('offers a fresh empty row once its row was added', async () => {\n const el = await mount(mode, [])\n await type(el, 0, 'title', 'first')\n await idle(el)\n await type(el, 1, 'title', 'second')\n expect(rows(el).map(record => record.title)).to.eql(['first', 'second'])\n })\n\n it('is not added again when its new row was deleted while a field waited', async () => {\n const el = await mount(mode, [])\n const pending = deferred()\n validating = pending.promise\n await type(el, 0, 'title', 'waits')\n validating = undefined\n await type(el, 0, 'other', 'adds the row')\n await idle(el)\n /* Resetting a new row removes it (`record-reset` of a row that has no origin). */\n el.grist.onRecordChanged(undefined as any, 0, null)\n pending.resolve(true)\n await settle()\n expect(rows(el)).to.have.length(0)\n })\n })\n}\n"]}
@@ -0,0 +1 @@
1
+ import '../src/data-grist.js';
@@ -0,0 +1,46 @@
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
@@ -0,0 +1 @@
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;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O,EAAE,cAAc,CAC/G,CAAA;YACD,MAAM,IAAI,CAAC,EAAE,CAAC,CAAA;YACd,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;YAC7B,MAAM,IAAI,CAAC,EAAE,CAAC,CAAA;YACd,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,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"]}
@@ -0,0 +1 @@
1
+ export declare function failOnPageErrors(): void;
@@ -0,0 +1,44 @@
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
+ //# source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AC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;IACpF,CAAC,CAAC,CAAA;IACF,KAAK,CAAC,GAAG,EAAE;QACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QAClD,MAAM,CAAC,mBAAmB,CAAC,oBAAoB,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"]}
@@ -0,0 +1 @@
1
+ import '../src/data-grist.js';
@@ -0,0 +1,163 @@
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