@lvce-editor/test-worker 10.8.0 → 10.9.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
@@ -1,17 +1,17 @@
1
1
  export interface LocatorExpect {
2
+ readonly not: LocatorExpect;
3
+ readonly toBeFocused: () => Promise<void>;
4
+ readonly toBeHidden: () => Promise<void>;
2
5
  readonly toBeVisible: () => Promise<void>;
3
- readonly toHaveText: (text: string) => Promise<void>;
4
6
  readonly toContainText: (text: string) => Promise<void>;
5
- readonly toHaveValue: (value: string) => Promise<void>;
6
- readonly toBeFocused: () => Promise<void>;
7
- readonly toHaveCSS: (key: string, value: string) => Promise<void>;
8
7
  readonly toHaveAttribute: (key: string, value: string | null) => Promise<void>;
9
- readonly toHaveJSProperty: (key: string, value: any) => Promise<void>;
10
8
  readonly toHaveClass: (className: string) => Promise<void>;
11
- readonly toHaveId: (id: string) => Promise<void>;
12
9
  readonly toHaveCount: (count: number) => Promise<void>;
13
- readonly toBeHidden: () => Promise<void>;
14
- readonly not: LocatorExpect;
10
+ readonly toHaveCSS: (key: string, value: string) => Promise<void>;
11
+ readonly toHaveId: (id: string) => Promise<void>;
12
+ readonly toHaveJSProperty: (key: string, value: any) => Promise<void>;
13
+ readonly toHaveText: (text: string) => Promise<void>;
14
+ readonly toHaveValue: (value: string) => Promise<void>;
15
15
  }
16
16
 
17
17
  interface LocatorClickOptions {
@@ -20,12 +20,12 @@ interface LocatorClickOptions {
20
20
 
21
21
  interface ILocatorExternal {
22
22
  readonly click: (options: LocatorClickOptions) => Promise<void>;
23
- readonly hover: () => Promise<void>;
23
+ readonly dispatchEvent: (type: string, init: string) => Promise<void>;
24
24
  readonly first: () => ILocatorExternal;
25
+ readonly hover: () => Promise<void>;
25
26
  readonly locator: (subSelector: string) => ILocatorExternal;
26
27
  readonly nth: (nth: number) => ILocatorExternal;
27
28
  readonly type: (text: string) => Promise<void>;
28
- readonly dispatchEvent: (type: string, init: string) => Promise<void>;
29
29
  }
30
30
 
31
31
  interface LocatorConstructor {
@@ -33,17 +33,17 @@ interface LocatorConstructor {
33
33
  }
34
34
 
35
35
  export interface Diagnostic {
36
- readonly rowIndex: number;
37
36
  readonly columnIndex: number;
38
- readonly endRowIndex: number;
39
37
  readonly endColumnIndex: number;
38
+ readonly endRowIndex: number;
40
39
  readonly message: string;
40
+ readonly rowIndex: number;
41
41
  readonly type: "error" | "warning";
42
42
  }
43
43
 
44
44
  export interface DroppedFileHandle {
45
- readonly id: number;
46
45
  readonly file: File;
46
+ readonly id: number;
47
47
  }
48
48
 
49
49
  export interface FileSystemTmpDirOptions {
@@ -257,12 +257,16 @@ interface Extension {
257
257
  }
258
258
 
259
259
  interface ExtensionDetail {
260
+ readonly copyReadmeLink: (href: string) => Promise<void>;
260
261
  readonly handleClickCategory: (categoryId: string) => Promise<void>;
261
262
  readonly handleClickDisable: () => Promise<void>;
262
263
  readonly handleClickEnable: () => Promise<void>;
263
264
  readonly handleClickSetColorTheme: () => Promise<void>;
265
+ readonly handleClickUninstall: () => Promise<void>;
266
+ readonly handleImageContextMenu: () => Promise<void>;
264
267
  readonly handleReadmeContextMenu: (x: number, y: number, nodeName: string, href: string) => Promise<void>;
265
268
  readonly handleScroll: (scrollTop: number) => Promise<void>;
269
+ readonly hideSizeLink: () => Promise<void>;
266
270
  readonly open: (extensionId: string) => Promise<void>;
267
271
  readonly openCommands: () => Promise<void>;
268
272
  readonly openFeature: (featureName: string) => Promise<void>;
@@ -1179,8 +1179,8 @@ const toHaveValue = (locator, {
1179
1179
  const toHaveText = async (locator, options) => {
1180
1180
  const locatorString = printLocator(locator);
1181
1181
  const {
1182
- wasFound,
1183
- actual
1182
+ actual,
1183
+ wasFound
1184
1184
  } = await locatorInvoke(locator, 'TestFrameWork.checkConditionError', 'toHaveText', locator, options);
1185
1185
  const {
1186
1186
  text
@@ -1193,8 +1193,8 @@ const toHaveText = async (locator, options) => {
1193
1193
  const toContainText = async (locator, options) => {
1194
1194
  const locatorString = printLocator(locator);
1195
1195
  const {
1196
- wasFound,
1197
- actual
1196
+ actual,
1197
+ wasFound
1198
1198
  } = await locatorInvoke(locator, 'TestFrameWork.checkConditionError', 'toContainText', locator, options);
1199
1199
  const {
1200
1200
  text
@@ -1207,8 +1207,8 @@ const toContainText = async (locator, options) => {
1207
1207
  const toHaveAttribute = async (locator, options) => {
1208
1208
  const locatorString = printLocator(locator);
1209
1209
  const {
1210
- wasFound,
1211
- actual
1210
+ actual,
1211
+ wasFound
1212
1212
  } = await locatorInvoke(locator, 'TestFrameWork.checkConditionError', 'toHaveAttribute', locator, options);
1213
1213
  const {
1214
1214
  key,
@@ -1250,8 +1250,8 @@ const toHaveClass = async (locator, options) => {
1250
1250
  };
1251
1251
  const toHaveId = async (locator, options) => {
1252
1252
  const {
1253
- wasFound,
1254
- actual
1253
+ actual,
1254
+ wasFound
1255
1255
  } = await locatorInvoke(locator, 'TestFrameWork.checkConditionError', 'toHaveId', locator, options);
1256
1256
  const locatorString = printLocator(locator);
1257
1257
  const {
@@ -1268,8 +1268,8 @@ const toBeHidden = locator => {
1268
1268
  };
1269
1269
  const toHaveCss = async (locator, options) => {
1270
1270
  const {
1271
- wasFound,
1272
- actual
1271
+ actual,
1272
+ wasFound
1273
1273
  } = await locatorInvoke(locator, 'TestFrameWork.checkConditionError', 'toHaveCss', locator, options);
1274
1274
  const locatorString = printLocator(locator);
1275
1275
  const {
@@ -1283,8 +1283,8 @@ const toHaveCss = async (locator, options) => {
1283
1283
  };
1284
1284
  const toHaveJSProperty = async (locator, options) => {
1285
1285
  const {
1286
- wasFound,
1287
- actual
1286
+ actual,
1287
+ wasFound
1288
1288
  } = await locatorInvoke(locator, 'TestFrameWork.checkConditionError', 'toHaveJSProperty', locator, options);
1289
1289
  const locatorString = printLocator(locator);
1290
1290
  const {
@@ -1299,30 +1299,30 @@ const toHaveJSProperty = async (locator, options) => {
1299
1299
 
1300
1300
  const getFunction = fnName => {
1301
1301
  switch (fnName) {
1302
+ case 'toBeFocused':
1303
+ return toBeFocused;
1304
+ case 'toBeHidden':
1305
+ return toBeHidden;
1302
1306
  case 'toBeVisible':
1303
1307
  return toBeVisible;
1304
- case 'toHaveValue':
1305
- return toHaveValue;
1306
- case 'toHaveText':
1307
- return toHaveText;
1308
1308
  case 'toContainText':
1309
1309
  return toContainText;
1310
1310
  case 'toHaveAttribute':
1311
1311
  return toHaveAttribute;
1312
+ case 'toHaveClass':
1313
+ return toHaveClass;
1312
1314
  case 'toHaveCount':
1313
1315
  return toHaveCount;
1314
- case 'toBeFocused':
1315
- return toBeFocused;
1316
- case 'toHaveId':
1317
- return toHaveId;
1318
- case 'toBeHidden':
1319
- return toBeHidden;
1320
1316
  case 'toHaveCss':
1321
1317
  return toHaveCss;
1322
- case 'toHaveClass':
1323
- return toHaveClass;
1318
+ case 'toHaveId':
1319
+ return toHaveId;
1324
1320
  case 'toHaveJSProperty':
1325
1321
  return toHaveJSProperty;
1322
+ case 'toHaveText':
1323
+ return toHaveText;
1324
+ case 'toHaveValue':
1325
+ return toHaveValue;
1326
1326
  default:
1327
1327
  throw new Error(`unexpected function name ${fnName}`);
1328
1328
  }
@@ -1452,16 +1452,16 @@ const nameAnonymousFunction = (fn, name) => {
1452
1452
  // @ts-nocheck
1453
1453
 
1454
1454
  const state = {
1455
+ mockRpcs: Object.create(null),
1455
1456
  /**
1456
1457
  * @type {any[]}
1457
1458
  */
1458
- pendingTests: [],
1459
- mockRpcs: Object.create(null)
1459
+ pendingTests: []
1460
1460
  };
1461
1461
  const addTest = (name, fn) => {
1462
1462
  state.pendingTests.push({
1463
- name,
1464
- fn
1463
+ fn,
1464
+ name
1465
1465
  });
1466
1466
  };
1467
1467
  const getTests = () => {
@@ -1497,8 +1497,8 @@ const performAction = async (locator, action, options) => {
1497
1497
  };
1498
1498
  class Locator {
1499
1499
  constructor(selector, {
1500
- nth = -1,
1501
- hasText = ''
1500
+ hasText = '',
1501
+ nth = -1
1502
1502
  } = {}) {
1503
1503
  this._selector = selector;
1504
1504
  this._nth = nth;
@@ -1508,17 +1508,17 @@ class Locator {
1508
1508
  button = 'left'
1509
1509
  } = {}) {
1510
1510
  const options = {
1511
- cancable: true,
1512
1511
  bubbles: true,
1513
1512
  button: toButtonNumber(button),
1513
+ cancable: true,
1514
1514
  detail: 1
1515
1515
  };
1516
1516
  return performAction(this, 'click', options);
1517
1517
  }
1518
1518
  async hover() {
1519
1519
  const options = {
1520
- cancable: true,
1521
- bubbles: true
1520
+ bubbles: true,
1521
+ cancable: true
1522
1522
  };
1523
1523
  return performAction(this, 'hover', options);
1524
1524
  }
@@ -1546,8 +1546,8 @@ class Locator {
1546
1546
  }
1547
1547
  async dispatchEvent(type, init) {
1548
1548
  return performAction(this, 'dispatchEvent', {
1549
- type,
1550
- init
1549
+ init,
1550
+ type
1551
1551
  });
1552
1552
  }
1553
1553
  }
@@ -2440,6 +2440,10 @@ const handleReadmeContextMenu = async (x, y, nodeName, href) => {
2440
2440
  // @ts-ignore
2441
2441
  await invoke$1('ExtensionDetail.handleReadmeContextMenu', x, y, nodeName, href);
2442
2442
  };
2443
+ const copyReadmeLink = async href => {
2444
+ // @ts-ignore
2445
+ await invoke$1('ExtensionDetail.copyReadmeLink', href);
2446
+ };
2443
2447
  const handleClickEnable = async () => {
2444
2448
  // @ts-ignore
2445
2449
  await invoke$1('ExtensionDetail.handleClickEnable');
@@ -2471,6 +2475,12 @@ const open$6 = extensionId => {
2471
2475
  const uri = `extension-detail://${extensionId}`;
2472
2476
  return invoke$1('Main.openUri', uri);
2473
2477
  };
2478
+ const handleClickUninstall = () => {
2479
+ return invoke$1('ExtensionDetail.handleClickUninstall');
2480
+ };
2481
+ const handleImageContextMenu = () => {
2482
+ return invoke$1('ExtensionDetail.handleImageContextMenu');
2483
+ };
2474
2484
  const openFeature = featureName => {
2475
2485
  // @ts-ignore
2476
2486
  return invoke$1('ExtensionDetail.handleFeaturesClick', featureName);
@@ -2497,15 +2507,22 @@ const handleScroll$1 = async scrollTop => {
2497
2507
  // @ts-ignore
2498
2508
  return invoke$1('ExtensionDetail.handleScroll', scrollTop);
2499
2509
  };
2510
+ const hideSizeLink = async () => {
2511
+ return invoke$1('ExtensionDetail.hideSizeLink');
2512
+ };
2500
2513
 
2501
2514
  const ExtensionDetail = {
2502
2515
  __proto__: null,
2516
+ copyReadmeLink,
2503
2517
  handleClickCategory,
2504
2518
  handleClickDisable,
2505
2519
  handleClickEnable,
2506
2520
  handleClickSetColorTheme,
2521
+ handleClickUninstall,
2522
+ handleImageContextMenu,
2507
2523
  handleReadmeContextMenu,
2508
2524
  handleScroll: handleScroll$1,
2525
+ hideSizeLink,
2509
2526
  open: open$6,
2510
2527
  openCommands,
2511
2528
  openFeature,
@@ -2988,38 +3005,38 @@ const getKeyOptions = rawKey => {
2988
3005
  let key = '';
2989
3006
  for (const part of parts) {
2990
3007
  switch (part) {
3008
+ case Alt:
3009
+ altKey = true;
3010
+ break;
2991
3011
  case Control:
2992
3012
  ctrlKey = true;
2993
3013
  break;
2994
3014
  case Space:
2995
3015
  key = ' ';
2996
3016
  break;
2997
- case Alt:
2998
- altKey = true;
2999
- break;
3000
3017
  default:
3001
3018
  key = part;
3002
3019
  break;
3003
3020
  }
3004
3021
  }
3005
3022
  return {
3006
- key,
3023
+ altKey,
3007
3024
  ctrlKey,
3008
- altKey
3025
+ key
3009
3026
  };
3010
3027
  }
3011
3028
  return {
3012
- key: rawKey,
3029
+ altKey: false,
3013
3030
  ctrlKey: false,
3014
- altKey: false
3031
+ key: rawKey
3015
3032
  };
3016
3033
  };
3017
3034
 
3018
3035
  const press = async key => {
3019
3036
  const keyOptions = getKeyOptions(key);
3020
3037
  const options = {
3021
- cancelable: true,
3022
3038
  bubbles: true,
3039
+ cancelable: true,
3023
3040
  ...keyOptions
3024
3041
  };
3025
3042
  // @ts-ignore
@@ -3751,8 +3768,8 @@ const transferWebViewPort = async (webViewId, port) => {
3751
3768
 
3752
3769
  const waitForFirstEventEvent = async port => {
3753
3770
  const {
3754
- resolve,
3755
- promise
3771
+ promise,
3772
+ resolve
3756
3773
  } = Promise.withResolvers();
3757
3774
  port.onmessage = resolve;
3758
3775
  const firstEvent = await promise;
@@ -3773,9 +3790,9 @@ const createPortRpc = async webViewId => {
3773
3790
  throw new Error('unexpected first message');
3774
3791
  }
3775
3792
  const rpc = await MessagePortRpcParent.create({
3776
- messagePort: port1,
3777
3793
  commandMap: {},
3778
- isMessagePortOpen: true
3794
+ isMessagePortOpen: true,
3795
+ messagePort: port1
3779
3796
  });
3780
3797
  return rpc;
3781
3798
  };
@@ -3833,6 +3850,7 @@ const createApi = (platform, assetDir) => {
3833
3850
  EditorHover,
3834
3851
  EditorRename,
3835
3852
  EditorSourceAction,
3853
+ expect,
3836
3854
  Explorer,
3837
3855
  Extension,
3838
3856
  ExtensionDetail,
@@ -3844,10 +3862,13 @@ const createApi = (platform, assetDir) => {
3844
3862
  }
3845
3863
  },
3846
3864
  FindWidget,
3865
+ getTmpDir: getTmpDir$1,
3866
+ // TODO maybe deprecate this or move to file system
3847
3867
  IconTheme,
3848
3868
  IframeInspector,
3849
3869
  KeyBindingsEditor,
3850
3870
  KeyBoard,
3871
+ Locator: create,
3851
3872
  Main,
3852
3873
  Output,
3853
3874
  Panel,
@@ -3862,14 +3883,11 @@ const createApi = (platform, assetDir) => {
3862
3883
  SideBar,
3863
3884
  SourceControl,
3864
3885
  StatusBar,
3886
+ test,
3865
3887
  TitleBarMenuBar,
3866
3888
  Url,
3867
3889
  WebView,
3868
- Workspace,
3869
- test,
3870
- Locator: create,
3871
- expect,
3872
- getTmpDir: getTmpDir$1 // TODO maybe deprecate this or move to file system
3890
+ Workspace
3873
3891
  };
3874
3892
  };
3875
3893
 
@@ -3898,27 +3916,27 @@ const executeTest2 = async (name, fn, globals, timestampGenerator) => {
3898
3916
  const formattedDuration = formatDuration(duration);
3899
3917
  if (error) {
3900
3918
  return {
3901
- error,
3902
- start,
3903
- end,
3919
+ background: 'red',
3904
3920
  duration,
3921
+ end,
3922
+ error,
3905
3923
  formattedDuration,
3906
3924
  name,
3907
- type: Fail,
3908
- background: 'red',
3909
- text: `test failed: ${error}`
3925
+ start,
3926
+ text: `test failed: ${error}`,
3927
+ type: Fail
3910
3928
  };
3911
3929
  }
3912
3930
  return {
3913
- error: undefined,
3914
- start,
3915
- end,
3931
+ background: 'green',
3916
3932
  duration,
3933
+ end,
3934
+ error: undefined,
3917
3935
  formattedDuration,
3918
3936
  name,
3919
- type: Pass,
3920
- background: 'green',
3921
- text: `test passed in ${formattedDuration}`
3937
+ start,
3938
+ text: `test passed in ${formattedDuration}`,
3939
+ type: Pass
3922
3940
  };
3923
3941
  };
3924
3942
 
@@ -3941,9 +3959,9 @@ const now = () => {
3941
3959
 
3942
3960
  const executeTest = async (name, fn, globals = {}) => {
3943
3961
  const {
3962
+ background,
3944
3963
  error,
3945
3964
  formattedDuration,
3946
- background,
3947
3965
  text,
3948
3966
  type
3949
3967
  } = await executeTest2(name, fn, globals, now);
@@ -4021,10 +4039,10 @@ const watchForHotReload = async (platform, href) => {
4021
4039
  // 3. print out results
4022
4040
  const execute = async (href, platform, assetDir) => {
4023
4041
  push({
4024
- url: href,
4025
4042
  assetDir,
4043
+ inProgress: true,
4026
4044
  platform,
4027
- inProgress: true
4045
+ url: href
4028
4046
  });
4029
4047
  const globals = createApi(platform, assetDir);
4030
4048
  // TODO
@@ -4059,10 +4077,10 @@ const execute = async (href, platform, assetDir) => {
4059
4077
  // TODO maybe setup file watcher earlier, to not miss events?
4060
4078
 
4061
4079
  push({
4062
- url: href,
4063
4080
  assetDir,
4081
+ inProgress: false,
4064
4082
  platform,
4065
- inProgress: false
4083
+ url: href
4066
4084
  });
4067
4085
  // TODO if file watcher was previously added, don't need to add one
4068
4086
  try {
@@ -4080,10 +4098,10 @@ const hotReloadTest = async () => {
4080
4098
  }
4081
4099
  const last$1 = last();
4082
4100
  const {
4083
- platform,
4084
- url,
4085
4101
  assetDir,
4086
- inProgress
4102
+ inProgress,
4103
+ platform,
4104
+ url
4087
4105
  } = last$1;
4088
4106
  if (inProgress) {
4089
4107
  return;
@@ -4098,9 +4116,9 @@ const handleFileWatcherEvent = async event => {
4098
4116
  };
4099
4117
 
4100
4118
  const commandMap = {
4119
+ 'FileWatcher.handleEvent': handleFileWatcherEvent,
4101
4120
  'Test.execute': execute,
4102
- 'Test.executeMock': executeMock,
4103
- 'FileWatcher.handleEvent': handleFileWatcherEvent
4121
+ 'Test.executeMock': executeMock
4104
4122
  };
4105
4123
 
4106
4124
  const send = async port => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "10.8.0",
3
+ "version": "10.9.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,7 @@
11
11
  "type": "module",
12
12
  "main": "dist/testWorkerMain.js",
13
13
  "dependencies": {
14
- "@lvce-editor/constants": "^1.38.0"
14
+ "@lvce-editor/constants": "^1.41.0"
15
15
  },
16
16
  "types": "dist/api.d.ts"
17
17
  }