@baselift/blocks-testing 0.0.1
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/README.md +177 -0
- package/dist/cjs/error_utils.js +56 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/inject_mock_airtable_interface.js +6 -0
- package/dist/cjs/mock_airtable_interface.js +851 -0
- package/dist/cjs/private_utils.js +78 -0
- package/dist/cjs/test_driver.js +658 -0
- package/dist/cjs/test_mutations.js +37 -0
- package/dist/cjs/vacant_airtable_interface.js +367 -0
- package/dist/types/src/error_utils.d.ts +11 -0
- package/dist/types/src/error_utils.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/inject_mock_airtable_interface.d.ts +2 -0
- package/dist/types/src/inject_mock_airtable_interface.d.ts.map +1 -0
- package/dist/types/src/mock_airtable_interface.d.ts +237 -0
- package/dist/types/src/mock_airtable_interface.d.ts.map +1 -0
- package/dist/types/src/private_utils.d.ts +33 -0
- package/dist/types/src/private_utils.d.ts.map +1 -0
- package/dist/types/src/test_driver.d.ts +450 -0
- package/dist/types/src/test_driver.d.ts.map +1 -0
- package/dist/types/src/test_mutations.d.ts +43 -0
- package/dist/types/src/test_mutations.d.ts.map +1 -0
- package/dist/types/src/vacant_airtable_interface.d.ts +2 -0
- package/dist/types/src/vacant_airtable_interface.d.ts.map +1 -0
- package/dist/types/test/index_compatible.test.d.ts +8 -0
- package/dist/types/test/index_compatible.test.d.ts.map +1 -0
- package/dist/types/test/index_incompatible.test.d.ts +2 -0
- package/dist/types/test/index_incompatible.test.d.ts.map +1 -0
- package/dist/types/test/mock_airtable_interface.test.d.ts +2 -0
- package/dist/types/test/mock_airtable_interface.test.d.ts.map +1 -0
- package/dist/types/test/mutation_types.test.d.ts +2 -0
- package/dist/types/test/mutation_types.test.d.ts.map +1 -0
- package/dist/types/test/package_json.test.d.ts +2 -0
- package/dist/types/test/package_json.test.d.ts.map +1 -0
- package/dist/types/test/test_driver.test.d.ts +2 -0
- package/dist/types/test/test_driver.test.d.ts.map +1 -0
- package/dist/types/test/untestable_bindings.test.d.ts +2 -0
- package/dist/types/test/untestable_bindings.test.d.ts.map +1 -0
- package/package.json +120 -0
- package/types/globals.d.ts +6 -0
|
@@ -0,0 +1,851 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
4
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
5
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
6
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
18
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
require("core-js/modules/es.symbol.js");
|
|
22
|
+
require("core-js/modules/es.symbol.description.js");
|
|
23
|
+
require("core-js/modules/es.array.concat.js");
|
|
24
|
+
require("core-js/modules/es.array.filter.js");
|
|
25
|
+
require("core-js/modules/es.array.from.js");
|
|
26
|
+
require("core-js/modules/es.array.includes.js");
|
|
27
|
+
require("core-js/modules/es.array.index-of.js");
|
|
28
|
+
require("core-js/modules/es.array.iterator.js");
|
|
29
|
+
require("core-js/modules/es.array.map.js");
|
|
30
|
+
require("core-js/modules/es.array.slice.js");
|
|
31
|
+
require("core-js/modules/es.array.splice.js");
|
|
32
|
+
require("core-js/modules/es.object.to-string.js");
|
|
33
|
+
require("core-js/modules/es.object.values.js");
|
|
34
|
+
require("core-js/modules/es.set.js");
|
|
35
|
+
require("core-js/modules/es.string.includes.js");
|
|
36
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
|
37
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
38
|
+
var _unstable_testing_utils = require("@baselift/blocks/unstable_testing_utils");
|
|
39
|
+
var _test_mutations = require("./test_mutations");
|
|
40
|
+
var _private_utils = require("./private_utils");
|
|
41
|
+
var _error_utils = require("./error_utils");
|
|
42
|
+
var _excluded = ["opts"];
|
|
43
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
44
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
45
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
46
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
47
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
48
|
+
function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
49
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
50
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
51
|
+
var MutationTypeValues = Object.freeze(Object.values(_unstable_testing_utils.MutationTypes));
|
|
52
|
+
var unmodifiableSdkData = {
|
|
53
|
+
isDevelopmentMode: false,
|
|
54
|
+
blockInstallationId: 'bliTESTING',
|
|
55
|
+
isFirstRun: false,
|
|
56
|
+
isFullscreen: false,
|
|
57
|
+
intentData: null
|
|
58
|
+
};
|
|
59
|
+
var unmodifiableBaseData = {
|
|
60
|
+
enabledFeatureNames: [],
|
|
61
|
+
billingPlanGrouping: 'pro',
|
|
62
|
+
permissionLevel: 'create',
|
|
63
|
+
appInterface: {},
|
|
64
|
+
isBlockDevelopmentRestrictionEnabled: false
|
|
65
|
+
};
|
|
66
|
+
var unmodifiableTableData = {
|
|
67
|
+
lock: null,
|
|
68
|
+
externalSyncById: null
|
|
69
|
+
};
|
|
70
|
+
var unmodifiableFieldData = {
|
|
71
|
+
lock: null,
|
|
72
|
+
isSynced: false
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Prior to version 4.1, TypeScript's built-in type guard for the native
|
|
77
|
+
* `Array.isArray` did not function correctly for values of type
|
|
78
|
+
* `ReadonlyArray`. This helper provides the expected functionality for the
|
|
79
|
+
* purposes of `setGlobalConfigValue`.
|
|
80
|
+
* TODO: replace with `Array.isArray` in TypeScript 4.1 or later.
|
|
81
|
+
*
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
function isReadonlyArray(value) {
|
|
85
|
+
return Array.isArray(value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Determine whether a given Mutation is defined by the Blocks SDK (and used in
|
|
90
|
+
* production scenarios) or defined by the blocks-testing library (and used
|
|
91
|
+
* purely for simulation purposes).
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
function isAuthenticMutation(mutation) {
|
|
96
|
+
return MutationTypeValues.includes(mutation.type);
|
|
97
|
+
}
|
|
98
|
+
var alphanumerics = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Select a random element from an array-like object.
|
|
102
|
+
*
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
function pick(arraylike) {
|
|
106
|
+
return arraylike[Math.floor(Math.random() * arraylike.length)];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** @internal */
|
|
110
|
+
|
|
111
|
+
function setGlobalConfigValue(target, path, value) {
|
|
112
|
+
if (isReadonlyArray(target)) {
|
|
113
|
+
var _newTarget = target.slice();
|
|
114
|
+
var index = parseInt(path[0], 10);
|
|
115
|
+
if (path.length === 1) {
|
|
116
|
+
if (value === undefined) {
|
|
117
|
+
_newTarget.splice(index, 1);
|
|
118
|
+
} else {
|
|
119
|
+
_newTarget[index] = value;
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
_newTarget[index] = setGlobalConfigValue(target[index] || {}, path.slice(1), value);
|
|
123
|
+
}
|
|
124
|
+
return _newTarget;
|
|
125
|
+
}
|
|
126
|
+
var newTarget = typeof target === 'object' ? _objectSpread({}, target) : {};
|
|
127
|
+
if (path.length === 1) {
|
|
128
|
+
if (value === undefined) {
|
|
129
|
+
delete newTarget[path[0]];
|
|
130
|
+
} else {
|
|
131
|
+
newTarget[path[0]] = value;
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
newTarget[path[0]] = setGlobalConfigValue(newTarget[path[0]] || {}, path.slice(1), value);
|
|
135
|
+
}
|
|
136
|
+
return newTarget;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A mapping relating the names of event subscriptions available on
|
|
141
|
+
* {@link TestDriver} instances to the arguments that are provided when one of
|
|
142
|
+
* those events is triggered.
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A complete set of information necessary to initialize a simulated Airtable
|
|
147
|
+
* Base in automated test environments.
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/** A representation of the state of a Table */
|
|
151
|
+
|
|
152
|
+
/** A representation of the state of a Field */
|
|
153
|
+
|
|
154
|
+
/** A representation of the state of a View */
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* A reference to Record contained within a simulated view. This is distinct
|
|
158
|
+
* from the complete fixture data for the simulated Record.
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
/** A representation of the state of a Record */
|
|
162
|
+
|
|
163
|
+
/** @hidden */
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A callback function allowing tests to simulate user interaction with the
|
|
167
|
+
* expanded record picker UI. The testing library will invoke this function
|
|
168
|
+
* whenever the Extension under test uses the {@link expandRecordPickerAsync}
|
|
169
|
+
* function, and the return value of this function will be provided to the Extension
|
|
170
|
+
* under test as the {@link Record} that the simulated user selected.
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
var generateGenericId = () => {
|
|
174
|
+
var length = 10 + Math.floor(Math.random() * 10);
|
|
175
|
+
return Array.from({
|
|
176
|
+
length
|
|
177
|
+
}).map(() => pick(alphanumerics)).join('');
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* An implementation of the MockAirtableInterface designed for use in automated
|
|
182
|
+
* test suites for Airtable Blocks maintained externally. Provides a more
|
|
183
|
+
* high-level constructor for specifying test fixture data and implements some
|
|
184
|
+
* features which approximate interactions with Hyperbase in production.
|
|
185
|
+
*
|
|
186
|
+
* @hidden
|
|
187
|
+
*/
|
|
188
|
+
var MockAirtableInterface = exports.default = /*#__PURE__*/function (_AbstractMockAirtable) {
|
|
189
|
+
function MockAirtableInterface(unsafeFixtureData) {
|
|
190
|
+
var _this;
|
|
191
|
+
(0, _classCallCheck2.default)(this, MockAirtableInterface);
|
|
192
|
+
var fixtureData = (0, _private_utils.cloneDeep)(unsafeFixtureData);
|
|
193
|
+
var store = {
|
|
194
|
+
tables: {},
|
|
195
|
+
views: {}
|
|
196
|
+
};
|
|
197
|
+
if (!fixtureData.base.tables || !fixtureData.base.tables.length) {
|
|
198
|
+
throw (0, _error_utils.spawnError)('Fixture data must include at least one table');
|
|
199
|
+
}
|
|
200
|
+
var tables = fixtureData.base.tables.map(table => {
|
|
201
|
+
if (table.id in store.tables) {
|
|
202
|
+
throw (0, _error_utils.spawnError)('repeated table ID: %s', table.id);
|
|
203
|
+
}
|
|
204
|
+
store.tables[table.id] = (0, _private_utils.keyBy)(table.records, _private_utils.getId);
|
|
205
|
+
store.views[table.id] = {};
|
|
206
|
+
if (!table.fields || !table.fields.length) {
|
|
207
|
+
throw (0, _error_utils.spawnError)('Every table in fixture data must specify at least one field, but table "%s" specified zero fields', table.id);
|
|
208
|
+
}
|
|
209
|
+
table.fields.map(_ref => {
|
|
210
|
+
var id = _ref.id;
|
|
211
|
+
return id;
|
|
212
|
+
}).forEach((id, index, ids) => {
|
|
213
|
+
if (ids.indexOf(id) !== index) {
|
|
214
|
+
throw (0, _error_utils.spawnError)('repeated field ID: %s', id);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
if (!table.views || !table.views.length) {
|
|
218
|
+
throw (0, _error_utils.spawnError)('Every table in fixture data must specify at least one view, but table "%s" specified zero views', table.id);
|
|
219
|
+
}
|
|
220
|
+
var _iterator = _createForOfIteratorHelper(table.views),
|
|
221
|
+
_step;
|
|
222
|
+
try {
|
|
223
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
224
|
+
var view = _step.value;
|
|
225
|
+
if (view.id in store.views[table.id]) {
|
|
226
|
+
throw (0, _error_utils.spawnError)('repeated view ID: %s', view.id);
|
|
227
|
+
}
|
|
228
|
+
var _iterator2 = _createForOfIteratorHelper(view.records),
|
|
229
|
+
_step2;
|
|
230
|
+
try {
|
|
231
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
232
|
+
var record = _step2.value;
|
|
233
|
+
if (!(record.id in store.tables[table.id])) {
|
|
234
|
+
throw (0, _error_utils.spawnError)('record %s not present in table %s', record.id, table.id);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
} catch (err) {
|
|
238
|
+
_iterator2.e(err);
|
|
239
|
+
} finally {
|
|
240
|
+
_iterator2.f();
|
|
241
|
+
}
|
|
242
|
+
store.views[table.id][view.id] = {
|
|
243
|
+
fieldOrder: view.fieldOrder,
|
|
244
|
+
records: view.records
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
} catch (err) {
|
|
248
|
+
_iterator.e(err);
|
|
249
|
+
} finally {
|
|
250
|
+
_iterator.f();
|
|
251
|
+
}
|
|
252
|
+
return _objectSpread(_objectSpread({}, unmodifiableTableData), {}, {
|
|
253
|
+
id: table.id,
|
|
254
|
+
name: table.name,
|
|
255
|
+
description: table.description,
|
|
256
|
+
fieldsById: (0, _private_utils.keyBy)(table.fields.map(field => _objectSpread(_objectSpread({}, field), {}, {
|
|
257
|
+
typeOptions: field.options
|
|
258
|
+
}, unmodifiableFieldData)), _private_utils.getId),
|
|
259
|
+
primaryFieldId: table.fields[0].id,
|
|
260
|
+
viewsById: (0, _private_utils.keyBy)(table.views, _private_utils.getId),
|
|
261
|
+
activeViewId: table.views[0].id,
|
|
262
|
+
viewOrder: table.views.map(_ref2 => {
|
|
263
|
+
var id = _ref2.id;
|
|
264
|
+
return id;
|
|
265
|
+
})
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
var sdkInitData = _objectSpread(_objectSpread({}, unmodifiableSdkData), {}, {
|
|
269
|
+
initialKvValuesByKey: fixtureData.globalConfig || {},
|
|
270
|
+
baseData: _objectSpread(_objectSpread({}, unmodifiableBaseData), {}, {
|
|
271
|
+
id: fixtureData.base.id,
|
|
272
|
+
name: fixtureData.base.name,
|
|
273
|
+
color: fixtureData.base.color || 'gray',
|
|
274
|
+
activeTableId: tables[0].id,
|
|
275
|
+
tableOrder: tables.map(_ref3 => {
|
|
276
|
+
var id = _ref3.id;
|
|
277
|
+
return id;
|
|
278
|
+
}),
|
|
279
|
+
tablesById: (0, _private_utils.keyBy)(tables, _private_utils.getId),
|
|
280
|
+
currentUserId: fixtureData.base.collaborators[0].id,
|
|
281
|
+
cursorData: {
|
|
282
|
+
selectedRecordIdSet: {},
|
|
283
|
+
selectedFieldIdSet: {}
|
|
284
|
+
},
|
|
285
|
+
collaboratorsById: (0, _private_utils.keyBy)(fixtureData.base.collaborators, _private_utils.getId),
|
|
286
|
+
activeCollaboratorIds: fixtureData.base.collaborators.filter(_ref4 => {
|
|
287
|
+
var isActive = _ref4.isActive;
|
|
288
|
+
return isActive;
|
|
289
|
+
}).map(_ref5 => {
|
|
290
|
+
var id = _ref5.id;
|
|
291
|
+
return id;
|
|
292
|
+
}),
|
|
293
|
+
workspaceId: fixtureData.base.workspaceId
|
|
294
|
+
}),
|
|
295
|
+
runContext: {
|
|
296
|
+
type: _unstable_testing_utils.BlockRunContextType.DASHBOARD_APP
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
_this = _callSuper(this, MockAirtableInterface, [sdkInitData]);
|
|
300
|
+
(0, _defineProperty2.default)(_this, "_recordDataStore", void 0);
|
|
301
|
+
(0, _defineProperty2.default)(_this, "_userPermissionCheck", void 0);
|
|
302
|
+
(0, _defineProperty2.default)(_this, "_pickRecord", void 0);
|
|
303
|
+
_this._recordDataStore = store;
|
|
304
|
+
return _this;
|
|
305
|
+
}
|
|
306
|
+
(0, _inherits2.default)(MockAirtableInterface, _AbstractMockAirtable);
|
|
307
|
+
return (0, _createClass2.default)(MockAirtableInterface, [{
|
|
308
|
+
key: "applyMutationAsync",
|
|
309
|
+
value: function () {
|
|
310
|
+
var _applyMutationAsync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(mutation, opts) {
|
|
311
|
+
var tableData, viewUpdates, fieldData, viewData, _tableData, newOrder, updates, _internalOpts, mainMutation;
|
|
312
|
+
return _regenerator.default.wrap(function (_context) {
|
|
313
|
+
while (1) switch (_context.prev = _context.next) {
|
|
314
|
+
case 0:
|
|
315
|
+
if (mutation.type === _test_mutations.TestMutationTypes.DELETE_SINGLE_FIELD) {
|
|
316
|
+
tableData = this.sdkInitData.baseData.tablesById[mutation.tableId];
|
|
317
|
+
(0, _error_utils.invariant)(tableData.primaryFieldId !== mutation.id, "A table's primary field may not be deleted.");
|
|
318
|
+
viewUpdates = Object.values(tableData.viewsById).filter(view => {
|
|
319
|
+
return view.fieldOrder && view.fieldOrder.fieldIds.includes(mutation.id);
|
|
320
|
+
}).map(view => {
|
|
321
|
+
var fieldOrder = view.fieldOrder;
|
|
322
|
+
(0, _error_utils.invariant)(fieldOrder, 'View must define a field ordering');
|
|
323
|
+
var index = fieldOrder.fieldIds.indexOf(mutation.id);
|
|
324
|
+
var fieldIds = fieldOrder.fieldIds.slice();
|
|
325
|
+
fieldIds.splice(index, 1);
|
|
326
|
+
var visibleFieldCount = index < fieldOrder.visibleFieldCount ? fieldOrder.visibleFieldCount - 1 : fieldOrder.visibleFieldCount;
|
|
327
|
+
return {
|
|
328
|
+
path: ['tablesById', mutation.tableId, 'viewsById', view.id, 'fieldOrder'],
|
|
329
|
+
value: {
|
|
330
|
+
fieldIds,
|
|
331
|
+
visibleFieldCount
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
});
|
|
335
|
+
viewUpdates.forEach(_ref6 => {
|
|
336
|
+
var path = _ref6.path,
|
|
337
|
+
value = _ref6.value;
|
|
338
|
+
var view = this._recordDataStore.views[path[1]][path[3]];
|
|
339
|
+
(0, _error_utils.invariant)(view, 'Internal update must reference existing view');
|
|
340
|
+
view.fieldOrder = value;
|
|
341
|
+
});
|
|
342
|
+
this.triggerModelUpdates([{
|
|
343
|
+
path: ['tablesById', mutation.tableId, 'fieldsById', mutation.id],
|
|
344
|
+
value: undefined
|
|
345
|
+
}, ...viewUpdates]);
|
|
346
|
+
} else if (mutation.type === _test_mutations.TestMutationTypes.CREATE_SINGLE_TABLE) {
|
|
347
|
+
fieldData = mutation.fields.map(field => {
|
|
348
|
+
return _objectSpread({
|
|
349
|
+
id: this.idGenerator.generateFieldId(),
|
|
350
|
+
name: field.name,
|
|
351
|
+
description: '',
|
|
352
|
+
type: field.config.type,
|
|
353
|
+
typeOptions: field.config.options
|
|
354
|
+
}, unmodifiableFieldData);
|
|
355
|
+
});
|
|
356
|
+
viewData = {
|
|
357
|
+
id: generateGenericId(),
|
|
358
|
+
name: 'Dynamically-generated Grid view',
|
|
359
|
+
type: _unstable_testing_utils.ViewType.GRID,
|
|
360
|
+
fieldOrder: {
|
|
361
|
+
fieldIds: fieldData.map(_ref7 => {
|
|
362
|
+
var id = _ref7.id;
|
|
363
|
+
return id;
|
|
364
|
+
}),
|
|
365
|
+
visibleFieldCount: fieldData.length
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
this.triggerModelUpdates([{
|
|
369
|
+
path: ['tablesById', mutation.id],
|
|
370
|
+
value: _objectSpread({
|
|
371
|
+
id: mutation.id,
|
|
372
|
+
name: mutation.name,
|
|
373
|
+
primaryFieldId: fieldData[0].id,
|
|
374
|
+
viewOrder: [viewData.id],
|
|
375
|
+
viewsById: {
|
|
376
|
+
[viewData.id]: viewData
|
|
377
|
+
},
|
|
378
|
+
fieldsById: (0, _private_utils.keyBy)(fieldData, _private_utils.getId)
|
|
379
|
+
}, unmodifiableTableData)
|
|
380
|
+
}, {
|
|
381
|
+
path: ['tableOrder'],
|
|
382
|
+
value: this.sdkInitData.baseData.tableOrder.concat(mutation.id)
|
|
383
|
+
}]);
|
|
384
|
+
this._recordDataStore.tables[mutation.id] = {};
|
|
385
|
+
this._recordDataStore.views[mutation.id] = {
|
|
386
|
+
[viewData.id]: {
|
|
387
|
+
fieldOrder: viewData.fieldOrder,
|
|
388
|
+
records: []
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
} else if (mutation.type === _test_mutations.TestMutationTypes.CREATE_MULTIPLE_RECORDS) {
|
|
392
|
+
Object.assign(this._recordDataStore.tables[mutation.tableId], (0, _private_utils.keyBy)(mutation.records, _private_utils.getId));
|
|
393
|
+
} else if (mutation.type === _test_mutations.TestMutationTypes.DELETE_SINGLE_VIEW) {
|
|
394
|
+
_tableData = this.sdkInitData.baseData.tablesById[mutation.tableId];
|
|
395
|
+
(0, _error_utils.invariant)(_tableData.viewOrder.length > 1, 'The view in a table with one view may not be deleted');
|
|
396
|
+
newOrder = _tableData.viewOrder.filter(id => id !== mutation.id);
|
|
397
|
+
delete this._recordDataStore.views[mutation.id];
|
|
398
|
+
updates = [{
|
|
399
|
+
path: ['tablesById', mutation.tableId, 'viewOrder'],
|
|
400
|
+
value: newOrder
|
|
401
|
+
}, {
|
|
402
|
+
path: ['tablesById', mutation.tableId, 'viewsById', mutation.id],
|
|
403
|
+
value: undefined
|
|
404
|
+
}];
|
|
405
|
+
if (mutation.id === this.sdkInitData.baseData.tablesById[mutation.tableId].activeViewId) {
|
|
406
|
+
updates.push({
|
|
407
|
+
path: ['tablesById', mutation.tableId, 'activeViewId'],
|
|
408
|
+
value: newOrder[0]
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
this.triggerModelUpdates(updates);
|
|
412
|
+
}
|
|
413
|
+
if (!isAuthenticMutation(mutation)) {
|
|
414
|
+
_context.next = 2;
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
if (!(mutation.type === _test_mutations.TestMutationTypes.CREATE_MULTIPLE_RECORDS || mutation.type === _test_mutations.TestMutationTypes.SET_MULTIPLE_RECORDS_CELL_VALUES)) {
|
|
418
|
+
_context.next = 1;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
422
|
+
_internalOpts = mutation.opts, mainMutation = (0, _objectWithoutProperties2.default)(mutation, _excluded);
|
|
423
|
+
this.emit('mutation', mainMutation);
|
|
424
|
+
return _context.abrupt("return");
|
|
425
|
+
case 1:
|
|
426
|
+
this.emit('mutation', mutation);
|
|
427
|
+
case 2:
|
|
428
|
+
case "end":
|
|
429
|
+
return _context.stop();
|
|
430
|
+
}
|
|
431
|
+
}, _callee, this);
|
|
432
|
+
}));
|
|
433
|
+
function applyMutationAsync(_x, _x2) {
|
|
434
|
+
return _applyMutationAsync.apply(this, arguments);
|
|
435
|
+
}
|
|
436
|
+
return applyMutationAsync;
|
|
437
|
+
}()
|
|
438
|
+
}, {
|
|
439
|
+
key: "checkPermissionsForMutation",
|
|
440
|
+
value: function checkPermissionsForMutation(mutation) {
|
|
441
|
+
if (!this._userPermissionCheck || this._userPermissionCheck(mutation)) {
|
|
442
|
+
return {
|
|
443
|
+
hasPermission: true
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
return {
|
|
447
|
+
hasPermission: false,
|
|
448
|
+
reasonDisplayString: 'The testing environment has been configured to deny this mutation.'
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
}, {
|
|
452
|
+
key: "globalConfigHelpers",
|
|
453
|
+
get: function get() {
|
|
454
|
+
var globalConfigHelpers = _superPropGet(MockAirtableInterface, "globalConfigHelpers", this, 1);
|
|
455
|
+
globalConfigHelpers.validateAndApplyUpdates = (updates, store) => {
|
|
456
|
+
var changedTopLevelKeys = new Set();
|
|
457
|
+
var newKvStore = _objectSpread({}, store);
|
|
458
|
+
var _iterator3 = _createForOfIteratorHelper(updates),
|
|
459
|
+
_step3;
|
|
460
|
+
try {
|
|
461
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
462
|
+
var update = _step3.value;
|
|
463
|
+
changedTopLevelKeys.add(update.path[0]);
|
|
464
|
+
newKvStore = setGlobalConfigValue(newKvStore, update.path, update.value);
|
|
465
|
+
}
|
|
466
|
+
} catch (err) {
|
|
467
|
+
_iterator3.e(err);
|
|
468
|
+
} finally {
|
|
469
|
+
_iterator3.f();
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
newKvStore,
|
|
473
|
+
changedTopLevelKeys: Array.from(changedTopLevelKeys)
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
return globalConfigHelpers;
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
479
|
+
key: "emit",
|
|
480
|
+
value: function emit(key, data) {
|
|
481
|
+
_superPropGet(MockAirtableInterface, "emit", this, 3)([key, data]);
|
|
482
|
+
}
|
|
483
|
+
}, {
|
|
484
|
+
key: "expandRecord",
|
|
485
|
+
value: function expandRecord(tableId, recordId, recordIds) {
|
|
486
|
+
this.emit('expandRecord', {
|
|
487
|
+
recordId,
|
|
488
|
+
recordIds
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}, {
|
|
492
|
+
key: "expandRecordList",
|
|
493
|
+
value: function expandRecordList(tableId, recordIds, fieldIds) {
|
|
494
|
+
this.emit('expandRecordList', {
|
|
495
|
+
tableId,
|
|
496
|
+
recordIds,
|
|
497
|
+
fieldIds
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
}, {
|
|
501
|
+
key: "expandRecordPickerAsync",
|
|
502
|
+
value: function () {
|
|
503
|
+
var _expandRecordPickerAsync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(tableId, recordIds, fieldIds, shouldAllowCreatingRecord) {
|
|
504
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
505
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
506
|
+
case 0:
|
|
507
|
+
if (this._pickRecord) {
|
|
508
|
+
_context2.next = 1;
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
throw (0, _error_utils.spawnError)('Unable to simulate user record selection for `expandRecordPickerAsync`. The test environment must be configured with the record to select before this method is called.');
|
|
512
|
+
case 1:
|
|
513
|
+
return _context2.abrupt("return", this._pickRecord(tableId, recordIds, fieldIds, shouldAllowCreatingRecord));
|
|
514
|
+
case 2:
|
|
515
|
+
case "end":
|
|
516
|
+
return _context2.stop();
|
|
517
|
+
}
|
|
518
|
+
}, _callee2, this);
|
|
519
|
+
}));
|
|
520
|
+
function expandRecordPickerAsync(_x3, _x4, _x5, _x6) {
|
|
521
|
+
return _expandRecordPickerAsync.apply(this, arguments);
|
|
522
|
+
}
|
|
523
|
+
return expandRecordPickerAsync;
|
|
524
|
+
}()
|
|
525
|
+
}, {
|
|
526
|
+
key: "fieldTypeProvider",
|
|
527
|
+
get: function get() {
|
|
528
|
+
var fieldTypeProvider = _superPropGet(MockAirtableInterface, "fieldTypeProvider", this, 1);
|
|
529
|
+
fieldTypeProvider.convertCellValueToString = (appInterface, cellValue, fieldData) => {
|
|
530
|
+
if (cellValue === null) {
|
|
531
|
+
return '';
|
|
532
|
+
}
|
|
533
|
+
if (Array.isArray(cellValue)) {
|
|
534
|
+
return cellValue.map(item => {
|
|
535
|
+
return fieldTypeProvider.convertCellValueToString(appInterface, item, fieldData);
|
|
536
|
+
}).join(', ');
|
|
537
|
+
}
|
|
538
|
+
if (typeof cellValue === 'object' && cellValue !== null && (0, _private_utils.has)(cellValue, 'name')) {
|
|
539
|
+
var named = cellValue;
|
|
540
|
+
if (typeof named.name === 'string') {
|
|
541
|
+
return named.name;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return String(cellValue);
|
|
545
|
+
};
|
|
546
|
+
return fieldTypeProvider;
|
|
547
|
+
}
|
|
548
|
+
}, {
|
|
549
|
+
key: "fetchAndSubscribeToCellValuesInFieldsAsync",
|
|
550
|
+
value: function () {
|
|
551
|
+
var _fetchAndSubscribeToCellValuesInFieldsAsync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(tableId, fieldIds) {
|
|
552
|
+
var _iterator4, _step4, _fieldId, recordsById, _i, _Object$values, record, cellValuesByFieldId, _iterator5, _step5, fieldId, _t;
|
|
553
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
554
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
555
|
+
case 0:
|
|
556
|
+
if (tableId in this._recordDataStore.tables) {
|
|
557
|
+
_context3.next = 1;
|
|
558
|
+
break;
|
|
559
|
+
}
|
|
560
|
+
throw (0, _error_utils.spawnError)('table not present in fixture data: %s', tableId);
|
|
561
|
+
case 1:
|
|
562
|
+
_iterator4 = _createForOfIteratorHelper(fieldIds);
|
|
563
|
+
_context3.prev = 2;
|
|
564
|
+
_iterator4.s();
|
|
565
|
+
case 3:
|
|
566
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
567
|
+
_context3.next = 5;
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
_fieldId = _step4.value;
|
|
571
|
+
if (_fieldId in this.sdkInitData.baseData.tablesById[tableId].fieldsById) {
|
|
572
|
+
_context3.next = 4;
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
throw (0, _error_utils.spawnError)('field %s not present in table %s', _fieldId, tableId);
|
|
576
|
+
case 4:
|
|
577
|
+
_context3.next = 3;
|
|
578
|
+
break;
|
|
579
|
+
case 5:
|
|
580
|
+
_context3.next = 7;
|
|
581
|
+
break;
|
|
582
|
+
case 6:
|
|
583
|
+
_context3.prev = 6;
|
|
584
|
+
_t = _context3["catch"](2);
|
|
585
|
+
_iterator4.e(_t);
|
|
586
|
+
case 7:
|
|
587
|
+
_context3.prev = 7;
|
|
588
|
+
_iterator4.f();
|
|
589
|
+
return _context3.finish(7);
|
|
590
|
+
case 8:
|
|
591
|
+
recordsById = {};
|
|
592
|
+
for (_i = 0, _Object$values = Object.values(this._recordDataStore.tables[tableId]); _i < _Object$values.length; _i++) {
|
|
593
|
+
record = _Object$values[_i];
|
|
594
|
+
cellValuesByFieldId = {};
|
|
595
|
+
_iterator5 = _createForOfIteratorHelper(fieldIds);
|
|
596
|
+
try {
|
|
597
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
598
|
+
fieldId = _step5.value;
|
|
599
|
+
cellValuesByFieldId[fieldId] = record.cellValuesByFieldId[fieldId];
|
|
600
|
+
}
|
|
601
|
+
} catch (err) {
|
|
602
|
+
_iterator5.e(err);
|
|
603
|
+
} finally {
|
|
604
|
+
_iterator5.f();
|
|
605
|
+
}
|
|
606
|
+
recordsById[record.id] = _objectSpread(_objectSpread({}, record), {}, {
|
|
607
|
+
cellValuesByFieldId
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
return _context3.abrupt("return", {
|
|
611
|
+
recordsById
|
|
612
|
+
});
|
|
613
|
+
case 9:
|
|
614
|
+
case "end":
|
|
615
|
+
return _context3.stop();
|
|
616
|
+
}
|
|
617
|
+
}, _callee3, this, [[2, 6, 7, 8]]);
|
|
618
|
+
}));
|
|
619
|
+
function fetchAndSubscribeToCellValuesInFieldsAsync(_x7, _x8) {
|
|
620
|
+
return _fetchAndSubscribeToCellValuesInFieldsAsync.apply(this, arguments);
|
|
621
|
+
}
|
|
622
|
+
return fetchAndSubscribeToCellValuesInFieldsAsync;
|
|
623
|
+
}()
|
|
624
|
+
}, {
|
|
625
|
+
key: "fetchAndSubscribeToCursorDataAsync",
|
|
626
|
+
value: function () {
|
|
627
|
+
var _fetchAndSubscribeToCursorDataAsync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
628
|
+
var cursorData, selectedRecordIdSet;
|
|
629
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
630
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
631
|
+
case 0:
|
|
632
|
+
cursorData = this.sdkInitData.baseData.cursorData;
|
|
633
|
+
selectedRecordIdSet = Object.assign({}, cursorData && cursorData.selectedRecordIdSet);
|
|
634
|
+
return _context4.abrupt("return", {
|
|
635
|
+
selectedRecordIdSet,
|
|
636
|
+
selectedFieldIdSet: {}
|
|
637
|
+
});
|
|
638
|
+
case 1:
|
|
639
|
+
case "end":
|
|
640
|
+
return _context4.stop();
|
|
641
|
+
}
|
|
642
|
+
}, _callee4, this);
|
|
643
|
+
}));
|
|
644
|
+
function fetchAndSubscribeToCursorDataAsync() {
|
|
645
|
+
return _fetchAndSubscribeToCursorDataAsync.apply(this, arguments);
|
|
646
|
+
}
|
|
647
|
+
return fetchAndSubscribeToCursorDataAsync;
|
|
648
|
+
}()
|
|
649
|
+
}, {
|
|
650
|
+
key: "fetchAndSubscribeToTableDataAsync",
|
|
651
|
+
value: function () {
|
|
652
|
+
var _fetchAndSubscribeToTableDataAsync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(tableId) {
|
|
653
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
654
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
655
|
+
case 0:
|
|
656
|
+
if (tableId in this._recordDataStore.tables) {
|
|
657
|
+
_context5.next = 1;
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
throw (0, _error_utils.spawnError)('table not present in fixture data: %s', tableId);
|
|
661
|
+
case 1:
|
|
662
|
+
return _context5.abrupt("return", {
|
|
663
|
+
recordsById: this._recordDataStore.tables[tableId]
|
|
664
|
+
});
|
|
665
|
+
case 2:
|
|
666
|
+
case "end":
|
|
667
|
+
return _context5.stop();
|
|
668
|
+
}
|
|
669
|
+
}, _callee5, this);
|
|
670
|
+
}));
|
|
671
|
+
function fetchAndSubscribeToTableDataAsync(_x9) {
|
|
672
|
+
return _fetchAndSubscribeToTableDataAsync.apply(this, arguments);
|
|
673
|
+
}
|
|
674
|
+
return fetchAndSubscribeToTableDataAsync;
|
|
675
|
+
}()
|
|
676
|
+
}, {
|
|
677
|
+
key: "fetchAndSubscribeToViewDataAsync",
|
|
678
|
+
value: function () {
|
|
679
|
+
var _fetchAndSubscribeToViewDataAsync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(tableId, viewId) {
|
|
680
|
+
var tableSchema, viewData;
|
|
681
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
682
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
683
|
+
case 0:
|
|
684
|
+
if (tableId in this.sdkInitData.baseData.tablesById) {
|
|
685
|
+
_context6.next = 1;
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
throw (0, _error_utils.spawnError)('table not present in fixture data: %s', tableId);
|
|
689
|
+
case 1:
|
|
690
|
+
tableSchema = this.sdkInitData.baseData.tablesById[tableId];
|
|
691
|
+
if (viewId in tableSchema.viewsById) {
|
|
692
|
+
_context6.next = 2;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
throw (0, _error_utils.spawnError)('view not present in fixture data: %s', viewId);
|
|
696
|
+
case 2:
|
|
697
|
+
viewData = this._recordDataStore.views[tableId][viewId];
|
|
698
|
+
return _context6.abrupt("return", {
|
|
699
|
+
visibleRecordIds: viewData.records.map(_ref8 => {
|
|
700
|
+
var id = _ref8.id;
|
|
701
|
+
return id;
|
|
702
|
+
}),
|
|
703
|
+
fieldOrder: viewData.fieldOrder,
|
|
704
|
+
colorsByRecordId: {}
|
|
705
|
+
});
|
|
706
|
+
case 3:
|
|
707
|
+
case "end":
|
|
708
|
+
return _context6.stop();
|
|
709
|
+
}
|
|
710
|
+
}, _callee6, this);
|
|
711
|
+
}));
|
|
712
|
+
function fetchAndSubscribeToViewDataAsync(_x0, _x1) {
|
|
713
|
+
return _fetchAndSubscribeToViewDataAsync.apply(this, arguments);
|
|
714
|
+
}
|
|
715
|
+
return fetchAndSubscribeToViewDataAsync;
|
|
716
|
+
}()
|
|
717
|
+
}, {
|
|
718
|
+
key: "hasRecord",
|
|
719
|
+
value: function hasRecord(tableId, recordId) {
|
|
720
|
+
var recordsById = this._recordDataStore.tables[tableId];
|
|
721
|
+
return recordsById && recordId in recordsById;
|
|
722
|
+
}
|
|
723
|
+
}, {
|
|
724
|
+
key: "idGenerator",
|
|
725
|
+
get: function get() {
|
|
726
|
+
var idGenerator = _superPropGet(MockAirtableInterface, "idGenerator", this, 1);
|
|
727
|
+
idGenerator.generateRecordId = generateGenericId;
|
|
728
|
+
idGenerator.generateFieldId = generateGenericId;
|
|
729
|
+
return idGenerator;
|
|
730
|
+
}
|
|
731
|
+
}, {
|
|
732
|
+
key: "on",
|
|
733
|
+
value: function on(key, fn) {
|
|
734
|
+
_superPropGet(MockAirtableInterface, "on", this, 3)([key, fn]);
|
|
735
|
+
}
|
|
736
|
+
}, {
|
|
737
|
+
key: "off",
|
|
738
|
+
value: function off(key, fn) {
|
|
739
|
+
_superPropGet(MockAirtableInterface, "off", this, 3)([key, fn]);
|
|
740
|
+
}
|
|
741
|
+
}, {
|
|
742
|
+
key: "setFullscreenMaxSize",
|
|
743
|
+
value: function setFullscreenMaxSize(maxFullscreenSize) {
|
|
744
|
+
this.emit('setFullscreenMaxSize', maxFullscreenSize);
|
|
745
|
+
}
|
|
746
|
+
}, {
|
|
747
|
+
key: "setPickRecord",
|
|
748
|
+
value: function setPickRecord(pickRecord) {
|
|
749
|
+
this._pickRecord = pickRecord;
|
|
750
|
+
}
|
|
751
|
+
}, {
|
|
752
|
+
key: "setUserPermissionCheck",
|
|
753
|
+
value: function setUserPermissionCheck(check) {
|
|
754
|
+
this._userPermissionCheck = check;
|
|
755
|
+
}
|
|
756
|
+
}, {
|
|
757
|
+
key: "performBackendFetchAsync",
|
|
758
|
+
value: function () {
|
|
759
|
+
var _performBackendFetchAsync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7(requestJson) {
|
|
760
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
761
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
762
|
+
case 0:
|
|
763
|
+
throw (0, _error_utils.spawnError)('Backend fetch is not currently supported in the blocks testing environment.');
|
|
764
|
+
case 1:
|
|
765
|
+
case "end":
|
|
766
|
+
return _context7.stop();
|
|
767
|
+
}
|
|
768
|
+
}, _callee7);
|
|
769
|
+
}));
|
|
770
|
+
function performBackendFetchAsync(_x10) {
|
|
771
|
+
return _performBackendFetchAsync.apply(this, arguments);
|
|
772
|
+
}
|
|
773
|
+
return performBackendFetchAsync;
|
|
774
|
+
}()
|
|
775
|
+
}, {
|
|
776
|
+
key: "fetchDefaultCellValuesByFieldIdAsync",
|
|
777
|
+
value: function () {
|
|
778
|
+
var _fetchDefaultCellValuesByFieldIdAsync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
779
|
+
return _regenerator.default.wrap(function (_context8) {
|
|
780
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
781
|
+
case 0:
|
|
782
|
+
return _context8.abrupt("return", {});
|
|
783
|
+
case 1:
|
|
784
|
+
case "end":
|
|
785
|
+
return _context8.stop();
|
|
786
|
+
}
|
|
787
|
+
}, _callee8);
|
|
788
|
+
}));
|
|
789
|
+
function fetchDefaultCellValuesByFieldIdAsync() {
|
|
790
|
+
return _fetchDefaultCellValuesByFieldIdAsync.apply(this, arguments);
|
|
791
|
+
}
|
|
792
|
+
return fetchDefaultCellValuesByFieldIdAsync;
|
|
793
|
+
}()
|
|
794
|
+
}, {
|
|
795
|
+
key: "reloadFrame",
|
|
796
|
+
value: function reloadFrame() {}
|
|
797
|
+
}, {
|
|
798
|
+
key: "setSettingsButtonVisibility",
|
|
799
|
+
value: function setSettingsButtonVisibility() {}
|
|
800
|
+
}, {
|
|
801
|
+
key: "setUndoRedoMode",
|
|
802
|
+
value: function setUndoRedoMode() {}
|
|
803
|
+
}, {
|
|
804
|
+
key: "enterFullscreen",
|
|
805
|
+
value: function enterFullscreen() {
|
|
806
|
+
this.emit('enterFullscreen', null);
|
|
807
|
+
}
|
|
808
|
+
}, {
|
|
809
|
+
key: "exitFullscreen",
|
|
810
|
+
value: function exitFullscreen() {
|
|
811
|
+
this.emit('exitFullscreen', null);
|
|
812
|
+
}
|
|
813
|
+
}, {
|
|
814
|
+
key: "fetchAndSubscribeToPerformRecordActionAsync",
|
|
815
|
+
value: function () {
|
|
816
|
+
var _fetchAndSubscribeToPerformRecordActionAsync = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
817
|
+
return _regenerator.default.wrap(function (_context9) {
|
|
818
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
819
|
+
case 0:
|
|
820
|
+
return _context9.abrupt("return", null);
|
|
821
|
+
case 1:
|
|
822
|
+
case "end":
|
|
823
|
+
return _context9.stop();
|
|
824
|
+
}
|
|
825
|
+
}, _callee9);
|
|
826
|
+
}));
|
|
827
|
+
function fetchAndSubscribeToPerformRecordActionAsync() {
|
|
828
|
+
return _fetchAndSubscribeToPerformRecordActionAsync.apply(this, arguments);
|
|
829
|
+
}
|
|
830
|
+
return fetchAndSubscribeToPerformRecordActionAsync;
|
|
831
|
+
}()
|
|
832
|
+
}, {
|
|
833
|
+
key: "trackEvent",
|
|
834
|
+
value: function trackEvent() {}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* `trackExposure` cannot be invoked by any Extensions (neither those authored by
|
|
838
|
+
* Airtable nor by other Extension developers). It should be implemented to
|
|
839
|
+
* satisfy the AirtableInterface contract, but the implementation should
|
|
840
|
+
* not throw because it must be successful for Extensions to function. Likewise,
|
|
841
|
+
* it should not emit an event because test authors have no need to track
|
|
842
|
+
* its usage.
|
|
843
|
+
*/
|
|
844
|
+
}, {
|
|
845
|
+
key: "trackExposure",
|
|
846
|
+
value: function trackExposure() {}
|
|
847
|
+
}, {
|
|
848
|
+
key: "sendStat",
|
|
849
|
+
value: function sendStat() {}
|
|
850
|
+
}]);
|
|
851
|
+
}(_unstable_testing_utils.AbstractMockAirtableInterface);
|