@lvce-editor/test-worker 16.7.0 → 17.0.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
@@ -28,47 +28,6 @@ interface ILocatorExternal {
28
28
  readonly type: (text: string) => Promise<void>;
29
29
  }
30
30
 
31
- interface ParsedCssSelectorPart {
32
- readonly selector: string;
33
- readonly type: "css";
34
- }
35
-
36
- interface ParsedTextSelectorPart {
37
- readonly text: string;
38
- readonly type: "text";
39
- }
40
-
41
- interface ParsedHasTextSelectorPart {
42
- readonly text: string;
43
- readonly type: "has-text";
44
- }
45
-
46
- interface ParsedNthSelectorPart {
47
- readonly index: number;
48
- readonly type: "nth";
49
- }
50
- export type ParsedSelectorPart = ParsedCssSelectorPart | ParsedTextSelectorPart | ParsedHasTextSelectorPart | ParsedNthSelectorPart;
51
- export type ParsedCssSelector = readonly ParsedSelectorPart[];
52
-
53
- interface ILocatorCreateOptions {
54
- readonly hasText?: string;
55
- readonly nth?: number;
56
- }
57
- export declare class Locator implements ILocatorExternal {
58
- readonly _selector: string;
59
- readonly _parsed: ParsedCssSelector;
60
- constructor(selector: string, options?: ILocatorCreateOptions, parsed?: ParsedCssSelector);
61
- click({ button }?: {
62
- readonly button?: string;
63
- }): Promise<void>;
64
- hover(): Promise<void>;
65
- first(): any;
66
- locator(subSelector: string): any;
67
- nth(nth: number): any;
68
- type(text: string): Promise<void>;
69
- dispatchEvent(type: string, init: any): Promise<void>;
70
- }
71
-
72
31
  export interface UpdateConfig {
73
32
  readonly progress: number;
74
33
  readonly state: number;
@@ -198,11 +157,6 @@ export interface GitPushOptions {
198
157
  readonly setUpstream?: readonly string[];
199
158
  }
200
159
 
201
- export interface GitInvocation {
202
- readonly command: readonly string[];
203
- readonly cwd: string;
204
- }
205
-
206
160
  export interface LayoutExpectation extends LayoutExpectationObject {
207
161
  readonly activeGroupIndex?: number;
208
162
  readonly direction?: LayoutDirection;
@@ -210,7 +164,7 @@ export interface LayoutExpectation extends LayoutExpectationObject {
210
164
  }
211
165
 
212
166
  export interface SelectItemOptions {
213
- readonly waitUntil?: SelectItemWaitUntil;
167
+ readonly waitUntil?: "done" | "quickPick" | "none";
214
168
  }
215
169
 
216
170
  export interface SelectItem2Options {
@@ -267,8 +221,6 @@ export type SavedState = {
267
221
  readonly layout?: LayoutState;
268
222
  };
269
223
 
270
- export type SelectItemWaitUntil = "done" | "quickPick" | "none";
271
-
272
224
  export type SearchInputType = "SearchValue" | "ReplaceValue" | "IncludeValue" | "ExcludeValue";
273
225
 
274
226
  interface Workspace {
@@ -464,6 +416,7 @@ interface Dialog {
464
416
 
465
417
  interface DiffView {
466
418
  readonly handleClickAt: (clientX: number, clientY: number, targetName: string) => Promise<void>;
419
+ readonly handleInput: (text: string) => Promise<void>;
467
420
  readonly handleResize: (width: number, height: number) => Promise<void>;
468
421
  readonly handleSashPointerDown: (clientX: number, clientY: number) => Promise<void>;
469
422
  readonly handleSashPointerMove: (clientX: number, clientY: number) => Promise<void>;
@@ -476,10 +429,13 @@ interface DiffView {
476
429
  readonly open: (leftUri: string, rightUri: string) => Promise<void>;
477
430
  readonly setCursorPosition: (rowIndex: number, columnIndex: number) => Promise<void>;
478
431
  readonly setDiffMode: (diffMode: DiffMode) => Promise<void>;
432
+ readonly setFontFamily: (fontFamily: string) => Promise<void>;
479
433
  readonly setLayout: (layout: DiffLayout) => Promise<void>;
434
+ readonly setWordWrap: (enabled: boolean) => Promise<void>;
480
435
  readonly shouldHaveContentLeft: (expectedContent: string) => Promise<void>;
481
436
  readonly shouldHaveContentRight: (expectedContent: string) => Promise<void>;
482
437
  readonly toggleDiffMode: () => Promise<void>;
438
+ readonly toggleWhitespace: () => Promise<void>;
483
439
  }
484
440
 
485
441
  interface Editor {
@@ -653,6 +609,8 @@ interface Explorer {
653
609
  interface Extension {
654
610
  readonly addNodeExtension: (relativePath: string) => Promise<void>;
655
611
  readonly addWebExtension: (relativePath: string) => Promise<void>;
612
+ readonly disableWorkspace: (id: string) => Promise<void>;
613
+ readonly enableWorkspace: (id: string) => Promise<void>;
656
614
  readonly executeCompletionProvider: (textDocument: CompletionTextDocument, ...args: readonly unknown[]) => Promise<readonly CompletionItem[]>;
657
615
  readonly executeFormattingProvider: (textDocument: FormattingTextDocument, ...args: readonly unknown[]) => Promise<readonly FormattingEdit[]>;
658
616
  }
@@ -770,7 +728,6 @@ interface Git {
770
728
  readonly setOrigin: (remoteUrl: string) => Promise<void>;
771
729
  readonly setUpstream: (remoteUrl: string) => Promise<void>;
772
730
  readonly shouldHaveCommit: (message: string) => Promise<void>;
773
- readonly shouldHaveInvocations: (invocations: readonly GitInvocation[]) => Promise<void>;
774
731
  readonly stage: (pathSpec: string) => Promise<void>;
775
732
  readonly stash: (message?: string) => Promise<void>;
776
733
  readonly status: () => Promise<unknown>;
@@ -880,8 +837,10 @@ interface Output {
880
837
  }
881
838
 
882
839
  interface Panel {
840
+ readonly maximize: () => Promise<void>;
883
841
  readonly open: (id: string) => Promise<void>;
884
842
  readonly openProblems: () => Promise<void>;
843
+ readonly unmaximize: () => Promise<void>;
885
844
  }
886
845
 
887
846
  interface Platform {
@@ -1063,6 +1022,11 @@ interface WebView {
1063
1022
  readonly fromId: (webViewId: string) => Promise<any>;
1064
1023
  }
1065
1024
 
1025
+ interface LocatorOptions {
1026
+ readonly hasText?: string
1027
+ readonly nth?: number
1028
+ }
1029
+
1066
1030
  export interface TestApi {
1067
1031
  readonly Workspace: Workspace
1068
1032
  readonly About: About
@@ -1115,7 +1079,7 @@ export interface TestApi {
1115
1079
  readonly Url: Url
1116
1080
  readonly WebView: WebView
1117
1081
  readonly expect: (locator: ILocatorExternal) => LocatorExpect
1118
- readonly Locator: (selector: string, option?: any) => ILocatorExternal
1082
+ readonly Locator: (selector: string, options?: LocatorOptions) => ILocatorExternal
1119
1083
  }
1120
1084
 
1121
1085
  export interface Test {
@@ -1924,8 +1924,13 @@ const execute$1 = async (id, ...args) => {
1924
1924
  return invoke(id, ...args);
1925
1925
  };
1926
1926
  const executeExtensionCommand = async (commandId, ...args) => {
1927
- // TODO maybe ask extension-management-worker instead
1928
- return invoke('ExtensionHost.executeCommand', commandId, ...args);
1927
+ try {
1928
+ return await invoke$2('Extensions.executeExtensionCommand', commandId, ...args);
1929
+ } catch {
1930
+ // legacy
1931
+ // TODO maybe ask extension-management-worker instead
1932
+ return invoke('ExtensionHost.executeCommand', commandId, ...args);
1933
+ }
1929
1934
  };
1930
1935
 
1931
1936
  const Command = {
@@ -1988,7 +1993,7 @@ const show$7 = async () => {
1988
1993
  const getSelectedSessionId = async () => {
1989
1994
  return invoke('Chat.getSelectedSessionId');
1990
1995
  };
1991
- const handleInput$8 = async text => {
1996
+ const handleInput$9 = async text => {
1992
1997
  await invoke('Chat.handleInput', 'composer', text, 'script');
1993
1998
  };
1994
1999
  const handleDropFiles = async file => {
@@ -2169,7 +2174,7 @@ const Chat = {
2169
2174
  handleContextMenuChatImageAttachment,
2170
2175
  handleDropFiles,
2171
2176
  handleErrorComposerAttachmentPreviewOverlay,
2172
- handleInput: handleInput$8,
2177
+ handleInput: handleInput$9,
2173
2178
  handleInputCopy: handleInputCopy$1,
2174
2179
  handleInputCut: handleInputCut$1,
2175
2180
  handleInputFocus,
@@ -2295,7 +2300,7 @@ const open2 = async ({
2295
2300
  await setEvents(events);
2296
2301
  }
2297
2302
  if (useDevtoolsLayout) {
2298
- await handleInput$7('useDevtoolsLayout', '', true);
2303
+ await handleInput$8('useDevtoolsLayout', '', true);
2299
2304
  }
2300
2305
  };
2301
2306
  const handleTimelineDoubleClick = async () => {
@@ -2356,41 +2361,41 @@ const shouldHaveResponse = async expectedPayload => {
2356
2361
  throw new ChatDebugShouldHavePayloadError(expectedPayload, actualPayload, error);
2357
2362
  }
2358
2363
  };
2359
- const handleInput$7 = async (name, value, checked) => {
2364
+ const handleInput$8 = async (name, value, checked) => {
2360
2365
  await invoke('ChatDebug.handleInput', name, value, checked);
2361
2366
  };
2362
2367
  const useDevtoolsLayout = async () => {
2363
- await handleInput$7('useDevtoolsLayout', '', true);
2368
+ await handleInput$8('useDevtoolsLayout', '', true);
2364
2369
  };
2365
2370
  const handleHeaderContextMenu = async (x, y) => {
2366
2371
  await invoke('ChatDebug.handleHeaderContextMenu', x, y);
2367
2372
  };
2368
2373
  const setFilter = async value => {
2369
- await handleInput$7('filter', value, false);
2374
+ await handleInput$8('filter', value, false);
2370
2375
  };
2371
2376
  const handlePreviewTextPointerDown = async (x, y) => {
2372
2377
  await invoke('ChatDebug.handlePreviewTextPointerDown', x, y);
2373
2378
  };
2374
2379
  const setEventCategoryFilter = async value => {
2375
- await handleInput$7('eventCategoryFilter', value, false);
2380
+ await handleInput$8('eventCategoryFilter', value, false);
2376
2381
  };
2377
2382
  const setTimelineRangePreset = async value => {
2378
- await handleInput$7('timelineRangePreset', value, false);
2383
+ await handleInput$8('timelineRangePreset', value, false);
2379
2384
  };
2380
2385
  const setShowInputEvents = async enabled => {
2381
- await handleInput$7('showInputEvents', '', enabled);
2386
+ await handleInput$8('showInputEvents', '', enabled);
2382
2387
  };
2383
2388
  const setShowResponsePartEvents = async enabled => {
2384
- await handleInput$7('showResponsePartEvents', '', enabled);
2389
+ await handleInput$8('showResponsePartEvents', '', enabled);
2385
2390
  };
2386
2391
  const handleTableFocus = async () => {
2387
2392
  await invoke('ChatDebug.handleTableFocus');
2388
2393
  };
2389
2394
  const setShowEventStreamFinishedEvents = async enabled => {
2390
- await handleInput$7('showEventStreamFinishedEvents', '', enabled);
2395
+ await handleInput$8('showEventStreamFinishedEvents', '', enabled);
2391
2396
  };
2392
2397
  const closeDetails = async () => {
2393
- await handleInput$7('closeDetails', 'close', false);
2398
+ await handleInput$8('closeDetails', 'close', false);
2394
2399
  };
2395
2400
  const openTab = async id => {
2396
2401
  await invoke('ChatDebug.handleInput', 'detailTab', id, false);
@@ -2444,7 +2449,7 @@ const ChatDebug = {
2444
2449
  handleClickRefresh,
2445
2450
  handleEventCategoryFilter,
2446
2451
  handleHeaderContextMenu,
2447
- handleInput: handleInput$7,
2452
+ handleInput: handleInput$8,
2448
2453
  handlePreviewTextPointerDown,
2449
2454
  handleRootContextMenu,
2450
2455
  handleTableBodyContextMenu,
@@ -2813,6 +2818,15 @@ const toggleDiffMode = async () => {
2813
2818
  const setLayout = async layout => {
2814
2819
  await execute$1('DiffView.setLayout', layout);
2815
2820
  };
2821
+ const setFontFamily = async fontFamily => {
2822
+ await execute$1('DiffView.setFontFamily', fontFamily);
2823
+ };
2824
+ const setWordWrap = async enabled => {
2825
+ await execute$1('DiffView.setWordWrap', enabled);
2826
+ };
2827
+ const toggleWhitespace = async () => {
2828
+ await execute$1('DiffView.toggleWhitespace');
2829
+ };
2816
2830
  const handleWheel$3 = async (deltaMode, deltaY) => {
2817
2831
  await execute$1('DiffView.handleWheel', deltaMode, deltaY);
2818
2832
  };
@@ -2846,9 +2860,13 @@ const handleScrollBarPointerUp = async clientY => {
2846
2860
  const setCursorPosition = async (rowIndex, columnIndex) => {
2847
2861
  await execute$1('DiffView.setCursorPosition', rowIndex, columnIndex);
2848
2862
  };
2863
+ const handleInput$7 = async text => {
2864
+ await execute$1('DiffView.handleInput', text);
2865
+ };
2849
2866
 
2850
2867
  const DiffView = {
2851
2868
  handleClickAt: handleClickAt$3,
2869
+ handleInput: handleInput$7,
2852
2870
  handleResize,
2853
2871
  handleSashPointerDown,
2854
2872
  handleSashPointerMove,
@@ -2861,10 +2879,13 @@ const DiffView = {
2861
2879
  open: open$9,
2862
2880
  setCursorPosition,
2863
2881
  setDiffMode,
2882
+ setFontFamily,
2864
2883
  setLayout,
2884
+ setWordWrap,
2865
2885
  shouldHaveContentLeft,
2866
2886
  shouldHaveContentRight,
2867
- toggleDiffMode
2887
+ toggleDiffMode,
2888
+ toggleWhitespace
2868
2889
  };
2869
2890
 
2870
2891
  const isDiagnosticEqual = (actual, expected) => {
@@ -3621,6 +3642,12 @@ const executeFormattingProvider = async (textDocument, ...args) => {
3621
3642
  const executeCompletionProvider = async (textDocument, ...args) => {
3622
3643
  return invoke$2('Extensions.executeCompletionProvider', textDocument, ...args);
3623
3644
  };
3645
+ const enableWorkspace = async id => {
3646
+ await invoke$2('Extensions.enableWorkspace', id);
3647
+ };
3648
+ const disableWorkspace = async id => {
3649
+ await invoke$2('Extensions.disableWorkspace', id);
3650
+ };
3624
3651
  const addNodeExtension = async relativePath => {
3625
3652
  // TODO compute absolutePath
3626
3653
  const absolutePath = relativePath;
@@ -3630,6 +3657,8 @@ const addNodeExtension = async relativePath => {
3630
3657
  const Extension = {
3631
3658
  addNodeExtension,
3632
3659
  addWebExtension,
3660
+ disableWorkspace,
3661
+ enableWorkspace,
3633
3662
  executeCompletionProvider,
3634
3663
  executeFormattingProvider
3635
3664
  };
@@ -3913,7 +3942,9 @@ const writeFiles = async files => {
3913
3942
  return writeFile(file.uri, file.content);
3914
3943
  }));
3915
3944
  };
3916
- const setFiles = writeFiles;
3945
+ const setFiles = async files => {
3946
+ await writeFiles(files);
3947
+ };
3917
3948
  const readDir = async uri => {
3918
3949
  return invoke('FileSystem.readDirWithFileTypes', uri);
3919
3950
  };
@@ -4248,9 +4279,6 @@ const shouldHaveCommit = async message => {
4248
4279
  throw new Error(`Expected commit message to be "${message}", but got "${commits[0].message}"`);
4249
4280
  }
4250
4281
  };
4251
- const shouldHaveInvocations = async invocations => {
4252
- // TODO
4253
- };
4254
4282
 
4255
4283
  const Git = {
4256
4284
  add,
@@ -4286,7 +4314,6 @@ const Git = {
4286
4314
  setOrigin,
4287
4315
  setUpstream,
4288
4316
  shouldHaveCommit,
4289
- shouldHaveInvocations,
4290
4317
  stage,
4291
4318
  stash,
4292
4319
  status,
@@ -4564,10 +4591,18 @@ const openProblems = async () => {
4564
4591
  await open$3('Problems');
4565
4592
  await invoke('Panel.selectIndex', 0);
4566
4593
  };
4594
+ const maximize = async () => {
4595
+ await invoke('Panel.maximize');
4596
+ };
4597
+ const unmaximize = async () => {
4598
+ await invoke('Panel.unmaximize');
4599
+ };
4567
4600
 
4568
4601
  const Panel = {
4602
+ maximize,
4569
4603
  open: open$3,
4570
- openProblems
4604
+ openProblems,
4605
+ unmaximize
4571
4606
  };
4572
4607
 
4573
4608
  const show$5 = async () => {
@@ -5646,6 +5681,47 @@ const executeAllTest = async (item, globals) => {
5646
5681
  return getImportErrorResult(item.name, error);
5647
5682
  }
5648
5683
  };
5684
+ const getCountText = (count, label) => {
5685
+ if (count === 1) {
5686
+ return `1 ${label}`;
5687
+ }
5688
+ return `${count} ${label}s`;
5689
+ };
5690
+ const getSummaryParts = results => {
5691
+ const passed = results.filter(result => result.status === Pass).length;
5692
+ const failed = results.filter(result => result.status === Fail).length;
5693
+ const skipped = results.filter(result => result.status === 'skip').length;
5694
+ const parts = [];
5695
+ if (passed > 0) {
5696
+ parts.push(`${getCountText(passed, 'test')} passed`);
5697
+ }
5698
+ if (failed > 0) {
5699
+ parts.push(`${getCountText(failed, 'test')} failed`);
5700
+ }
5701
+ if (skipped > 0) {
5702
+ parts.push(`${getCountText(skipped, 'test')} skipped`);
5703
+ }
5704
+ if (parts.length === 0) {
5705
+ return ['0 tests passed'];
5706
+ }
5707
+ return parts;
5708
+ };
5709
+ const showAllTestsOverlay = async (results, duration) => {
5710
+ const hasFailures = results.some(result => result.status === Fail);
5711
+ const hasPassed = results.some(result => result.status === Pass);
5712
+ let type = 'skip';
5713
+ let background = 'yellow';
5714
+ if (hasPassed) {
5715
+ type = Pass;
5716
+ background = 'green';
5717
+ }
5718
+ if (hasFailures) {
5719
+ type = Fail;
5720
+ background = 'red';
5721
+ }
5722
+ const text = `${getSummaryParts(results).join(', ')} in ${formatDuration(duration)}`;
5723
+ await invoke('TestFrameWork.showOverlay', type, background, text);
5724
+ };
5649
5725
 
5650
5726
  // TODO move this into three steps:
5651
5727
  // 1. import test module
@@ -5716,10 +5792,13 @@ const executeAll = async (tests, href, platform, assetDir) => {
5716
5792
  });
5717
5793
  const globals = createApi(platform, assetDir);
5718
5794
  const results = [];
5795
+ const start = now();
5719
5796
  for (const test of tests) {
5720
5797
  const result = await executeAllTest(test, globals);
5721
5798
  results.push(result);
5722
5799
  }
5800
+ const end = now();
5801
+ await showAllTestsOverlay(results, end - start);
5723
5802
  await invoke('TestFrameWork.showTestResults', JSON.stringify(results));
5724
5803
  push({
5725
5804
  assetDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "16.7.0",
3
+ "version": "17.0.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",