@lvce-editor/test-worker 16.5.0 → 16.7.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
@@ -474,6 +474,7 @@ interface DiffView {
474
474
  readonly handleWheel: (deltaMode: number, deltaY: number) => Promise<void>;
475
475
  readonly handleWorkspaceChange: () => Promise<void>;
476
476
  readonly open: (leftUri: string, rightUri: string) => Promise<void>;
477
+ readonly setCursorPosition: (rowIndex: number, columnIndex: number) => Promise<void>;
477
478
  readonly setDiffMode: (diffMode: DiffMode) => Promise<void>;
478
479
  readonly setLayout: (layout: DiffLayout) => Promise<void>;
479
480
  readonly shouldHaveContentLeft: (expectedContent: string) => Promise<void>;
@@ -2843,6 +2843,9 @@ const handleScrollBarPointerMove = async clientY => {
2843
2843
  const handleScrollBarPointerUp = async clientY => {
2844
2844
  await execute$1('DiffView.handleScrollBarPointerUp', clientY);
2845
2845
  };
2846
+ const setCursorPosition = async (rowIndex, columnIndex) => {
2847
+ await execute$1('DiffView.setCursorPosition', rowIndex, columnIndex);
2848
+ };
2846
2849
 
2847
2850
  const DiffView = {
2848
2851
  handleClickAt: handleClickAt$3,
@@ -2856,6 +2859,7 @@ const DiffView = {
2856
2859
  handleWheel: handleWheel$3,
2857
2860
  handleWorkspaceChange,
2858
2861
  open: open$9,
2862
+ setCursorPosition,
2859
2863
  setDiffMode,
2860
2864
  setLayout,
2861
2865
  shouldHaveContentLeft,
@@ -5574,6 +5578,75 @@ const watchForHotReload = async (platform, href) => {
5574
5578
  await invoke('FileWatcher.watchFile', TestWorker, callbackCommand, fileUrl);
5575
5579
  };
5576
5580
 
5581
+ const toErrorMessage = error => {
5582
+ if (error instanceof Error) {
5583
+ return error.message;
5584
+ }
5585
+ return String(error);
5586
+ };
5587
+ const getSkippedResult = name => {
5588
+ const now$1 = now();
5589
+ return {
5590
+ end: now$1,
5591
+ error: '',
5592
+ name,
5593
+ start: now$1,
5594
+ status: 'skip'
5595
+ };
5596
+ };
5597
+ const getMissingTestResult = name => {
5598
+ const now$1 = now();
5599
+ return {
5600
+ end: now$1,
5601
+ error: 'test function not found',
5602
+ name,
5603
+ start: now$1,
5604
+ status: Fail
5605
+ };
5606
+ };
5607
+ const getImportErrorResult = (name, error) => {
5608
+ const now$1 = now();
5609
+ return {
5610
+ end: now$1,
5611
+ error: toErrorMessage(error),
5612
+ name,
5613
+ start: now$1,
5614
+ status: Fail
5615
+ };
5616
+ };
5617
+ const getExecutedResult = async (name, test, globals) => {
5618
+ const result = await executeTest2(name, test, globals, now);
5619
+ return {
5620
+ end: result.end,
5621
+ error: result.error ? toErrorMessage(result.error) : '',
5622
+ name,
5623
+ start: result.start,
5624
+ status: result.type
5625
+ };
5626
+ };
5627
+ const executeAllTest = async (item, globals) => {
5628
+ try {
5629
+ const module = await importTest(item.url);
5630
+ const {
5631
+ mockRpc,
5632
+ skip,
5633
+ test
5634
+ } = module;
5635
+ if (mockRpc) {
5636
+ setMockRpc(mockRpc);
5637
+ }
5638
+ if (skip) {
5639
+ return getSkippedResult(item.name);
5640
+ }
5641
+ if (!test) {
5642
+ return getMissingTestResult(item.name);
5643
+ }
5644
+ return getExecutedResult(item.name, test, globals);
5645
+ } catch (error) {
5646
+ return getImportErrorResult(item.name, error);
5647
+ }
5648
+ };
5649
+
5577
5650
  // TODO move this into three steps:
5578
5651
  // 1. import test module
5579
5652
  // 2. execute test
@@ -5634,6 +5707,27 @@ const execute = async (href, platform, assetDir) => {
5634
5707
  // ignore
5635
5708
  }
5636
5709
  };
5710
+ const executeAll = async (tests, href, platform, assetDir) => {
5711
+ push({
5712
+ assetDir,
5713
+ inProgress: true,
5714
+ platform,
5715
+ url: href
5716
+ });
5717
+ const globals = createApi(platform, assetDir);
5718
+ const results = [];
5719
+ for (const test of tests) {
5720
+ const result = await executeAllTest(test, globals);
5721
+ results.push(result);
5722
+ }
5723
+ await invoke('TestFrameWork.showTestResults', JSON.stringify(results));
5724
+ push({
5725
+ assetDir,
5726
+ inProgress: false,
5727
+ platform,
5728
+ url: href
5729
+ });
5730
+ };
5637
5731
 
5638
5732
  const doHotReload = async (url, platform, assetDir) => {
5639
5733
  // eslint-disable-next-line no-console
@@ -6040,6 +6134,7 @@ const tryAutoFix = async () => {
6040
6134
  const commandMap = {
6041
6135
  'FileWatcher.handleEvent': handleFileWatcherEvent,
6042
6136
  'Test.execute': execute,
6137
+ 'Test.executeAll': executeAll,
6043
6138
  'Test.executeMock': executeMock,
6044
6139
  'Test.tryAutoFix': tryAutoFix
6045
6140
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "16.5.0",
3
+ "version": "16.7.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",