@lvce-editor/test-worker 5.0.0 → 5.2.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
@@ -92,6 +92,7 @@ declare const shouldHaveText$1: (expectedText: string) => Promise<void>;
92
92
  declare const shouldHaveSelections: (expectedSelections: Uint32Array) => Promise<void>;
93
93
  declare const selectIndex: (index: number) => Promise<void>;
94
94
  declare const selectCurrentIndex: () => Promise<void>;
95
+ declare const handleWheel: (deltaMode: number, deltaY: number) => Promise<void>;
95
96
  declare const selectIndex$1: (index: number) => Promise<void>;
96
97
  declare const selectCurrentIndex$1: () => Promise<void>;
97
98
  declare const openContextMenu$1: (index: number) => Promise<void>;
@@ -171,7 +172,7 @@ declare const focusLast$2: () => Promise<void>;
171
172
  declare const open$1: () => Promise<void>;
172
173
  declare const handleInput: (value: string) => Promise<void>;
173
174
  declare const handleClick$2: (x: number, y: number) => Promise<void>;
174
- declare const handleWheel: (deltaMode: number, deltaY: number) => Promise<void>;
175
+ declare const handleWheel$1: (deltaMode: number, deltaY: number) => Promise<void>;
175
176
  declare const handleDoubleClick: (x: number, y: number) => Promise<void>;
176
177
  declare const focusNext$5: () => Promise<void>;
177
178
  declare const focusPrevious$3: () => Promise<void>;
@@ -256,7 +257,7 @@ declare const focusFirst$6: () => Promise<void>;
256
257
  declare const focusIndex$4: (index: number) => Promise<void>;
257
258
  declare const selectIndex$5: (index: number) => Promise<void>;
258
259
  declare const focusNext$8: () => Promise<void>;
259
- declare const handleWheel$1: (deltaMode: number, deltaY: number) => Promise<void>;
260
+ declare const handleWheel$2: (deltaMode: number, deltaY: number) => Promise<void>;
260
261
  declare const focusNextPage: () => Promise<void>;
261
262
  declare const focusPreviousPage: () => Promise<void>;
262
263
  declare const focusPrevious$6: () => Promise<void>;
@@ -338,7 +339,7 @@ declare namespace Editor {
338
339
  export { addAllMissingImports, closeColorPicker, closeCompletion, closeCompletionDetails, copy, copyLineDown, copyLineUp, cursorCharacterLeft, cursorCharacterRight, cursorDown, cursorEnd, cursorHome, cursorUp, cursorWordLeft, cursorWordPartLeft, cursorWordPartRight, cursorWordRight, deleteAllLeft, deleteAllRight, executeTabCompletion, findAllImplementations, findAllReferences, format, getSelections, getText, goToDefinition, goToTypeDefinition, growSelection, insertLineBreak, invokeBraceCompletion, invokeTabCompletion, openColorPicker, openCompletion, openCompletionDetails, openContextMenu, openEditorContextMenu, openFind, openFindWidget, openHover, openRename, openSourceActions, organizeImports, rename, rename2, selectAll, setCursor, setDeltaY, setSelections, shouldHaveSelections, shouldHaveText$1 as shouldHaveText, showHover, sortImports, sourceActionsSelectCurrent, toggleBlockComment, toggleCompletionDetails, toggleLineComment, type };
339
340
  }
340
341
  declare namespace EditorCompletion {
341
- export { selectCurrentIndex, selectIndex };
342
+ export { handleWheel, selectCurrentIndex, selectIndex };
342
343
  }
343
344
  declare namespace EditorSourceAction {
344
345
  export { selectCurrentIndex$1 as selectCurrentIndex, selectIndex$1 as selectIndex };
@@ -365,7 +366,7 @@ declare namespace IframeInspector {
365
366
  export { focusFirst$2 as focusFirst, focusLast$2 as focusLast, focusNext$4 as focusNext, focusPrevious$2 as focusPrevious, selectIndex$2 as selectIndex };
366
367
  }
367
368
  declare namespace KeyBindingsEditor {
368
- export { addKeyBinding, changeWhenExpression, clearInput, copyCommandId, copyCommandTitle, focusFirst$3 as focusFirst, focusIndex$1 as focusIndex, focusLast$3 as focusLast, focusNext$5 as focusNext, focusPrevious$3 as focusPrevious, handleClick$2 as handleClick, handleContextMenu$1 as handleContextMenu, handleDoubleClick, handleInput, handleWheel, open$1 as open, removeKeyBinding, resetKeyBinding, showSameKeyBindings, sortByPrecedence, startRecordingKeys, stopRecordingKeys, toggleRecordingKeys };
369
+ export { addKeyBinding, changeWhenExpression, clearInput, copyCommandId, copyCommandTitle, focusFirst$3 as focusFirst, focusIndex$1 as focusIndex, focusLast$3 as focusLast, focusNext$5 as focusNext, focusPrevious$3 as focusPrevious, handleClick$2 as handleClick, handleContextMenu$1 as handleContextMenu, handleDoubleClick, handleInput, handleWheel$1 as handleWheel, open$1 as open, removeKeyBinding, resetKeyBinding, showSameKeyBindings, sortByPrecedence, startRecordingKeys, stopRecordingKeys, toggleRecordingKeys };
369
370
  }
370
371
  declare namespace KeyBoard {
371
372
  export { press };
@@ -392,7 +393,7 @@ declare namespace RunAndDebug {
392
393
  export { acceptWatchExpressionEdit, addWatchExpression, handleClickSectionWatch, handleRename, handleSpace, handleWatchValueChange, selectIndex$4 as selectIndex, setPauseOnExceptions };
393
394
  }
394
395
  declare namespace Search {
395
- export { clearSearchResults, collapseDetails, dismissItem, focusFirst$6 as focusFirst, focusIndex$4 as focusIndex, focusNext$8 as focusNext, focusNextPage, focusPrevious$6 as focusPrevious, focusPreviousPage, handleWheel$1 as handleWheel, openDetails, replaceAll, selectIndex$5 as selectIndex, setExcludeValue, setIncludeValue, setReplaceValue, setValue$2 as setValue, toggleMatchCase, toggleMatchWholeWord, togglePreserveCase, toggleReplace, toggleSearchDetails, toggleUseRegularExpression };
396
+ export { clearSearchResults, collapseDetails, dismissItem, focusFirst$6 as focusFirst, focusIndex$4 as focusIndex, focusNext$8 as focusNext, focusNextPage, focusPrevious$6 as focusPrevious, focusPreviousPage, handleWheel$2 as handleWheel, openDetails, replaceAll, selectIndex$5 as selectIndex, setExcludeValue, setIncludeValue, setReplaceValue, setValue$2 as setValue, toggleMatchCase, toggleMatchWholeWord, togglePreserveCase, toggleReplace, toggleSearchDetails, toggleUseRegularExpression };
396
397
  }
397
398
  declare namespace Settings {
398
399
  export { update };
@@ -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) {
@@ -1207,10 +1195,11 @@ const getLocatorInvoke = locator => {
1207
1195
  const module = get(locator.webViewId);
1208
1196
  return module.invoke;
1209
1197
  }
1198
+ // @ts-ignore
1210
1199
  return invoke$1;
1211
1200
  };
1212
1201
 
1213
- const locatorInvoke = (locator, method, ...params) => {
1202
+ const locatorInvoke = async (locator, method, ...params) => {
1214
1203
  object(locator);
1215
1204
  string$1(method);
1216
1205
  const invoke = getLocatorInvoke(locator);
@@ -1383,102 +1372,106 @@ const number = (value, message) => {
1383
1372
  };
1384
1373
 
1385
1374
  const expect$1 = locator => {
1386
- return {
1387
- negated: false,
1388
- async checkSingleElementCondition(fnName, options) {
1389
- // TODO add rpcId property to locator instead
1390
- const result = await locatorInvoke(locator, 'TestFrameWork.checkSingleElementCondition', locator, fnName, options);
1391
- if (result && result.error) {
1392
- const fn = getFunction(fnName);
1393
- const errorInfo = await fn(locator, options);
1394
- throw new AssertionError(errorInfo);
1395
- }
1396
- },
1397
- async checkMultiElementCondition(fnName, options) {
1398
- const result = await locatorInvoke(locator, 'TestFrameWork.checkMultiElementCondition', locator, fnName, options);
1399
- if (result && result.error) {
1400
- const fn = getFunction(fnName);
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;
1375
+ return new Expect(locator);
1376
+ };
1377
+ class Expect {
1378
+ negated = false;
1379
+ constructor(locator, negated = false) {
1380
+ this.locator = locator;
1381
+ this.negated = negated;
1382
+ }
1383
+ async checkSingleElementCondition(fnName, options) {
1384
+ // TODO add rpcId property to locator instead
1385
+ const result = await locatorInvoke(this.locator, 'TestFrameWork.checkSingleElementCondition', this.locator, fnName, options);
1386
+ if (result && result.error) {
1387
+ const fn = getFunction(fnName);
1388
+ const errorInfo = await fn(this.locator, options);
1389
+ throw new AssertionError(errorInfo);
1477
1390
  }
1478
- };
1479
- };
1391
+ }
1392
+ async checkMultiElementCondition(fnName, options) {
1393
+ const result = await locatorInvoke(this.locator, 'TestFrameWork.checkMultiElementCondition', this.locator, fnName, options);
1394
+ if (result && result.error) {
1395
+ const fn = getFunction(fnName);
1396
+ const errorInfo = await fn(this.locator, options);
1397
+ throw new AssertionError(errorInfo);
1398
+ }
1399
+ }
1400
+ async toBeVisible() {
1401
+ if (this.negated) {
1402
+ throw new Error('use toBeHidden instead of not.toBeVisible');
1403
+ }
1404
+ return this.checkSingleElementCondition('toBeVisible', {});
1405
+ }
1406
+ async toHaveText(text) {
1407
+ string(text, 'text must be of type string');
1408
+ return this.checkSingleElementCondition('toHaveText', {
1409
+ text
1410
+ });
1411
+ }
1412
+ async toContainText(text) {
1413
+ string(text, 'text must be of type string');
1414
+ return this.checkSingleElementCondition('toContainText', {
1415
+ text
1416
+ });
1417
+ }
1418
+ async toHaveValue(value) {
1419
+ string(value, 'value must be of type string');
1420
+ return this.checkSingleElementCondition('toHaveValue', {
1421
+ value
1422
+ });
1423
+ }
1424
+ async toBeFocused() {
1425
+ return this.checkSingleElementCondition('toBeFocused');
1426
+ }
1427
+ async toHaveCSS(key, value) {
1428
+ return this.checkSingleElementCondition('toHaveCss', {
1429
+ key,
1430
+ value
1431
+ });
1432
+ }
1433
+ async toHaveAttribute(key, value) {
1434
+ string(key, 'key must be of type string');
1435
+ // Assert.string(value, 'value must be of type string')
1436
+ return this.checkSingleElementCondition('toHaveAttribute', {
1437
+ key,
1438
+ value
1439
+ });
1440
+ }
1441
+ async toHaveJSProperty(key, value) {
1442
+ string(key, 'key must be of type string');
1443
+ return this.checkSingleElementCondition('toHaveJSProperty', {
1444
+ key,
1445
+ value
1446
+ });
1447
+ }
1448
+ async toHaveClass(className) {
1449
+ string(className, 'className must be of type string');
1450
+ return this.checkSingleElementCondition('toHaveClass', {
1451
+ className
1452
+ });
1453
+ }
1454
+ async toHaveId(id) {
1455
+ string(id, 'id must be of type string');
1456
+ return this.checkSingleElementCondition('toHaveId', {
1457
+ id
1458
+ });
1459
+ }
1460
+ async toHaveCount(count) {
1461
+ number(count, 'count must be of type number');
1462
+ return this.checkMultiElementCondition('toHaveCount', {
1463
+ count
1464
+ });
1465
+ }
1466
+ async toBeHidden() {
1467
+ return this.checkMultiElementCondition('toBeHidden', {});
1468
+ }
1469
+ get not() {
1470
+ return new Expect(this.locator, !this.negated);
1471
+ }
1472
+ }
1480
1473
 
1481
- const Expect = {
1474
+ const Expect$1 = {
1482
1475
  __proto__: null,
1483
1476
  expect: expect$1
1484
1477
  };
@@ -1608,7 +1601,7 @@ test.skip = async id => {
1608
1601
  };
1609
1602
  const {
1610
1603
  expect
1611
- } = Expect;
1604
+ } = Expect$1;
1612
1605
 
1613
1606
  const TestFrameWork = {
1614
1607
  __proto__: null,
@@ -1872,8 +1865,7 @@ const areSelectionsEqual = (a, b) => {
1872
1865
  };
1873
1866
 
1874
1867
  const send = async port => {
1875
- const rpcId = 9001;
1876
- await sendMessagePortToEditorWorker(port, rpcId);
1868
+ await sendMessagePortToEditorWorker(port, TestWorker);
1877
1869
  };
1878
1870
  const launchEditorWorkerRpc = async () => {
1879
1871
  const rpc = await TransferMessagePortRpcParent.create({
@@ -2164,9 +2156,14 @@ const selectIndex$6 = async index => {
2164
2156
  const selectCurrentIndex$2 = async () => {
2165
2157
  await invoke$1('EditorCompletion.selectCurrentIndex');
2166
2158
  };
2159
+ const handleWheel$2 = async (deltaMode, deltaY) => {
2160
+ // @ts-ignore
2161
+ await invoke$1('EditorCompletion.handleWheel', deltaMode, deltaY);
2162
+ };
2167
2163
 
2168
2164
  const TestFrameWorkComponentEditorCompletion = {
2169
2165
  __proto__: null,
2166
+ handleWheel: handleWheel$2,
2170
2167
  selectCurrentIndex: selectCurrentIndex$2,
2171
2168
  selectIndex: selectIndex$6
2172
2169
  };
@@ -3357,6 +3354,7 @@ const waitForFirstEventEvent = async port => {
3357
3354
  };
3358
3355
 
3359
3356
  const createPortIpc = async webViewId => {
3357
+ // TODO use transforpemssageportrpc
3360
3358
  const {
3361
3359
  port1,
3362
3360
  port2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "5.0.0",
3
+ "version": "5.2.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",