@atlaskit/editor-plugin-table 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/cjs/plugins/table/event-handlers.js +7 -6
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +4 -4
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
- package/dist/cjs/plugins/table/utils/column-controls.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/event-handlers.js +8 -7
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +3 -4
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
- package/dist/es2019/plugins/table/utils/column-controls.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/event-handlers.js +8 -7
- package/dist/esm/plugins/table/nodeviews/tableCell.js +3 -4
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/column-state.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +8 -3
- package/dist/esm/plugins/table/utils/column-controls.js +1 -1
- package/dist/esm/version.json +1 -1
- package/package.json +4 -2
- package/src/__tests__/unit/analytics.ts +737 -0
- package/src/__tests__/unit/collab.ts +76 -0
- package/src/__tests__/unit/commands/sort.ts +230 -0
- package/src/__tests__/unit/copy-paste.ts +686 -0
- package/src/__tests__/unit/event-handlers/index.ts +106 -0
- package/src/__tests__/unit/event-handlers.ts +202 -0
- package/src/__tests__/unit/fix-tables.ts +156 -0
- package/src/__tests__/unit/floating-toolbar.ts +95 -0
- package/src/__tests__/unit/handlers.ts +81 -0
- package/src/__tests__/unit/hover-selection.ts +277 -0
- package/src/__tests__/unit/index-with-fake-timers.ts +106 -0
- package/src/__tests__/unit/index.ts +986 -0
- package/src/__tests__/unit/keymap.ts +602 -0
- package/src/__tests__/unit/layout.ts +196 -0
- package/src/__tests__/unit/nodeviews/cell.ts +167 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/utils/resize-state.ts +33 -0
- package/src/__tests__/unit/sort-column.ts +512 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +499 -0
- package/src/__tests__/unit/transforms/delete-rows.ts +557 -0
- package/src/__tests__/unit/transforms/merging.ts +374 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +80 -0
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +95 -0
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +175 -0
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +266 -0
- package/src/__tests__/unit/ui/RowControls.tsx +301 -0
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +93 -0
- package/src/__tests__/unit/undo-redo.ts +202 -0
- package/src/__tests__/unit/utils/dom.ts +286 -0
- package/src/__tests__/unit/utils/nodes.ts +59 -0
- package/src/__tests__/unit/utils/row-controls.ts +176 -0
- package/src/__tests__/unit/utils/table.ts +93 -0
- package/src/__tests__/unit/utils.ts +652 -0
- package/src/plugins/table/event-handlers.ts +5 -6
- package/src/plugins/table/nodeviews/tableCell.tsx +5 -4
- package/src/plugins/table/pm-plugins/table-resizing/utils/column-state.ts +1 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/resize-logic.ts +6 -2
- package/src/plugins/table/utils/column-controls.ts +1 -1
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
2
|
+
import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
3
|
+
import {
|
|
4
|
+
doc,
|
|
5
|
+
p,
|
|
6
|
+
table,
|
|
7
|
+
tr,
|
|
8
|
+
thEmpty,
|
|
9
|
+
tdEmpty,
|
|
10
|
+
tdCursor,
|
|
11
|
+
td,
|
|
12
|
+
DocBuilder,
|
|
13
|
+
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
14
|
+
import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
15
|
+
import { B50 } from '@atlaskit/theme/colors';
|
|
16
|
+
|
|
17
|
+
import { TablePluginState, PluginConfig } from '../../plugins/table/types';
|
|
18
|
+
import {
|
|
19
|
+
deleteTableWithAnalytics,
|
|
20
|
+
emptyMultipleCellsWithAnalytics,
|
|
21
|
+
mergeCellsWithAnalytics,
|
|
22
|
+
splitCellWithAnalytics,
|
|
23
|
+
setColorWithAnalytics,
|
|
24
|
+
toggleHeaderRowWithAnalytics,
|
|
25
|
+
toggleHeaderColumnWithAnalytics,
|
|
26
|
+
toggleNumberColumnWithAnalytics,
|
|
27
|
+
toggleTableLayoutWithAnalytics,
|
|
28
|
+
insertRowWithAnalytics,
|
|
29
|
+
insertColumnWithAnalytics,
|
|
30
|
+
deleteRowsWithAnalytics,
|
|
31
|
+
deleteColumnsWithAnalytics,
|
|
32
|
+
deleteTableIfSelectedWithAnalytics,
|
|
33
|
+
} from '../../plugins/table/commands-with-analytics';
|
|
34
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
35
|
+
import { handleCut } from '../../plugins/table/event-handlers';
|
|
36
|
+
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
37
|
+
import { replaceSelectedTable } from '../../plugins/table/transforms';
|
|
38
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
39
|
+
import tablePlugin from '../../plugins/table-plugin';
|
|
40
|
+
|
|
41
|
+
const defaultTable = table()(
|
|
42
|
+
tr(thEmpty, thEmpty, thEmpty),
|
|
43
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
44
|
+
tr(tdEmpty, tdEmpty, tdCursor),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const secondRow: Rect = { left: 0, top: 1, bottom: 2, right: 3 };
|
|
48
|
+
const secondColumn: Rect = { left: 1, top: 0, bottom: 3, right: 2 };
|
|
49
|
+
|
|
50
|
+
describe('Table analytic events', () => {
|
|
51
|
+
let editorAnalyticsAPIFake: EditorAnalyticsAPI;
|
|
52
|
+
const analyticFireMock = jest.fn().mockReturnValue(jest.fn());
|
|
53
|
+
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
editorAnalyticsAPIFake = {
|
|
56
|
+
attachAnalyticsEvent: analyticFireMock,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const createEditor = createEditorFactory<TablePluginState>();
|
|
61
|
+
|
|
62
|
+
const editor = (doc: DocBuilder) => {
|
|
63
|
+
const tableOptions = {
|
|
64
|
+
allowNumberColumn: true,
|
|
65
|
+
allowHeaderRow: true,
|
|
66
|
+
allowHeaderColumn: true,
|
|
67
|
+
permittedLayouts: 'all',
|
|
68
|
+
} as PluginConfig;
|
|
69
|
+
|
|
70
|
+
const _editor = createEditor({
|
|
71
|
+
doc,
|
|
72
|
+
editorProps: {
|
|
73
|
+
allowTables: false,
|
|
74
|
+
allowAnalyticsGASV3: true,
|
|
75
|
+
appearance: 'full-page',
|
|
76
|
+
quickInsert: true,
|
|
77
|
+
dangerouslyAppendPlugins: {
|
|
78
|
+
__plugins: [
|
|
79
|
+
tablePlugin({
|
|
80
|
+
tableOptions,
|
|
81
|
+
editorAnalyticsAPI: editorAnalyticsAPIFake,
|
|
82
|
+
}),
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
pluginKey,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return _editor;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
describe('table inserted via quickInsert', () => {
|
|
93
|
+
beforeEach(async () => {
|
|
94
|
+
const { typeAheadTool } = editor(doc(p('{<>}')));
|
|
95
|
+
typeAheadTool.searchQuickInsert('Table').insert({ index: 0 });
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should fire v3 analytics', () => {
|
|
99
|
+
expect(analyticFireMock).toBeCalledWith({
|
|
100
|
+
action: 'inserted',
|
|
101
|
+
actionSubject: 'document',
|
|
102
|
+
actionSubjectId: 'table',
|
|
103
|
+
attributes: expect.objectContaining({ inputMethod: 'quickInsert' }),
|
|
104
|
+
eventType: 'track',
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('table deleted', () => {
|
|
110
|
+
beforeEach(() => {
|
|
111
|
+
const { editorView } = editor(doc(defaultTable));
|
|
112
|
+
deleteTableWithAnalytics(editorAnalyticsAPIFake)(
|
|
113
|
+
editorView.state,
|
|
114
|
+
editorView.dispatch,
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should fire v3 analytics', () => {
|
|
119
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
120
|
+
action: 'deleted',
|
|
121
|
+
actionSubject: 'table',
|
|
122
|
+
attributes: expect.objectContaining({
|
|
123
|
+
inputMethod: 'floatingToolbar',
|
|
124
|
+
totalRowCount: 3,
|
|
125
|
+
totalColumnCount: 3,
|
|
126
|
+
}),
|
|
127
|
+
eventType: 'track',
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe('table deleted if selected', () => {
|
|
133
|
+
beforeEach(() => {
|
|
134
|
+
const { editorView } = editor(
|
|
135
|
+
doc(
|
|
136
|
+
table()(
|
|
137
|
+
tr(td()(p('{<cell}1')), td()(p('2'))),
|
|
138
|
+
tr(td()(p('3')), td()(p('4{cell>}'))),
|
|
139
|
+
),
|
|
140
|
+
),
|
|
141
|
+
);
|
|
142
|
+
deleteTableIfSelectedWithAnalytics(editorAnalyticsAPIFake)(
|
|
143
|
+
INPUT_METHOD.KEYBOARD,
|
|
144
|
+
)(editorView.state, editorView.dispatch);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should fire v3 analytics', () => {
|
|
148
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
149
|
+
action: 'deleted',
|
|
150
|
+
actionSubject: 'table',
|
|
151
|
+
attributes: expect.objectContaining({
|
|
152
|
+
inputMethod: 'keyboard',
|
|
153
|
+
totalRowCount: 2,
|
|
154
|
+
totalColumnCount: 2,
|
|
155
|
+
}),
|
|
156
|
+
eventType: 'track',
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe('table cleared', () => {
|
|
162
|
+
describe('context menu', () => {
|
|
163
|
+
beforeEach(() => {
|
|
164
|
+
const { editorView } = editor(
|
|
165
|
+
doc(
|
|
166
|
+
table()(
|
|
167
|
+
tr(thEmpty, td()(p('{<cell}Hello')), thEmpty),
|
|
168
|
+
tr(td()(p('Hello')), tdEmpty, tdEmpty),
|
|
169
|
+
tr(tdEmpty, td()(p('{cell>}')), tdEmpty),
|
|
170
|
+
),
|
|
171
|
+
),
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
emptyMultipleCellsWithAnalytics(editorAnalyticsAPIFake)(
|
|
175
|
+
INPUT_METHOD.CONTEXT_MENU,
|
|
176
|
+
)(editorView.state, editorView.dispatch);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('should fire v3 analytics', () => {
|
|
180
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
181
|
+
action: 'cleared',
|
|
182
|
+
actionSubject: 'table',
|
|
183
|
+
actionSubjectId: null,
|
|
184
|
+
attributes: expect.objectContaining({
|
|
185
|
+
inputMethod: 'contextMenu',
|
|
186
|
+
verticalCells: 3,
|
|
187
|
+
horizontalCells: 1,
|
|
188
|
+
totalRowCount: 3,
|
|
189
|
+
totalColumnCount: 3,
|
|
190
|
+
}),
|
|
191
|
+
eventType: 'track',
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
describe('keyboard - Backspace', () => {
|
|
197
|
+
beforeEach(() => {
|
|
198
|
+
const { editorView } = editor(
|
|
199
|
+
doc(
|
|
200
|
+
table()(
|
|
201
|
+
tr(thEmpty, td()(p('Hello')), thEmpty),
|
|
202
|
+
tr(td()(p('{<cell}Hello')), tdEmpty, td()(p('{cell>}'))),
|
|
203
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
204
|
+
),
|
|
205
|
+
),
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
sendKeyToPm(editorView, 'Backspace');
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('should fire v3 analytics', () => {
|
|
212
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
213
|
+
action: 'cleared',
|
|
214
|
+
actionSubject: 'table',
|
|
215
|
+
actionSubjectId: null,
|
|
216
|
+
attributes: expect.objectContaining({
|
|
217
|
+
inputMethod: 'keyboard',
|
|
218
|
+
verticalCells: 1,
|
|
219
|
+
horizontalCells: 3,
|
|
220
|
+
totalRowCount: 3,
|
|
221
|
+
totalColumnCount: 3,
|
|
222
|
+
}),
|
|
223
|
+
eventType: 'track',
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe('cells merged', () => {
|
|
230
|
+
beforeEach(() => {
|
|
231
|
+
const { editorView } = editor(
|
|
232
|
+
doc(
|
|
233
|
+
table()(
|
|
234
|
+
tr(thEmpty, td()(p('{<cell}Hello')), thEmpty),
|
|
235
|
+
tr(td()(p('Hello')), tdEmpty, tdEmpty),
|
|
236
|
+
tr(tdEmpty, td()(p('{cell>}')), tdEmpty),
|
|
237
|
+
),
|
|
238
|
+
),
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
mergeCellsWithAnalytics(editorAnalyticsAPIFake)(
|
|
242
|
+
editorView.state,
|
|
243
|
+
editorView.dispatch,
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('should fire v3 analytics', () => {
|
|
248
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
249
|
+
action: 'merged',
|
|
250
|
+
actionSubject: 'table',
|
|
251
|
+
actionSubjectId: null,
|
|
252
|
+
attributes: expect.objectContaining({
|
|
253
|
+
verticalCells: 3,
|
|
254
|
+
horizontalCells: 1,
|
|
255
|
+
totalCells: 3,
|
|
256
|
+
totalRowCount: 3,
|
|
257
|
+
totalColumnCount: 3,
|
|
258
|
+
}),
|
|
259
|
+
eventType: 'track',
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
describe('cell split', () => {
|
|
265
|
+
beforeEach(() => {
|
|
266
|
+
const { editorView } = editor(
|
|
267
|
+
doc(
|
|
268
|
+
table()(
|
|
269
|
+
tr(thEmpty, thEmpty, thEmpty),
|
|
270
|
+
tr(td({ colspan: 3 })(p('{<>}'))),
|
|
271
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
272
|
+
),
|
|
273
|
+
),
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
splitCellWithAnalytics(editorAnalyticsAPIFake)(
|
|
277
|
+
editorView.state,
|
|
278
|
+
editorView.dispatch,
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('should fire v3 analytics', () => {
|
|
283
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
284
|
+
action: 'split',
|
|
285
|
+
actionSubject: 'table',
|
|
286
|
+
actionSubjectId: null,
|
|
287
|
+
attributes: expect.objectContaining({
|
|
288
|
+
verticalCells: 1,
|
|
289
|
+
horizontalCells: 3,
|
|
290
|
+
totalCells: 3,
|
|
291
|
+
totalRowCount: 3,
|
|
292
|
+
totalColumnCount: 3,
|
|
293
|
+
}),
|
|
294
|
+
eventType: 'track',
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
describe('cells colored', () => {
|
|
300
|
+
beforeEach(() => {
|
|
301
|
+
const { editorView } = editor(
|
|
302
|
+
doc(
|
|
303
|
+
table()(
|
|
304
|
+
tr(thEmpty, td()(p('Hello')), thEmpty),
|
|
305
|
+
tr(td()(p('{<cell}Hello')), tdEmpty, td()(p('{cell>}'))),
|
|
306
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
307
|
+
),
|
|
308
|
+
),
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
312
|
+
setColorWithAnalytics(editorAnalyticsAPIFake)(B50)(
|
|
313
|
+
editorView.state,
|
|
314
|
+
editorView.dispatch,
|
|
315
|
+
);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('should fire v3 analytics', () => {
|
|
319
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
320
|
+
action: 'colored',
|
|
321
|
+
actionSubject: 'table',
|
|
322
|
+
actionSubjectId: null,
|
|
323
|
+
attributes: expect.objectContaining({
|
|
324
|
+
cellColor: 'light blue',
|
|
325
|
+
verticalCells: 1,
|
|
326
|
+
horizontalCells: 3,
|
|
327
|
+
totalCells: 3,
|
|
328
|
+
totalRowCount: 3,
|
|
329
|
+
totalColumnCount: 3,
|
|
330
|
+
}),
|
|
331
|
+
eventType: 'track',
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
describe('header row toggled', () => {
|
|
337
|
+
beforeEach(() => {
|
|
338
|
+
const { editorView } = editor(defaultTable);
|
|
339
|
+
toggleHeaderRowWithAnalytics(editorAnalyticsAPIFake)(
|
|
340
|
+
editorView.state,
|
|
341
|
+
editorView.dispatch,
|
|
342
|
+
);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it('should fire v3 analytics', () => {
|
|
346
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
347
|
+
action: 'toggledHeaderRow',
|
|
348
|
+
actionSubject: 'table',
|
|
349
|
+
actionSubjectId: null,
|
|
350
|
+
attributes: expect.objectContaining({
|
|
351
|
+
newState: false,
|
|
352
|
+
totalRowCount: 3,
|
|
353
|
+
totalColumnCount: 3,
|
|
354
|
+
}),
|
|
355
|
+
eventType: 'track',
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
describe('header column toggled', () => {
|
|
361
|
+
beforeEach(() => {
|
|
362
|
+
const { editorView } = editor(defaultTable);
|
|
363
|
+
toggleHeaderColumnWithAnalytics(editorAnalyticsAPIFake)(
|
|
364
|
+
editorView.state,
|
|
365
|
+
editorView.dispatch,
|
|
366
|
+
);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('should fire v3 analytics', () => {
|
|
370
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
371
|
+
action: 'toggledHeaderColumn',
|
|
372
|
+
actionSubject: 'table',
|
|
373
|
+
actionSubjectId: null,
|
|
374
|
+
attributes: expect.objectContaining({
|
|
375
|
+
newState: true,
|
|
376
|
+
totalRowCount: 3,
|
|
377
|
+
totalColumnCount: 3,
|
|
378
|
+
}),
|
|
379
|
+
eventType: 'track',
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
describe('number column toggled', () => {
|
|
385
|
+
beforeEach(() => {
|
|
386
|
+
const { editorView } = editor(defaultTable);
|
|
387
|
+
toggleNumberColumnWithAnalytics(editorAnalyticsAPIFake)(
|
|
388
|
+
editorView.state,
|
|
389
|
+
editorView.dispatch,
|
|
390
|
+
);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it('should fire v3 analytics', () => {
|
|
394
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
395
|
+
action: 'toggledNumberColumn',
|
|
396
|
+
actionSubject: 'table',
|
|
397
|
+
actionSubjectId: null,
|
|
398
|
+
attributes: expect.objectContaining({
|
|
399
|
+
newState: true,
|
|
400
|
+
totalRowCount: 3,
|
|
401
|
+
totalColumnCount: 3,
|
|
402
|
+
}),
|
|
403
|
+
eventType: 'track',
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
describe('layout changed', () => {
|
|
409
|
+
describe('normal', () => {
|
|
410
|
+
it('should fire v3 analytics', () => {
|
|
411
|
+
const { editorView } = editor(defaultTable);
|
|
412
|
+
toggleTableLayoutWithAnalytics(editorAnalyticsAPIFake)(
|
|
413
|
+
editorView.state,
|
|
414
|
+
editorView.dispatch,
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
418
|
+
action: 'changedBreakoutMode',
|
|
419
|
+
actionSubject: 'table',
|
|
420
|
+
actionSubjectId: null,
|
|
421
|
+
attributes: expect.objectContaining({
|
|
422
|
+
newBreakoutMode: 'wide',
|
|
423
|
+
previousBreakoutMode: 'normal',
|
|
424
|
+
totalRowCount: 3,
|
|
425
|
+
totalColumnCount: 3,
|
|
426
|
+
}),
|
|
427
|
+
eventType: 'track',
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
describe('wide', () => {
|
|
433
|
+
it('should fire v3 analytics', () => {
|
|
434
|
+
const { editorView } = editor(
|
|
435
|
+
doc(
|
|
436
|
+
table({
|
|
437
|
+
layout: 'wide',
|
|
438
|
+
})(
|
|
439
|
+
tr(thEmpty, thEmpty, thEmpty),
|
|
440
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
441
|
+
tr(tdEmpty, tdEmpty, tdCursor),
|
|
442
|
+
),
|
|
443
|
+
),
|
|
444
|
+
);
|
|
445
|
+
toggleTableLayoutWithAnalytics(editorAnalyticsAPIFake)(
|
|
446
|
+
editorView.state,
|
|
447
|
+
editorView.dispatch,
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
451
|
+
action: 'changedBreakoutMode',
|
|
452
|
+
actionSubject: 'table',
|
|
453
|
+
actionSubjectId: null,
|
|
454
|
+
attributes: expect.objectContaining({
|
|
455
|
+
newBreakoutMode: 'fullWidth',
|
|
456
|
+
previousBreakoutMode: 'wide',
|
|
457
|
+
totalRowCount: 3,
|
|
458
|
+
totalColumnCount: 3,
|
|
459
|
+
}),
|
|
460
|
+
eventType: 'track',
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
describe('fullWidth', () => {
|
|
466
|
+
it('should fire v3 analytics', () => {
|
|
467
|
+
const { editorView } = editor(
|
|
468
|
+
doc(
|
|
469
|
+
table({ layout: 'full-width' })(
|
|
470
|
+
tr(thEmpty, thEmpty, thEmpty),
|
|
471
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
472
|
+
tr(tdEmpty, tdEmpty, tdCursor),
|
|
473
|
+
),
|
|
474
|
+
),
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
toggleTableLayoutWithAnalytics(editorAnalyticsAPIFake)(
|
|
478
|
+
editorView.state,
|
|
479
|
+
editorView.dispatch,
|
|
480
|
+
);
|
|
481
|
+
|
|
482
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
483
|
+
action: 'changedBreakoutMode',
|
|
484
|
+
actionSubject: 'table',
|
|
485
|
+
actionSubjectId: null,
|
|
486
|
+
attributes: expect.objectContaining({
|
|
487
|
+
newBreakoutMode: 'normal',
|
|
488
|
+
previousBreakoutMode: 'fullWidth',
|
|
489
|
+
totalRowCount: 3,
|
|
490
|
+
totalColumnCount: 3,
|
|
491
|
+
}),
|
|
492
|
+
eventType: 'track',
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
describe('cut something from table', () => {
|
|
499
|
+
beforeEach(() => {
|
|
500
|
+
const { editorView } = editor(
|
|
501
|
+
doc(
|
|
502
|
+
table()(
|
|
503
|
+
tr(thEmpty, td()(p('Hello')), thEmpty),
|
|
504
|
+
tr(td()(p('{<cell}Hello')), tdEmpty, td()(p('{cell>}'))),
|
|
505
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
506
|
+
),
|
|
507
|
+
),
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
editorView.dispatch(
|
|
511
|
+
handleCut(
|
|
512
|
+
editorView.state.tr,
|
|
513
|
+
editorView.state,
|
|
514
|
+
editorView.state,
|
|
515
|
+
editorAnalyticsAPIFake,
|
|
516
|
+
),
|
|
517
|
+
);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
it('should fire v3 analytics', () => {
|
|
521
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
522
|
+
action: 'cut',
|
|
523
|
+
actionSubject: 'table',
|
|
524
|
+
actionSubjectId: null,
|
|
525
|
+
attributes: expect.objectContaining({
|
|
526
|
+
verticalCells: 1,
|
|
527
|
+
horizontalCells: 3,
|
|
528
|
+
totalCells: 3,
|
|
529
|
+
totalRowCount: 3,
|
|
530
|
+
totalColumnCount: 3,
|
|
531
|
+
}),
|
|
532
|
+
eventType: 'track',
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
describe('row added', () => {
|
|
538
|
+
describe('context menu', () => {
|
|
539
|
+
beforeEach(() => {
|
|
540
|
+
const { editorView } = editor(defaultTable);
|
|
541
|
+
insertRowWithAnalytics(editorAnalyticsAPIFake)(
|
|
542
|
+
INPUT_METHOD.CONTEXT_MENU,
|
|
543
|
+
{
|
|
544
|
+
index: 2,
|
|
545
|
+
moveCursorToInsertedRow: false,
|
|
546
|
+
},
|
|
547
|
+
)(editorView.state, editorView.dispatch);
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
it('should fire v3 analytics', () => {
|
|
551
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
552
|
+
action: 'addedRow',
|
|
553
|
+
actionSubject: 'table',
|
|
554
|
+
actionSubjectId: null,
|
|
555
|
+
attributes: expect.objectContaining({
|
|
556
|
+
inputMethod: 'contextMenu',
|
|
557
|
+
position: 2,
|
|
558
|
+
totalRowCount: 3,
|
|
559
|
+
totalColumnCount: 3,
|
|
560
|
+
}),
|
|
561
|
+
eventType: 'track',
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
describe('keyboard', () => {
|
|
567
|
+
describe('Tab', () => {
|
|
568
|
+
beforeEach(() => {
|
|
569
|
+
const { editorView } = editor(defaultTable);
|
|
570
|
+
sendKeyToPm(editorView, 'Tab');
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
it('should fire v3 analytics', () => {
|
|
574
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
575
|
+
action: 'addedRow',
|
|
576
|
+
actionSubject: 'table',
|
|
577
|
+
actionSubjectId: null,
|
|
578
|
+
attributes: expect.objectContaining({
|
|
579
|
+
inputMethod: 'keyboard',
|
|
580
|
+
position: 3,
|
|
581
|
+
totalRowCount: 3,
|
|
582
|
+
totalColumnCount: 3,
|
|
583
|
+
}),
|
|
584
|
+
eventType: 'track',
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
describe('Shift-Tab', () => {
|
|
590
|
+
beforeEach(() => {
|
|
591
|
+
const { editorView } = editor(
|
|
592
|
+
doc(
|
|
593
|
+
table()(
|
|
594
|
+
tr(tdCursor, tdEmpty, tdEmpty),
|
|
595
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
596
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
597
|
+
),
|
|
598
|
+
),
|
|
599
|
+
);
|
|
600
|
+
sendKeyToPm(editorView, 'Shift-Tab');
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
it('should fire v3 analytics', () => {
|
|
604
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
605
|
+
action: 'addedRow',
|
|
606
|
+
actionSubject: 'table',
|
|
607
|
+
actionSubjectId: null,
|
|
608
|
+
attributes: expect.objectContaining({
|
|
609
|
+
inputMethod: 'keyboard',
|
|
610
|
+
position: 0,
|
|
611
|
+
totalRowCount: 3,
|
|
612
|
+
totalColumnCount: 3,
|
|
613
|
+
}),
|
|
614
|
+
eventType: 'track',
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
describe('column added', () => {
|
|
622
|
+
const getEditorContainerWidth = () => {
|
|
623
|
+
return { width: 500 };
|
|
624
|
+
};
|
|
625
|
+
beforeEach(() => {
|
|
626
|
+
const { editorView } = editor(defaultTable);
|
|
627
|
+
insertColumnWithAnalytics(
|
|
628
|
+
getEditorContainerWidth,
|
|
629
|
+
editorAnalyticsAPIFake,
|
|
630
|
+
)(INPUT_METHOD.CONTEXT_MENU, 2)(
|
|
631
|
+
editorView.state,
|
|
632
|
+
editorView.dispatch,
|
|
633
|
+
editorView,
|
|
634
|
+
);
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
it('should fire v3 analytics', () => {
|
|
638
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
639
|
+
action: 'addedColumn',
|
|
640
|
+
actionSubject: 'table',
|
|
641
|
+
actionSubjectId: null,
|
|
642
|
+
attributes: expect.objectContaining({
|
|
643
|
+
inputMethod: 'contextMenu',
|
|
644
|
+
position: 2,
|
|
645
|
+
totalRowCount: 3,
|
|
646
|
+
totalColumnCount: 3,
|
|
647
|
+
}),
|
|
648
|
+
eventType: 'track',
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
describe('row deleted', () => {
|
|
654
|
+
beforeEach(() => {
|
|
655
|
+
const { editorView } = editor(defaultTable);
|
|
656
|
+
deleteRowsWithAnalytics(editorAnalyticsAPIFake)(
|
|
657
|
+
INPUT_METHOD.CONTEXT_MENU,
|
|
658
|
+
secondRow,
|
|
659
|
+
true,
|
|
660
|
+
)(editorView.state, editorView.dispatch);
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
it('should fire v3 analytics', () => {
|
|
664
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
665
|
+
action: 'deletedRow',
|
|
666
|
+
actionSubject: 'table',
|
|
667
|
+
actionSubjectId: null,
|
|
668
|
+
attributes: expect.objectContaining({
|
|
669
|
+
inputMethod: 'contextMenu',
|
|
670
|
+
position: 1,
|
|
671
|
+
count: 1,
|
|
672
|
+
totalRowCount: 3,
|
|
673
|
+
totalColumnCount: 3,
|
|
674
|
+
}),
|
|
675
|
+
eventType: 'track',
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
describe('column deleted', () => {
|
|
681
|
+
beforeEach(() => {
|
|
682
|
+
const { editorView } = editor(defaultTable);
|
|
683
|
+
deleteColumnsWithAnalytics(editorAnalyticsAPIFake)(
|
|
684
|
+
INPUT_METHOD.CONTEXT_MENU,
|
|
685
|
+
secondColumn,
|
|
686
|
+
)(editorView.state, editorView.dispatch);
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
it('should fire v3 analytics', () => {
|
|
690
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
691
|
+
action: 'deletedColumn',
|
|
692
|
+
actionSubject: 'table',
|
|
693
|
+
actionSubjectId: null,
|
|
694
|
+
attributes: expect.objectContaining({
|
|
695
|
+
inputMethod: 'contextMenu',
|
|
696
|
+
position: 1,
|
|
697
|
+
count: 1,
|
|
698
|
+
totalRowCount: 3,
|
|
699
|
+
totalColumnCount: 3,
|
|
700
|
+
}),
|
|
701
|
+
eventType: 'track',
|
|
702
|
+
});
|
|
703
|
+
});
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
describe('table replaced', () => {
|
|
707
|
+
it('should fire v3 analytics', () => {
|
|
708
|
+
const { editorView } = editor(
|
|
709
|
+
doc(
|
|
710
|
+
table()(
|
|
711
|
+
tr(td()(p('{<cell}1')), td()(p('2'))),
|
|
712
|
+
tr(td()(p('3')), td()(p('4{cell>}'))),
|
|
713
|
+
),
|
|
714
|
+
),
|
|
715
|
+
);
|
|
716
|
+
editorView.dispatch(
|
|
717
|
+
replaceSelectedTable(
|
|
718
|
+
editorView.state,
|
|
719
|
+
'text',
|
|
720
|
+
INPUT_METHOD.KEYBOARD,
|
|
721
|
+
editorAnalyticsAPIFake,
|
|
722
|
+
),
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
expect(analyticFireMock).toHaveBeenCalledWith({
|
|
726
|
+
action: 'replaced',
|
|
727
|
+
actionSubject: 'table',
|
|
728
|
+
attributes: expect.objectContaining({
|
|
729
|
+
totalRowCount: 2,
|
|
730
|
+
totalColumnCount: 2,
|
|
731
|
+
inputMethod: 'keyboard',
|
|
732
|
+
}),
|
|
733
|
+
eventType: 'track',
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
});
|
|
737
|
+
});
|