@lvce-editor/test-worker 4.44.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/api.d.ts CHANGED
@@ -131,6 +131,10 @@ declare const selectIndices: (indices: readonly number[]) => Promise<void>;
131
131
  declare const toggleIndividualSelection: (index: number) => Promise<void>;
132
132
  declare const addWebExtension: (relativePath: string) => Promise<void>;
133
133
  declare const addNodeExtension: (relativePath: string) => Promise<void>;
134
+ declare const handleClickCategory: (categoryId: string) => Promise<void>;
135
+ declare const handleClickEnable: () => Promise<void>;
136
+ declare const handleClickDisable: () => Promise<void>;
137
+ declare const handleClickSetColorTheme: () => Promise<void>;
134
138
  declare const selectFeature: (name: string) => Promise<void>;
135
139
  declare const selectTab: (name: string) => Promise<void>;
136
140
  declare const selectDetails: () => Promise<void>;
@@ -346,7 +350,7 @@ declare namespace Extension {
346
350
  export { addNodeExtension, addWebExtension };
347
351
  }
348
352
  declare namespace ExtensionDetail {
349
- export { handleScroll, open, openCommands, openFeature, openJsonValidation, openRuntimeStatus, openSettings, openThemes, openWebViews, selectChangelog, selectDetails, selectFeature, selectFeatures, selectTab };
353
+ export { handleClickCategory, handleClickDisable, handleClickEnable, handleClickSetColorTheme, handleScroll, open, openCommands, openFeature, openJsonValidation, openRuntimeStatus, openSettings, openThemes, openWebViews, selectChangelog, selectDetails, selectFeature, selectFeatures, selectTab };
350
354
  }
351
355
  declare namespace FileSystem {
352
356
  export { chmod, createExecutable, createExecutableFrom, getTmpDir, mkdir, readFile, remove, writeFile, writeJson };
@@ -521,7 +521,7 @@ const create$4 = (method, params) => {
521
521
  };
522
522
  };
523
523
  const callbacks = Object.create(null);
524
- const set$2 = (id, fn) => {
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$2(id, resolve);
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 formatDuration = duration => {
1038
- return duration.toFixed(2) + 'ms';
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$g = (id, rpc) => {
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$g(rpcId, rpc);
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
- const RendererWorker$1 = 1;
1071
+
1088
1072
  const {
1089
- invoke: invoke$3,
1090
- invokeAndTransfer: invokeAndTransfer$3,
1091
- set: set$3} = create$1(RendererWorker$1);
1092
- const sendMessagePortToEditorWorker$1 = async (port, rpcId) => {
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$3('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
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
- set: set$1,
1106
- invoke: invoke$1,
1107
- invokeAndTransfer,
1108
- sendMessagePortToEditorWorker
1109
- } = RendererWorker;
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,101 +1371,106 @@ const number = (value, message) => {
1383
1371
  };
1384
1372
 
1385
1373
  const expect$1 = locator => {
1386
- return {
1387
- async checkSingleElementCondition(fnName, options) {
1388
- // TODO add rpcId property to locator instead
1389
- const result = await locatorInvoke(locator, 'TestFrameWork.checkSingleElementCondition', locator, fnName, options);
1390
- if (result && result.error) {
1391
- const fn = getFunction(fnName);
1392
- const errorInfo = await fn(locator, options);
1393
- throw new AssertionError(errorInfo);
1394
- }
1395
- },
1396
- async checkMultiElementCondition(fnName, options) {
1397
- const result = await locatorInvoke(locator, 'TestFrameWork.checkMultiElementCondition', locator, fnName, options);
1398
- if (result && result.error) {
1399
- const fn = getFunction(fnName);
1400
- const errorInfo = await fn(locator, options);
1401
- throw new AssertionError(errorInfo);
1402
- }
1403
- },
1404
- async toBeVisible() {
1405
- if (this.negated) {
1406
- throw new Error('use toBeHidden instead of not.toBeVisible');
1407
- }
1408
- return this.checkSingleElementCondition('toBeVisible', {});
1409
- },
1410
- async toHaveText(text) {
1411
- string(text, 'text must be of type string');
1412
- return this.checkSingleElementCondition('toHaveText', {
1413
- text
1414
- });
1415
- },
1416
- async toContainText(text) {
1417
- string(text, 'text must be of type string');
1418
- return this.checkSingleElementCondition('toContainText', {
1419
- text
1420
- });
1421
- },
1422
- async toHaveValue(value) {
1423
- string(value, 'value must be of type string');
1424
- return this.checkSingleElementCondition('toHaveValue', {
1425
- value
1426
- });
1427
- },
1428
- async toBeFocused() {
1429
- return this.checkSingleElementCondition('toBeFocused');
1430
- },
1431
- async toHaveCSS(key, value) {
1432
- return this.checkSingleElementCondition('toHaveCss', {
1433
- key,
1434
- value
1435
- });
1436
- },
1437
- async toHaveAttribute(key, value) {
1438
- string(key, 'key must be of type string');
1439
- // Assert.string(value, 'value must be of type string')
1440
- return this.checkSingleElementCondition('toHaveAttribute', {
1441
- key,
1442
- value
1443
- });
1444
- },
1445
- async toHaveJSProperty(key, value) {
1446
- string(key, 'key must be of type string');
1447
- return this.checkSingleElementCondition('toHaveJSProperty', {
1448
- key,
1449
- value
1450
- });
1451
- },
1452
- async toHaveClass(className) {
1453
- string(className, 'className must be of type string');
1454
- return this.checkSingleElementCondition('toHaveClass', {
1455
- className
1456
- });
1457
- },
1458
- async toHaveId(id) {
1459
- string(id, 'id must be of type string');
1460
- return this.checkSingleElementCondition('toHaveId', {
1461
- id
1462
- });
1463
- },
1464
- async toHaveCount(count) {
1465
- number(count, 'count must be of type number');
1466
- return this.checkMultiElementCondition('toHaveCount', {
1467
- count
1468
- });
1469
- },
1470
- async toBeHidden() {
1471
- return this.checkMultiElementCondition('toBeHidden', {});
1472
- },
1473
- get not() {
1474
- this.negated = true;
1475
- 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);
1476
1389
  }
1477
- };
1478
- };
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
+ }
1479
1472
 
1480
- const Expect = {
1473
+ const Expect$1 = {
1481
1474
  __proto__: null,
1482
1475
  expect: expect$1
1483
1476
  };
@@ -1528,70 +1521,68 @@ const toButtonNumber = buttonType => {
1528
1521
  };
1529
1522
 
1530
1523
  const create = (selector, options = {}) => {
1531
- // @ts-ignore
1532
1524
  return new Locator(selector, options);
1533
1525
  };
1534
- const Locator = function (selector, {
1535
- nth = -1,
1536
- hasText = ''
1537
- } = {}) {
1538
- // @ts-ignore
1539
- this._selector = selector;
1540
- // @ts-ignore
1541
- this._nth = nth;
1542
- // @ts-ignore
1543
- this._hasText = hasText;
1544
- };
1545
1526
  const performAction = async (locator, action, options) => {
1546
1527
  const invoke = getLocatorInvoke(locator);
1547
1528
  return invoke('TestFrameWork.performAction', locator, action, options);
1548
1529
  };
1549
- Locator.prototype.click = async function ({
1550
- button = 'left'
1551
- } = {}) {
1552
- const options = {
1553
- cancable: true,
1554
- bubbles: true,
1555
- button: toButtonNumber(button),
1556
- detail: 1
1557
- };
1558
- return performAction(this, 'click', options);
1559
- };
1560
- Locator.prototype.hover = async function () {
1561
- const options = {
1562
- cancable: true,
1563
- bubbles: true
1564
- };
1565
- return performAction(this, 'hover', options);
1566
- };
1567
- Locator.prototype.first = function () {
1568
- return create(this._selector, {
1569
- nth: 0
1570
- });
1571
- };
1572
- Locator.prototype.locator = function (subSelector) {
1573
- if (this._nth !== -1) {
1574
- return create(`${this._selector}:nth-of-type(${this._nth + 1}) ${subSelector}`);
1530
+ class Locator {
1531
+ constructor(selector, {
1532
+ nth = -1,
1533
+ hasText = ''
1534
+ } = {}) {
1535
+ this._selector = selector;
1536
+ this._nth = nth;
1537
+ this._hasText = hasText;
1538
+ }
1539
+ async click({
1540
+ button = 'left'
1541
+ } = {}) {
1542
+ const options = {
1543
+ cancable: true,
1544
+ bubbles: true,
1545
+ button: toButtonNumber(button),
1546
+ detail: 1
1547
+ };
1548
+ return performAction(this, 'click', options);
1575
1549
  }
1576
- return create(`${this._selector} ${subSelector}`);
1577
- };
1578
- Locator.prototype.nth = function (nth) {
1579
- return create(this._selector, {
1580
- nth
1581
- });
1582
- };
1583
- Locator.prototype.type = async function (text) {
1584
- const options = {
1585
- text
1586
- };
1587
- return performAction(this, 'type', options);
1588
- };
1589
- Locator.prototype.dispatchEvent = async function (type, init) {
1590
- return performAction(this, 'dispatchEvent', {
1591
- type,
1592
- init
1593
- });
1594
- };
1550
+ async hover() {
1551
+ const options = {
1552
+ cancable: true,
1553
+ bubbles: true
1554
+ };
1555
+ return performAction(this, 'hover', options);
1556
+ }
1557
+ first() {
1558
+ return create(this._selector, {
1559
+ nth: 0
1560
+ });
1561
+ }
1562
+ locator(subSelector) {
1563
+ if (this._nth !== -1) {
1564
+ return create(`${this._selector}:nth-of-type(${this._nth + 1}) ${subSelector}`);
1565
+ }
1566
+ return create(`${this._selector} ${subSelector}`);
1567
+ }
1568
+ nth(nth) {
1569
+ return create(this._selector, {
1570
+ nth
1571
+ });
1572
+ }
1573
+ async type(text) {
1574
+ const options = {
1575
+ text
1576
+ };
1577
+ return performAction(this, 'type', options);
1578
+ }
1579
+ async dispatchEvent(type, init) {
1580
+ return performAction(this, 'dispatchEvent', {
1581
+ type,
1582
+ init
1583
+ });
1584
+ }
1585
+ }
1595
1586
 
1596
1587
  const getTmpDir$1 = async () => {
1597
1588
  return 'memfs://';
@@ -1609,7 +1600,7 @@ test.skip = async id => {
1609
1600
  };
1610
1601
  const {
1611
1602
  expect
1612
- } = Expect;
1603
+ } = Expect$1;
1613
1604
 
1614
1605
  const TestFrameWork = {
1615
1606
  __proto__: null,
@@ -1873,8 +1864,7 @@ const areSelectionsEqual = (a, b) => {
1873
1864
  };
1874
1865
 
1875
1866
  const send = async port => {
1876
- const rpcId = 9001;
1877
- await sendMessagePortToEditorWorker(port, rpcId);
1867
+ await sendMessagePortToEditorWorker(port, TestWorker);
1878
1868
  };
1879
1869
  const launchEditorWorkerRpc = async () => {
1880
1870
  const rpc = await TransferMessagePortRpcParent.create({
@@ -2359,6 +2349,22 @@ const TestFrameWorkComponentExtension = {
2359
2349
  addWebExtension
2360
2350
  };
2361
2351
 
2352
+ const handleClickCategory = async categoryId => {
2353
+ // @ts-ignore
2354
+ await invoke$1('ExtensionDetail.handleClickCategory', categoryId);
2355
+ };
2356
+ const handleClickEnable = async () => {
2357
+ // @ts-ignore
2358
+ await invoke$1('ExtensionDetail.handleClickEnable');
2359
+ };
2360
+ const handleClickDisable = async () => {
2361
+ // @ts-ignore
2362
+ await invoke$1('ExtensionDetail.handleClickDisable');
2363
+ };
2364
+ const handleClickSetColorTheme = async () => {
2365
+ // @ts-ignore
2366
+ await invoke$1('ExtensionDetail.handleClickSetColorTheme');
2367
+ };
2362
2368
  const selectFeature = name => {
2363
2369
  return invoke$1('ExtensionDetail.selectFeature', name);
2364
2370
  };
@@ -2407,6 +2413,10 @@ const handleScroll$1 = async scrollTop => {
2407
2413
 
2408
2414
  const TestFrameWorkComponentExtensionDetail = {
2409
2415
  __proto__: null,
2416
+ handleClickCategory,
2417
+ handleClickDisable,
2418
+ handleClickEnable,
2419
+ handleClickSetColorTheme,
2410
2420
  handleScroll: handleScroll$1,
2411
2421
  open: open$4,
2412
2422
  openCommands,
@@ -3338,6 +3348,7 @@ const waitForFirstEventEvent = async port => {
3338
3348
  };
3339
3349
 
3340
3350
  const createPortIpc = async webViewId => {
3351
+ // TODO use transforpemssageportrpc
3341
3352
  const {
3342
3353
  port1,
3343
3354
  port2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "4.44.0",
3
+ "version": "5.1.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",