@lvce-editor/test-worker 16.7.0 → 16.8.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;
@@ -464,6 +423,7 @@ interface Dialog {
464
423
 
465
424
  interface DiffView {
466
425
  readonly handleClickAt: (clientX: number, clientY: number, targetName: string) => Promise<void>;
426
+ readonly handleInput: (text: string) => Promise<void>;
467
427
  readonly handleResize: (width: number, height: number) => Promise<void>;
468
428
  readonly handleSashPointerDown: (clientX: number, clientY: number) => Promise<void>;
469
429
  readonly handleSashPointerMove: (clientX: number, clientY: number) => Promise<void>;
@@ -476,10 +436,13 @@ interface DiffView {
476
436
  readonly open: (leftUri: string, rightUri: string) => Promise<void>;
477
437
  readonly setCursorPosition: (rowIndex: number, columnIndex: number) => Promise<void>;
478
438
  readonly setDiffMode: (diffMode: DiffMode) => Promise<void>;
439
+ readonly setFontFamily: (fontFamily: string) => Promise<void>;
479
440
  readonly setLayout: (layout: DiffLayout) => Promise<void>;
441
+ readonly setWordWrap: (enabled: boolean) => Promise<void>;
480
442
  readonly shouldHaveContentLeft: (expectedContent: string) => Promise<void>;
481
443
  readonly shouldHaveContentRight: (expectedContent: string) => Promise<void>;
482
444
  readonly toggleDiffMode: () => Promise<void>;
445
+ readonly toggleWhitespace: () => Promise<void>;
483
446
  }
484
447
 
485
448
  interface Editor {
@@ -880,8 +843,10 @@ interface Output {
880
843
  }
881
844
 
882
845
  interface Panel {
846
+ readonly maximize: () => Promise<void>;
883
847
  readonly open: (id: string) => Promise<void>;
884
848
  readonly openProblems: () => Promise<void>;
849
+ readonly unmaximize: () => Promise<void>;
885
850
  }
886
851
 
887
852
  interface Platform {
@@ -1063,6 +1028,11 @@ interface WebView {
1063
1028
  readonly fromId: (webViewId: string) => Promise<any>;
1064
1029
  }
1065
1030
 
1031
+ interface LocatorOptions {
1032
+ readonly hasText?: string
1033
+ readonly nth?: number
1034
+ }
1035
+
1066
1036
  export interface TestApi {
1067
1037
  readonly Workspace: Workspace
1068
1038
  readonly About: About
@@ -1115,7 +1085,7 @@ export interface TestApi {
1115
1085
  readonly Url: Url
1116
1086
  readonly WebView: WebView
1117
1087
  readonly expect: (locator: ILocatorExternal) => LocatorExpect
1118
- readonly Locator: (selector: string, option?: any) => ILocatorExternal
1088
+ readonly Locator: (selector: string, options?: LocatorOptions) => ILocatorExternal
1119
1089
  }
1120
1090
 
1121
1091
  export interface Test {
@@ -1988,7 +1988,7 @@ const show$7 = async () => {
1988
1988
  const getSelectedSessionId = async () => {
1989
1989
  return invoke('Chat.getSelectedSessionId');
1990
1990
  };
1991
- const handleInput$8 = async text => {
1991
+ const handleInput$9 = async text => {
1992
1992
  await invoke('Chat.handleInput', 'composer', text, 'script');
1993
1993
  };
1994
1994
  const handleDropFiles = async file => {
@@ -2169,7 +2169,7 @@ const Chat = {
2169
2169
  handleContextMenuChatImageAttachment,
2170
2170
  handleDropFiles,
2171
2171
  handleErrorComposerAttachmentPreviewOverlay,
2172
- handleInput: handleInput$8,
2172
+ handleInput: handleInput$9,
2173
2173
  handleInputCopy: handleInputCopy$1,
2174
2174
  handleInputCut: handleInputCut$1,
2175
2175
  handleInputFocus,
@@ -2295,7 +2295,7 @@ const open2 = async ({
2295
2295
  await setEvents(events);
2296
2296
  }
2297
2297
  if (useDevtoolsLayout) {
2298
- await handleInput$7('useDevtoolsLayout', '', true);
2298
+ await handleInput$8('useDevtoolsLayout', '', true);
2299
2299
  }
2300
2300
  };
2301
2301
  const handleTimelineDoubleClick = async () => {
@@ -2356,41 +2356,41 @@ const shouldHaveResponse = async expectedPayload => {
2356
2356
  throw new ChatDebugShouldHavePayloadError(expectedPayload, actualPayload, error);
2357
2357
  }
2358
2358
  };
2359
- const handleInput$7 = async (name, value, checked) => {
2359
+ const handleInput$8 = async (name, value, checked) => {
2360
2360
  await invoke('ChatDebug.handleInput', name, value, checked);
2361
2361
  };
2362
2362
  const useDevtoolsLayout = async () => {
2363
- await handleInput$7('useDevtoolsLayout', '', true);
2363
+ await handleInput$8('useDevtoolsLayout', '', true);
2364
2364
  };
2365
2365
  const handleHeaderContextMenu = async (x, y) => {
2366
2366
  await invoke('ChatDebug.handleHeaderContextMenu', x, y);
2367
2367
  };
2368
2368
  const setFilter = async value => {
2369
- await handleInput$7('filter', value, false);
2369
+ await handleInput$8('filter', value, false);
2370
2370
  };
2371
2371
  const handlePreviewTextPointerDown = async (x, y) => {
2372
2372
  await invoke('ChatDebug.handlePreviewTextPointerDown', x, y);
2373
2373
  };
2374
2374
  const setEventCategoryFilter = async value => {
2375
- await handleInput$7('eventCategoryFilter', value, false);
2375
+ await handleInput$8('eventCategoryFilter', value, false);
2376
2376
  };
2377
2377
  const setTimelineRangePreset = async value => {
2378
- await handleInput$7('timelineRangePreset', value, false);
2378
+ await handleInput$8('timelineRangePreset', value, false);
2379
2379
  };
2380
2380
  const setShowInputEvents = async enabled => {
2381
- await handleInput$7('showInputEvents', '', enabled);
2381
+ await handleInput$8('showInputEvents', '', enabled);
2382
2382
  };
2383
2383
  const setShowResponsePartEvents = async enabled => {
2384
- await handleInput$7('showResponsePartEvents', '', enabled);
2384
+ await handleInput$8('showResponsePartEvents', '', enabled);
2385
2385
  };
2386
2386
  const handleTableFocus = async () => {
2387
2387
  await invoke('ChatDebug.handleTableFocus');
2388
2388
  };
2389
2389
  const setShowEventStreamFinishedEvents = async enabled => {
2390
- await handleInput$7('showEventStreamFinishedEvents', '', enabled);
2390
+ await handleInput$8('showEventStreamFinishedEvents', '', enabled);
2391
2391
  };
2392
2392
  const closeDetails = async () => {
2393
- await handleInput$7('closeDetails', 'close', false);
2393
+ await handleInput$8('closeDetails', 'close', false);
2394
2394
  };
2395
2395
  const openTab = async id => {
2396
2396
  await invoke('ChatDebug.handleInput', 'detailTab', id, false);
@@ -2444,7 +2444,7 @@ const ChatDebug = {
2444
2444
  handleClickRefresh,
2445
2445
  handleEventCategoryFilter,
2446
2446
  handleHeaderContextMenu,
2447
- handleInput: handleInput$7,
2447
+ handleInput: handleInput$8,
2448
2448
  handlePreviewTextPointerDown,
2449
2449
  handleRootContextMenu,
2450
2450
  handleTableBodyContextMenu,
@@ -2813,6 +2813,15 @@ const toggleDiffMode = async () => {
2813
2813
  const setLayout = async layout => {
2814
2814
  await execute$1('DiffView.setLayout', layout);
2815
2815
  };
2816
+ const setFontFamily = async fontFamily => {
2817
+ await execute$1('DiffView.setFontFamily', fontFamily);
2818
+ };
2819
+ const setWordWrap = async enabled => {
2820
+ await execute$1('DiffView.setWordWrap', enabled);
2821
+ };
2822
+ const toggleWhitespace = async () => {
2823
+ await execute$1('DiffView.toggleWhitespace');
2824
+ };
2816
2825
  const handleWheel$3 = async (deltaMode, deltaY) => {
2817
2826
  await execute$1('DiffView.handleWheel', deltaMode, deltaY);
2818
2827
  };
@@ -2846,9 +2855,13 @@ const handleScrollBarPointerUp = async clientY => {
2846
2855
  const setCursorPosition = async (rowIndex, columnIndex) => {
2847
2856
  await execute$1('DiffView.setCursorPosition', rowIndex, columnIndex);
2848
2857
  };
2858
+ const handleInput$7 = async text => {
2859
+ await execute$1('DiffView.handleInput', text);
2860
+ };
2849
2861
 
2850
2862
  const DiffView = {
2851
2863
  handleClickAt: handleClickAt$3,
2864
+ handleInput: handleInput$7,
2852
2865
  handleResize,
2853
2866
  handleSashPointerDown,
2854
2867
  handleSashPointerMove,
@@ -2861,10 +2874,13 @@ const DiffView = {
2861
2874
  open: open$9,
2862
2875
  setCursorPosition,
2863
2876
  setDiffMode,
2877
+ setFontFamily,
2864
2878
  setLayout,
2879
+ setWordWrap,
2865
2880
  shouldHaveContentLeft,
2866
2881
  shouldHaveContentRight,
2867
- toggleDiffMode
2882
+ toggleDiffMode,
2883
+ toggleWhitespace
2868
2884
  };
2869
2885
 
2870
2886
  const isDiagnosticEqual = (actual, expected) => {
@@ -3913,7 +3929,9 @@ const writeFiles = async files => {
3913
3929
  return writeFile(file.uri, file.content);
3914
3930
  }));
3915
3931
  };
3916
- const setFiles = writeFiles;
3932
+ const setFiles = async files => {
3933
+ await writeFiles(files);
3934
+ };
3917
3935
  const readDir = async uri => {
3918
3936
  return invoke('FileSystem.readDirWithFileTypes', uri);
3919
3937
  };
@@ -4564,10 +4582,18 @@ const openProblems = async () => {
4564
4582
  await open$3('Problems');
4565
4583
  await invoke('Panel.selectIndex', 0);
4566
4584
  };
4585
+ const maximize = async () => {
4586
+ await invoke('Panel.maximize');
4587
+ };
4588
+ const unmaximize = async () => {
4589
+ await invoke('Panel.unmaximize');
4590
+ };
4567
4591
 
4568
4592
  const Panel = {
4593
+ maximize,
4569
4594
  open: open$3,
4570
- openProblems
4595
+ openProblems,
4596
+ unmaximize
4571
4597
  };
4572
4598
 
4573
4599
  const show$5 = async () => {
@@ -5646,6 +5672,47 @@ const executeAllTest = async (item, globals) => {
5646
5672
  return getImportErrorResult(item.name, error);
5647
5673
  }
5648
5674
  };
5675
+ const getCountText = (count, label) => {
5676
+ if (count === 1) {
5677
+ return `1 ${label}`;
5678
+ }
5679
+ return `${count} ${label}s`;
5680
+ };
5681
+ const getSummaryParts = results => {
5682
+ const passed = results.filter(result => result.status === Pass).length;
5683
+ const failed = results.filter(result => result.status === Fail).length;
5684
+ const skipped = results.filter(result => result.status === 'skip').length;
5685
+ const parts = [];
5686
+ if (passed > 0) {
5687
+ parts.push(`${getCountText(passed, 'test')} passed`);
5688
+ }
5689
+ if (failed > 0) {
5690
+ parts.push(`${getCountText(failed, 'test')} failed`);
5691
+ }
5692
+ if (skipped > 0) {
5693
+ parts.push(`${getCountText(skipped, 'test')} skipped`);
5694
+ }
5695
+ if (parts.length === 0) {
5696
+ return ['0 tests passed'];
5697
+ }
5698
+ return parts;
5699
+ };
5700
+ const showAllTestsOverlay = async (results, duration) => {
5701
+ const hasFailures = results.some(result => result.status === Fail);
5702
+ const hasPassed = results.some(result => result.status === Pass);
5703
+ let type = 'skip';
5704
+ let background = 'yellow';
5705
+ if (hasPassed) {
5706
+ type = Pass;
5707
+ background = 'green';
5708
+ }
5709
+ if (hasFailures) {
5710
+ type = Fail;
5711
+ background = 'red';
5712
+ }
5713
+ const text = `${getSummaryParts(results).join(', ')} in ${formatDuration(duration)}`;
5714
+ await invoke('TestFrameWork.showOverlay', type, background, text);
5715
+ };
5649
5716
 
5650
5717
  // TODO move this into three steps:
5651
5718
  // 1. import test module
@@ -5716,10 +5783,13 @@ const executeAll = async (tests, href, platform, assetDir) => {
5716
5783
  });
5717
5784
  const globals = createApi(platform, assetDir);
5718
5785
  const results = [];
5786
+ const start = now();
5719
5787
  for (const test of tests) {
5720
5788
  const result = await executeAllTest(test, globals);
5721
5789
  results.push(result);
5722
5790
  }
5791
+ const end = now();
5792
+ await showAllTestsOverlay(results, end - start);
5723
5793
  await invoke('TestFrameWork.showTestResults', JSON.stringify(results));
5724
5794
  push({
5725
5795
  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": "16.8.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",