@lvce-editor/test-worker 4.13.0 → 4.15.0
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/dist/api.d.ts +1 -1
- package/dist/testWorkerMain.js +199 -41
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ declare const expandRecursively: () => Promise<void>;
|
|
|
97
97
|
declare const newFile: () => Promise<void>;
|
|
98
98
|
declare const newFolder: () => Promise<void>;
|
|
99
99
|
declare const handleClick$1: (index: number) => Promise<void>;
|
|
100
|
-
declare const handleClickAt: (button: number, ctrlKey: boolean, shiftKey: boolean, x: number, y: number) => Promise<void>;
|
|
100
|
+
declare const handleClickAt: (preventDefault: boolean, button: number, ctrlKey: boolean, shiftKey: boolean, x: number, y: number) => Promise<void>;
|
|
101
101
|
declare const handleDrop: (x: number, y: number, fileIds: readonly number[], fileList: FileList | readonly File[]) => Promise<void>;
|
|
102
102
|
declare const rename$1: () => Promise<void>;
|
|
103
103
|
declare const selectAll$1: () => Promise<void>;
|
package/dist/testWorkerMain.js
CHANGED
|
@@ -54,12 +54,12 @@ class VError extends Error {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
class AssertionError extends Error {
|
|
57
|
+
let AssertionError$1 = class AssertionError extends Error {
|
|
58
58
|
constructor(message) {
|
|
59
59
|
super(message);
|
|
60
60
|
this.name = 'AssertionError';
|
|
61
61
|
}
|
|
62
|
-
}
|
|
62
|
+
};
|
|
63
63
|
const getType = value => {
|
|
64
64
|
switch (typeof value) {
|
|
65
65
|
case 'number':
|
|
@@ -85,13 +85,13 @@ const getType = value => {
|
|
|
85
85
|
const object = value => {
|
|
86
86
|
const type = getType(value);
|
|
87
87
|
if (type !== 'object') {
|
|
88
|
-
throw new AssertionError('expected value to be of type object');
|
|
88
|
+
throw new AssertionError$1('expected value to be of type object');
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
|
-
const string = value => {
|
|
91
|
+
const string$1 = value => {
|
|
92
92
|
const type = getType(value);
|
|
93
93
|
if (type !== 'string') {
|
|
94
|
-
throw new AssertionError('expected value to be of type string');
|
|
94
|
+
throw new AssertionError$1('expected value to be of type string');
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
|
|
@@ -960,6 +960,10 @@ const WebWorkerRpcClient = {
|
|
|
960
960
|
create: create$1
|
|
961
961
|
};
|
|
962
962
|
|
|
963
|
+
const formatDuration = duration => {
|
|
964
|
+
return duration.toFixed(2) + 'ms';
|
|
965
|
+
};
|
|
966
|
+
|
|
963
967
|
const RendererWorker = 1;
|
|
964
968
|
|
|
965
969
|
const rpcs = Object.create(null);
|
|
@@ -985,13 +989,6 @@ const Rpc = {
|
|
|
985
989
|
invokeAndTransfer
|
|
986
990
|
};
|
|
987
991
|
|
|
988
|
-
const Fail = 'fail';
|
|
989
|
-
const Pass = 'pass';
|
|
990
|
-
|
|
991
|
-
const now = () => {
|
|
992
|
-
return performance.now();
|
|
993
|
-
};
|
|
994
|
-
|
|
995
992
|
const printError = error => {
|
|
996
993
|
if (error && error.constructor.name === 'AssertionError') {
|
|
997
994
|
console.error(error.message);
|
|
@@ -999,6 +996,7 @@ const printError = error => {
|
|
|
999
996
|
console.error(error);
|
|
1000
997
|
}
|
|
1001
998
|
};
|
|
999
|
+
|
|
1002
1000
|
const stringifyError = error => {
|
|
1003
1001
|
if (!error) {
|
|
1004
1002
|
return `${error}`;
|
|
@@ -1008,9 +1006,14 @@ const stringifyError = error => {
|
|
|
1008
1006
|
}
|
|
1009
1007
|
return `${error.message}`;
|
|
1010
1008
|
};
|
|
1011
|
-
|
|
1012
|
-
|
|
1009
|
+
|
|
1010
|
+
const Fail = 'fail';
|
|
1011
|
+
const Pass = 'pass';
|
|
1012
|
+
|
|
1013
|
+
const now = () => {
|
|
1014
|
+
return performance.now();
|
|
1013
1015
|
};
|
|
1016
|
+
|
|
1014
1017
|
const executeTest = async (name, fn, globals = {}) => {
|
|
1015
1018
|
let _error;
|
|
1016
1019
|
let _start;
|
|
@@ -1031,12 +1034,10 @@ const executeTest = async (name, fn, globals = {}) => {
|
|
|
1031
1034
|
console.error(error);
|
|
1032
1035
|
return;
|
|
1033
1036
|
}
|
|
1034
|
-
// @ts-ignore
|
|
1035
1037
|
_error = stringifyError(error);
|
|
1036
1038
|
if (!(error instanceof VError)) {
|
|
1037
1039
|
error = new VError(error, `Test failed: ${name}`);
|
|
1038
1040
|
}
|
|
1039
|
-
// @ts-ignore
|
|
1040
1041
|
printError(error);
|
|
1041
1042
|
}
|
|
1042
1043
|
let state;
|
|
@@ -1073,6 +1074,13 @@ const importTest = async url => {
|
|
|
1073
1074
|
}
|
|
1074
1075
|
};
|
|
1075
1076
|
|
|
1077
|
+
class AssertionError extends Error {
|
|
1078
|
+
constructor(message) {
|
|
1079
|
+
super(message);
|
|
1080
|
+
this.name = 'AssertionError';
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1076
1084
|
const webViews = Object.create(null);
|
|
1077
1085
|
const set = (id, webView) => {
|
|
1078
1086
|
webViews[id] = webView;
|
|
@@ -1088,29 +1096,179 @@ const getLocatorRpc = locator => {
|
|
|
1088
1096
|
return Rpc;
|
|
1089
1097
|
};
|
|
1090
1098
|
|
|
1091
|
-
const
|
|
1092
|
-
string(value, message) {
|
|
1093
|
-
if (typeof value !== 'string') {
|
|
1094
|
-
throw new TypeError(message);
|
|
1095
|
-
}
|
|
1096
|
-
},
|
|
1097
|
-
number(value, message) {
|
|
1098
|
-
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
1099
|
-
throw new TypeError(message);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
};
|
|
1103
|
-
const expect$1 = locator => {
|
|
1099
|
+
const locatorInvoke = (locator, method, ...params) => {
|
|
1104
1100
|
const {
|
|
1105
1101
|
invoke
|
|
1106
1102
|
} = getLocatorRpc(locator);
|
|
1103
|
+
return invoke(method, ...params);
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
const printLocator = locator => {
|
|
1107
|
+
if (locator._nth !== -1) {
|
|
1108
|
+
return `${locator._selector}:nth(${locator._nth})`;
|
|
1109
|
+
}
|
|
1110
|
+
if (locator._hasText) {
|
|
1111
|
+
return `${locator._selector} "${locator._hasText}"`;
|
|
1112
|
+
}
|
|
1113
|
+
return `${locator._selector}`;
|
|
1114
|
+
};
|
|
1115
|
+
|
|
1116
|
+
const toBeVisible = locator => {
|
|
1117
|
+
return `expected selector to be visible ${locator._selector}`;
|
|
1118
|
+
};
|
|
1119
|
+
const toHaveValue = (locator, {
|
|
1120
|
+
value
|
|
1121
|
+
}) => {
|
|
1122
|
+
return `expected selector ${locator._selector} to have value ${value}`;
|
|
1123
|
+
};
|
|
1124
|
+
const toHaveText = async (locator, options) => {
|
|
1125
|
+
const locatorString = printLocator(locator);
|
|
1126
|
+
const {
|
|
1127
|
+
wasFound,
|
|
1128
|
+
actual
|
|
1129
|
+
} = await locatorInvoke(locator, 'TestFrameWork.conditionToHaveAttribute', locator, options);
|
|
1130
|
+
const {
|
|
1131
|
+
text
|
|
1132
|
+
} = options;
|
|
1133
|
+
if (!wasFound) {
|
|
1134
|
+
return `expected selector ${locatorString} to have text "${text}" element was not found`;
|
|
1135
|
+
}
|
|
1136
|
+
return `expected selector ${locatorString} to have text "${text}" but was "${actual}"`;
|
|
1137
|
+
};
|
|
1138
|
+
const toHaveAttribute = async (locator, options) => {
|
|
1139
|
+
const locatorString = printLocator(locator);
|
|
1140
|
+
const {
|
|
1141
|
+
wasFound,
|
|
1142
|
+
actual
|
|
1143
|
+
} = await locatorInvoke(locator, 'TestFrameWork.conditionToHaveAttribute', locator, options);
|
|
1144
|
+
const {
|
|
1145
|
+
key,
|
|
1146
|
+
value
|
|
1147
|
+
} = options;
|
|
1148
|
+
if (!wasFound) {
|
|
1149
|
+
return `expected ${locatorString} to have attribute ${key} ${value} but element was not found`;
|
|
1150
|
+
}
|
|
1151
|
+
return `expected ${locatorString} to have attribute ${key} ${value} but was ${actual}`;
|
|
1152
|
+
};
|
|
1153
|
+
const toHaveCount = async (locator, {
|
|
1154
|
+
count
|
|
1155
|
+
}) => {
|
|
1156
|
+
const locatorString = printLocator(locator);
|
|
1157
|
+
const {
|
|
1158
|
+
actual
|
|
1159
|
+
} = await locatorInvoke(locator, 'TestFrameWork.conditionToHaveCount', locator);
|
|
1160
|
+
return `expected ${locatorString} to have count ${count} but was ${actual}`;
|
|
1161
|
+
};
|
|
1162
|
+
const toBeFocused = async locator => {
|
|
1163
|
+
const locatorString = printLocator(locator);
|
|
1164
|
+
const {
|
|
1165
|
+
actual
|
|
1166
|
+
} = await locatorInvoke(locator, 'TestFrameWork.conditionToBeFocused', locator);
|
|
1167
|
+
return `expected ${locatorString} to be focused but active element is ${actual}`;
|
|
1168
|
+
};
|
|
1169
|
+
const toHaveClass = async (locator, options) => {
|
|
1170
|
+
const locatorString = printLocator(locator);
|
|
1171
|
+
const {
|
|
1172
|
+
wasFound
|
|
1173
|
+
} = await locatorInvoke(locator, 'TestFrameWork.conditionToHaveCss', locator, options);
|
|
1174
|
+
const {
|
|
1175
|
+
className
|
|
1176
|
+
} = options;
|
|
1177
|
+
if (!wasFound) {
|
|
1178
|
+
return `expected ${locatorString} to have class ${className} but element was not found`;
|
|
1179
|
+
}
|
|
1180
|
+
return `expected ${locatorString} to have class ${className}`;
|
|
1181
|
+
};
|
|
1182
|
+
const toHaveId = async (locator, options) => {
|
|
1183
|
+
const {
|
|
1184
|
+
wasFound,
|
|
1185
|
+
actual
|
|
1186
|
+
} = await locatorInvoke(locator, 'TestFrameWork.conditionToHaveId', locator, options);
|
|
1187
|
+
const locatorString = printLocator(locator);
|
|
1188
|
+
const {
|
|
1189
|
+
id
|
|
1190
|
+
} = options;
|
|
1191
|
+
if (!wasFound) {
|
|
1192
|
+
return `expected ${locatorString} to have id ${id} but element was not found`;
|
|
1193
|
+
}
|
|
1194
|
+
return `expected ${locatorString} to have id ${id} but was ${actual}`;
|
|
1195
|
+
};
|
|
1196
|
+
const toBeHidden = locator => {
|
|
1197
|
+
const locatorString = printLocator(locator);
|
|
1198
|
+
return `expected ${locatorString} to be hidden`;
|
|
1199
|
+
};
|
|
1200
|
+
const toHaveCss = async (locator, options) => {
|
|
1201
|
+
const {
|
|
1202
|
+
wasFound,
|
|
1203
|
+
actual
|
|
1204
|
+
} = await locatorInvoke(locator, 'TestFrameWork.conditionToHaveCss', locator, options);
|
|
1205
|
+
const locatorString = printLocator(locator);
|
|
1206
|
+
const {
|
|
1207
|
+
key,
|
|
1208
|
+
value
|
|
1209
|
+
} = options;
|
|
1210
|
+
if (!wasFound) {
|
|
1211
|
+
return `expected ${locatorString} to have css ${key} ${value} but element was not found`;
|
|
1212
|
+
}
|
|
1213
|
+
return `expected ${locatorString} to have css ${key} ${value} but was ${actual}`;
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
const getFunction = fnName => {
|
|
1217
|
+
switch (fnName) {
|
|
1218
|
+
case 'toBeVisible':
|
|
1219
|
+
return toBeVisible;
|
|
1220
|
+
case 'toHaveValue':
|
|
1221
|
+
return toHaveValue;
|
|
1222
|
+
case 'toHaveText':
|
|
1223
|
+
return toHaveText;
|
|
1224
|
+
case 'toHaveAttribute':
|
|
1225
|
+
return toHaveAttribute;
|
|
1226
|
+
case 'toHaveCount':
|
|
1227
|
+
return toHaveCount;
|
|
1228
|
+
case 'toBeFocused':
|
|
1229
|
+
return toBeFocused;
|
|
1230
|
+
case 'toHaveId':
|
|
1231
|
+
return toHaveId;
|
|
1232
|
+
case 'toBeHidden':
|
|
1233
|
+
return toBeHidden;
|
|
1234
|
+
case 'toHaveCss':
|
|
1235
|
+
return toHaveCss;
|
|
1236
|
+
case 'toHaveClass':
|
|
1237
|
+
return toHaveClass;
|
|
1238
|
+
default:
|
|
1239
|
+
throw new Error(`unexpected function name ${fnName}`);
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
const string = (value, message) => {
|
|
1244
|
+
if (typeof value !== 'string') {
|
|
1245
|
+
throw new TypeError(message);
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
const number = (value, message) => {
|
|
1249
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
1250
|
+
throw new TypeError(message);
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
|
|
1254
|
+
const expect$1 = locator => {
|
|
1107
1255
|
return {
|
|
1108
1256
|
async checkSingleElementCondition(fnName, options) {
|
|
1109
1257
|
// TODO add rpcId property to locator instead
|
|
1110
|
-
|
|
1258
|
+
const result = await locatorInvoke('TestFrameWork.checkSingleElementCondition', locator, fnName, options);
|
|
1259
|
+
if (result && result.error) {
|
|
1260
|
+
const fn = getFunction(fnName);
|
|
1261
|
+
const errorInfo = await fn(locator, options);
|
|
1262
|
+
throw new AssertionError(errorInfo);
|
|
1263
|
+
}
|
|
1111
1264
|
},
|
|
1112
1265
|
async checkMultiElementCondition(fnName, options) {
|
|
1113
|
-
|
|
1266
|
+
const result = await locatorInvoke('TestFrameWork.checkMultiElementCondition', locator, fnName, options);
|
|
1267
|
+
if (result && result.error) {
|
|
1268
|
+
const fn = getFunction(fnName);
|
|
1269
|
+
const errorInfo = await fn(locator, options);
|
|
1270
|
+
throw new AssertionError(errorInfo);
|
|
1271
|
+
}
|
|
1114
1272
|
},
|
|
1115
1273
|
async toBeVisible() {
|
|
1116
1274
|
if (this.negated) {
|
|
@@ -1119,19 +1277,19 @@ const expect$1 = locator => {
|
|
|
1119
1277
|
return this.checkSingleElementCondition('toBeVisible', {});
|
|
1120
1278
|
},
|
|
1121
1279
|
async toHaveText(text) {
|
|
1122
|
-
|
|
1280
|
+
string(text, 'text must be of type string');
|
|
1123
1281
|
return this.checkSingleElementCondition('toHaveText', {
|
|
1124
1282
|
text
|
|
1125
1283
|
});
|
|
1126
1284
|
},
|
|
1127
1285
|
async toContainText(text) {
|
|
1128
|
-
|
|
1286
|
+
string(text, 'text must be of type string');
|
|
1129
1287
|
return this.checkSingleElementCondition('toContainText', {
|
|
1130
1288
|
text
|
|
1131
1289
|
});
|
|
1132
1290
|
},
|
|
1133
1291
|
async toHaveValue(value) {
|
|
1134
|
-
|
|
1292
|
+
string(value, 'value must be of type string');
|
|
1135
1293
|
return this.checkSingleElementCondition('toHaveValue', {
|
|
1136
1294
|
value
|
|
1137
1295
|
});
|
|
@@ -1146,7 +1304,7 @@ const expect$1 = locator => {
|
|
|
1146
1304
|
});
|
|
1147
1305
|
},
|
|
1148
1306
|
async toHaveAttribute(key, value) {
|
|
1149
|
-
|
|
1307
|
+
string(key, 'key must be of type string');
|
|
1150
1308
|
// Assert.string(value, 'value must be of type string')
|
|
1151
1309
|
return this.checkSingleElementCondition('toHaveAttribute', {
|
|
1152
1310
|
key,
|
|
@@ -1154,19 +1312,19 @@ const expect$1 = locator => {
|
|
|
1154
1312
|
});
|
|
1155
1313
|
},
|
|
1156
1314
|
async toHaveClass(className) {
|
|
1157
|
-
|
|
1315
|
+
string(className, 'className must be of type string');
|
|
1158
1316
|
return this.checkSingleElementCondition('toHaveClass', {
|
|
1159
1317
|
className
|
|
1160
1318
|
});
|
|
1161
1319
|
},
|
|
1162
1320
|
async toHaveId(id) {
|
|
1163
|
-
|
|
1321
|
+
string(id, 'id must be of type string');
|
|
1164
1322
|
return this.checkSingleElementCondition('toHaveId', {
|
|
1165
1323
|
id
|
|
1166
1324
|
});
|
|
1167
1325
|
},
|
|
1168
1326
|
async toHaveCount(count) {
|
|
1169
|
-
|
|
1327
|
+
number(count, 'count must be of type number');
|
|
1170
1328
|
return this.checkMultiElementCondition('toHaveCount', {
|
|
1171
1329
|
count
|
|
1172
1330
|
});
|
|
@@ -1214,7 +1372,7 @@ const getTests = () => {
|
|
|
1214
1372
|
};
|
|
1215
1373
|
const setMockRpc = mockRpc => {
|
|
1216
1374
|
object(mockRpc);
|
|
1217
|
-
string(mockRpc.name);
|
|
1375
|
+
string$1(mockRpc.name);
|
|
1218
1376
|
state.mockRpcs[mockRpc.name] = mockRpc;
|
|
1219
1377
|
};
|
|
1220
1378
|
|
|
@@ -1774,8 +1932,8 @@ const newFolder = async () => {
|
|
|
1774
1932
|
const handleClick$1 = async index => {
|
|
1775
1933
|
await invoke('Explorer.handleClick', index);
|
|
1776
1934
|
};
|
|
1777
|
-
const handleClickAt$1 = async (button, ctrlKey, shiftKey, x, y) => {
|
|
1778
|
-
await invoke('Explorer.handleClickAt', button, ctrlKey, shiftKey, x, y);
|
|
1935
|
+
const handleClickAt$1 = async (preventDefault, button, ctrlKey, shiftKey, x, y) => {
|
|
1936
|
+
await invoke('Explorer.handleClickAt', preventDefault, button, ctrlKey, shiftKey, x, y);
|
|
1779
1937
|
};
|
|
1780
1938
|
const handleDrop = async (x, y, fileIds, fileList) => {
|
|
1781
1939
|
await invoke('Explorer.handleDrop', x, y, fileIds, fileIds);
|