@lvce-editor/test-worker 5.0.0 → 5.1.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/testWorkerMain.js +129 -137
- package/package.json +1 -1
package/dist/testWorkerMain.js
CHANGED
|
@@ -521,7 +521,7 @@ const create$4 = (method, params) => {
|
|
|
521
521
|
};
|
|
522
522
|
};
|
|
523
523
|
const callbacks = Object.create(null);
|
|
524
|
-
const set$
|
|
524
|
+
const set$3 = (id, fn) => {
|
|
525
525
|
callbacks[id] = fn;
|
|
526
526
|
};
|
|
527
527
|
const get$2 = id => {
|
|
@@ -540,7 +540,7 @@ const registerPromise = () => {
|
|
|
540
540
|
resolve,
|
|
541
541
|
promise
|
|
542
542
|
} = Promise.withResolvers();
|
|
543
|
-
set$
|
|
543
|
+
set$3(id, resolve);
|
|
544
544
|
return {
|
|
545
545
|
id,
|
|
546
546
|
promise
|
|
@@ -1034,33 +1034,17 @@ const WebWorkerRpcClient = {
|
|
|
1034
1034
|
create: create$2
|
|
1035
1035
|
};
|
|
1036
1036
|
|
|
1037
|
-
const
|
|
1038
|
-
|
|
1039
|
-
};
|
|
1040
|
-
|
|
1041
|
-
const printError = error => {
|
|
1042
|
-
if (error && error.constructor.name === 'AssertionError') {
|
|
1043
|
-
console.error(error.message);
|
|
1044
|
-
} else {
|
|
1045
|
-
console.error(error);
|
|
1046
|
-
}
|
|
1047
|
-
};
|
|
1048
|
-
|
|
1049
|
-
const printTestError = async error => {
|
|
1050
|
-
// TODO ask error worker to add codeframe
|
|
1051
|
-
printError(error);
|
|
1052
|
-
};
|
|
1037
|
+
const RendererWorker = 1;
|
|
1038
|
+
const TestWorker = 9001;
|
|
1053
1039
|
|
|
1054
1040
|
const rpcs = Object.create(null);
|
|
1055
|
-
const set$
|
|
1041
|
+
const set$2 = (id, rpc) => {
|
|
1056
1042
|
rpcs[id] = rpc;
|
|
1057
1043
|
};
|
|
1058
1044
|
const get$1 = id => {
|
|
1059
1045
|
return rpcs[id];
|
|
1060
1046
|
};
|
|
1061
1047
|
|
|
1062
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1063
|
-
|
|
1064
1048
|
const create$1 = rpcId => {
|
|
1065
1049
|
return {
|
|
1066
1050
|
// @ts-ignore
|
|
@@ -1076,7 +1060,7 @@ const create$1 = rpcId => {
|
|
|
1076
1060
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1077
1061
|
},
|
|
1078
1062
|
set(rpc) {
|
|
1079
|
-
set$
|
|
1063
|
+
set$2(rpcId, rpc);
|
|
1080
1064
|
},
|
|
1081
1065
|
async dispose() {
|
|
1082
1066
|
const rpc = get$1(rpcId);
|
|
@@ -1084,29 +1068,33 @@ const create$1 = rpcId => {
|
|
|
1084
1068
|
}
|
|
1085
1069
|
};
|
|
1086
1070
|
};
|
|
1087
|
-
|
|
1071
|
+
|
|
1088
1072
|
const {
|
|
1089
|
-
invoke: invoke$
|
|
1090
|
-
invokeAndTransfer
|
|
1091
|
-
set: set$
|
|
1092
|
-
const sendMessagePortToEditorWorker
|
|
1073
|
+
invoke: invoke$1,
|
|
1074
|
+
invokeAndTransfer,
|
|
1075
|
+
set: set$1} = create$1(RendererWorker);
|
|
1076
|
+
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
1093
1077
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1094
1078
|
// @ts-ignore
|
|
1095
|
-
await invokeAndTransfer
|
|
1079
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
1096
1080
|
};
|
|
1097
|
-
const RendererWorker = {
|
|
1098
|
-
__proto__: null,
|
|
1099
|
-
invoke: invoke$3,
|
|
1100
|
-
invokeAndTransfer: invokeAndTransfer$3,
|
|
1101
|
-
sendMessagePortToEditorWorker: sendMessagePortToEditorWorker$1,
|
|
1102
|
-
set: set$3};
|
|
1103
1081
|
|
|
1104
|
-
const {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1082
|
+
const formatDuration = duration => {
|
|
1083
|
+
return duration.toFixed(2) + 'ms';
|
|
1084
|
+
};
|
|
1085
|
+
|
|
1086
|
+
const printError = error => {
|
|
1087
|
+
if (error && error.constructor.name === 'AssertionError') {
|
|
1088
|
+
console.error(error.message);
|
|
1089
|
+
} else {
|
|
1090
|
+
console.error(error);
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
const printTestError = async error => {
|
|
1095
|
+
// TODO ask error worker to add codeframe
|
|
1096
|
+
printError(error);
|
|
1097
|
+
};
|
|
1110
1098
|
|
|
1111
1099
|
const stringifyError = error => {
|
|
1112
1100
|
if (!error) {
|
|
@@ -1383,102 +1371,106 @@ const number = (value, message) => {
|
|
|
1383
1371
|
};
|
|
1384
1372
|
|
|
1385
1373
|
const expect$1 = locator => {
|
|
1386
|
-
return
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
const
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
const errorInfo = await fn(locator, options);
|
|
1402
|
-
throw new AssertionError(errorInfo);
|
|
1403
|
-
}
|
|
1404
|
-
},
|
|
1405
|
-
async toBeVisible() {
|
|
1406
|
-
if (this.negated) {
|
|
1407
|
-
throw new Error('use toBeHidden instead of not.toBeVisible');
|
|
1408
|
-
}
|
|
1409
|
-
return this.checkSingleElementCondition('toBeVisible', {});
|
|
1410
|
-
},
|
|
1411
|
-
async toHaveText(text) {
|
|
1412
|
-
string(text, 'text must be of type string');
|
|
1413
|
-
return this.checkSingleElementCondition('toHaveText', {
|
|
1414
|
-
text
|
|
1415
|
-
});
|
|
1416
|
-
},
|
|
1417
|
-
async toContainText(text) {
|
|
1418
|
-
string(text, 'text must be of type string');
|
|
1419
|
-
return this.checkSingleElementCondition('toContainText', {
|
|
1420
|
-
text
|
|
1421
|
-
});
|
|
1422
|
-
},
|
|
1423
|
-
async toHaveValue(value) {
|
|
1424
|
-
string(value, 'value must be of type string');
|
|
1425
|
-
return this.checkSingleElementCondition('toHaveValue', {
|
|
1426
|
-
value
|
|
1427
|
-
});
|
|
1428
|
-
},
|
|
1429
|
-
async toBeFocused() {
|
|
1430
|
-
return this.checkSingleElementCondition('toBeFocused');
|
|
1431
|
-
},
|
|
1432
|
-
async toHaveCSS(key, value) {
|
|
1433
|
-
return this.checkSingleElementCondition('toHaveCss', {
|
|
1434
|
-
key,
|
|
1435
|
-
value
|
|
1436
|
-
});
|
|
1437
|
-
},
|
|
1438
|
-
async toHaveAttribute(key, value) {
|
|
1439
|
-
string(key, 'key must be of type string');
|
|
1440
|
-
// Assert.string(value, 'value must be of type string')
|
|
1441
|
-
return this.checkSingleElementCondition('toHaveAttribute', {
|
|
1442
|
-
key,
|
|
1443
|
-
value
|
|
1444
|
-
});
|
|
1445
|
-
},
|
|
1446
|
-
async toHaveJSProperty(key, value) {
|
|
1447
|
-
string(key, 'key must be of type string');
|
|
1448
|
-
return this.checkSingleElementCondition('toHaveJSProperty', {
|
|
1449
|
-
key,
|
|
1450
|
-
value
|
|
1451
|
-
});
|
|
1452
|
-
},
|
|
1453
|
-
async toHaveClass(className) {
|
|
1454
|
-
string(className, 'className must be of type string');
|
|
1455
|
-
return this.checkSingleElementCondition('toHaveClass', {
|
|
1456
|
-
className
|
|
1457
|
-
});
|
|
1458
|
-
},
|
|
1459
|
-
async toHaveId(id) {
|
|
1460
|
-
string(id, 'id must be of type string');
|
|
1461
|
-
return this.checkSingleElementCondition('toHaveId', {
|
|
1462
|
-
id
|
|
1463
|
-
});
|
|
1464
|
-
},
|
|
1465
|
-
async toHaveCount(count) {
|
|
1466
|
-
number(count, 'count must be of type number');
|
|
1467
|
-
return this.checkMultiElementCondition('toHaveCount', {
|
|
1468
|
-
count
|
|
1469
|
-
});
|
|
1470
|
-
},
|
|
1471
|
-
async toBeHidden() {
|
|
1472
|
-
return this.checkMultiElementCondition('toBeHidden', {});
|
|
1473
|
-
},
|
|
1474
|
-
get not() {
|
|
1475
|
-
this.negated = true;
|
|
1476
|
-
return this;
|
|
1374
|
+
return new Expect(locator);
|
|
1375
|
+
};
|
|
1376
|
+
class Expect {
|
|
1377
|
+
negated = false;
|
|
1378
|
+
constructor(locator, negated = false) {
|
|
1379
|
+
this.locator = locator;
|
|
1380
|
+
this.negated = negated;
|
|
1381
|
+
}
|
|
1382
|
+
async checkSingleElementCondition(fnName, options) {
|
|
1383
|
+
// TODO add rpcId property to locator instead
|
|
1384
|
+
const result = await locatorInvoke(this.locator, 'TestFrameWork.checkSingleElementCondition', this.locator, fnName, options);
|
|
1385
|
+
if (result && result.error) {
|
|
1386
|
+
const fn = getFunction(fnName);
|
|
1387
|
+
const errorInfo = await fn(this.locator, options);
|
|
1388
|
+
throw new AssertionError(errorInfo);
|
|
1477
1389
|
}
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1390
|
+
}
|
|
1391
|
+
async checkMultiElementCondition(fnName, options) {
|
|
1392
|
+
const result = await locatorInvoke(this.locator, 'TestFrameWork.checkMultiElementCondition', this.locator, fnName, options);
|
|
1393
|
+
if (result && result.error) {
|
|
1394
|
+
const fn = getFunction(fnName);
|
|
1395
|
+
const errorInfo = await fn(this.locator, options);
|
|
1396
|
+
throw new AssertionError(errorInfo);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
async toBeVisible() {
|
|
1400
|
+
if (this.negated) {
|
|
1401
|
+
throw new Error('use toBeHidden instead of not.toBeVisible');
|
|
1402
|
+
}
|
|
1403
|
+
return this.checkSingleElementCondition('toBeVisible', {});
|
|
1404
|
+
}
|
|
1405
|
+
async toHaveText(text) {
|
|
1406
|
+
string(text, 'text must be of type string');
|
|
1407
|
+
return this.checkSingleElementCondition('toHaveText', {
|
|
1408
|
+
text
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
async toContainText(text) {
|
|
1412
|
+
string(text, 'text must be of type string');
|
|
1413
|
+
return this.checkSingleElementCondition('toContainText', {
|
|
1414
|
+
text
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
async toHaveValue(value) {
|
|
1418
|
+
string(value, 'value must be of type string');
|
|
1419
|
+
return this.checkSingleElementCondition('toHaveValue', {
|
|
1420
|
+
value
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
async toBeFocused() {
|
|
1424
|
+
return this.checkSingleElementCondition('toBeFocused');
|
|
1425
|
+
}
|
|
1426
|
+
async toHaveCSS(key, value) {
|
|
1427
|
+
return this.checkSingleElementCondition('toHaveCss', {
|
|
1428
|
+
key,
|
|
1429
|
+
value
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
async toHaveAttribute(key, value) {
|
|
1433
|
+
string(key, 'key must be of type string');
|
|
1434
|
+
// Assert.string(value, 'value must be of type string')
|
|
1435
|
+
return this.checkSingleElementCondition('toHaveAttribute', {
|
|
1436
|
+
key,
|
|
1437
|
+
value
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
async toHaveJSProperty(key, value) {
|
|
1441
|
+
string(key, 'key must be of type string');
|
|
1442
|
+
return this.checkSingleElementCondition('toHaveJSProperty', {
|
|
1443
|
+
key,
|
|
1444
|
+
value
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
async toHaveClass(className) {
|
|
1448
|
+
string(className, 'className must be of type string');
|
|
1449
|
+
return this.checkSingleElementCondition('toHaveClass', {
|
|
1450
|
+
className
|
|
1451
|
+
});
|
|
1452
|
+
}
|
|
1453
|
+
async toHaveId(id) {
|
|
1454
|
+
string(id, 'id must be of type string');
|
|
1455
|
+
return this.checkSingleElementCondition('toHaveId', {
|
|
1456
|
+
id
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
async toHaveCount(count) {
|
|
1460
|
+
number(count, 'count must be of type number');
|
|
1461
|
+
return this.checkMultiElementCondition('toHaveCount', {
|
|
1462
|
+
count
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
async toBeHidden() {
|
|
1466
|
+
return this.checkMultiElementCondition('toBeHidden', {});
|
|
1467
|
+
}
|
|
1468
|
+
get not() {
|
|
1469
|
+
return new Expect(this.locator, !this.negated);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1480
1472
|
|
|
1481
|
-
const Expect = {
|
|
1473
|
+
const Expect$1 = {
|
|
1482
1474
|
__proto__: null,
|
|
1483
1475
|
expect: expect$1
|
|
1484
1476
|
};
|
|
@@ -1608,7 +1600,7 @@ test.skip = async id => {
|
|
|
1608
1600
|
};
|
|
1609
1601
|
const {
|
|
1610
1602
|
expect
|
|
1611
|
-
} = Expect;
|
|
1603
|
+
} = Expect$1;
|
|
1612
1604
|
|
|
1613
1605
|
const TestFrameWork = {
|
|
1614
1606
|
__proto__: null,
|
|
@@ -1872,8 +1864,7 @@ const areSelectionsEqual = (a, b) => {
|
|
|
1872
1864
|
};
|
|
1873
1865
|
|
|
1874
1866
|
const send = async port => {
|
|
1875
|
-
|
|
1876
|
-
await sendMessagePortToEditorWorker(port, rpcId);
|
|
1867
|
+
await sendMessagePortToEditorWorker(port, TestWorker);
|
|
1877
1868
|
};
|
|
1878
1869
|
const launchEditorWorkerRpc = async () => {
|
|
1879
1870
|
const rpc = await TransferMessagePortRpcParent.create({
|
|
@@ -3357,6 +3348,7 @@ const waitForFirstEventEvent = async port => {
|
|
|
3357
3348
|
};
|
|
3358
3349
|
|
|
3359
3350
|
const createPortIpc = async webViewId => {
|
|
3351
|
+
// TODO use transforpemssageportrpc
|
|
3360
3352
|
const {
|
|
3361
3353
|
port1,
|
|
3362
3354
|
port2
|