@theia/api-tests 1.46.0-next.153 → 1.46.0-next.196

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@theia/api-tests",
3
- "version": "1.46.0-next.153+cff0a9c25",
3
+ "version": "1.46.0-next.196+cb2bd96b3",
4
4
  "description": "Theia API tests",
5
5
  "dependencies": {
6
- "@theia/core": "1.46.0-next.153+cff0a9c25"
6
+ "@theia/core": "1.46.0-next.196+cb2bd96b3"
7
7
  },
8
8
  "license": "EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0",
9
9
  "repository": {
@@ -20,5 +20,5 @@
20
20
  "publishConfig": {
21
21
  "access": "public"
22
22
  },
23
- "gitHead": "cff0a9c255ee748de2a055972196850faf09277f"
23
+ "gitHead": "cb2bd96b362408c90179005a5b415ddbd452ce41"
24
24
  }
package/src/scm.spec.js CHANGED
@@ -14,17 +14,23 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
+
18
+
19
+
17
20
  // @ts-check
18
21
  describe('SCM', function () {
19
22
 
20
23
  const { assert } = chai;
21
24
 
25
+ const { animationFrame } = require('@theia/core/lib/browser/browser');
26
+ const { HostedPluginSupport } = require('@theia/plugin-ext/lib/hosted/browser/hosted-plugin');
22
27
  const Uri = require('@theia/core/lib/common/uri');
23
28
  const { ApplicationShell } = require('@theia/core/lib/browser/shell/application-shell');
24
29
  const { ContextKeyService } = require('@theia/core/lib/browser/context-key-service');
25
30
  const { ScmContribution } = require('@theia/scm/lib/browser/scm-contribution');
26
31
  const { ScmService } = require('@theia/scm/lib/browser/scm-service');
27
32
  const { ScmWidget } = require('@theia/scm/lib/browser/scm-widget');
33
+ const { CommandRegistry } = require('@theia/core/lib/common');
28
34
 
29
35
  /** @type {import('inversify').Container} */
30
36
  const container = window['theia'].container;
@@ -32,6 +38,8 @@ describe('SCM', function () {
32
38
  const scmContribution = container.get(ScmContribution);
33
39
  const shell = container.get(ApplicationShell);
34
40
  const service = container.get(ScmService);
41
+ const commandRegistry = container.get(CommandRegistry);
42
+ const pluginService = container.get(HostedPluginSupport);
35
43
 
36
44
  /** @type {ScmWidget} */
37
45
  let scmWidget;
@@ -39,10 +47,49 @@ describe('SCM', function () {
39
47
  /** @type {ScmService} */
40
48
  let scmService;
41
49
 
50
+ const gitPluginId = 'vscode.git';
51
+
52
+ /**
53
+ * @param {() => unknown} condition
54
+ * @param {number | undefined} [timeout]
55
+ * @param {string | undefined} [message]
56
+ * @returns {Promise<void>}
57
+ */
58
+ function waitForAnimation(condition, timeout, message) {
59
+ const success = new Promise(async (resolve, reject) => {
60
+ if (timeout === undefined) {
61
+ timeout = 100000;
62
+ }
63
+
64
+ let timedOut = false;
65
+ const handle = setTimeout(() => {
66
+ console.log(message);
67
+ timedOut = true;
68
+ }, timeout);
69
+
70
+ do {
71
+ await animationFrame();
72
+ } while (!timedOut && !condition());
73
+ if (timedOut) {
74
+ reject(new Error(message ?? 'Wait for animation timed out.'));
75
+ } else {
76
+ clearTimeout(handle);
77
+ resolve(undefined);
78
+ }
79
+
80
+ });
81
+ return success;
82
+ }
83
+
42
84
  beforeEach(async () => {
85
+ if (!pluginService.getPlugin(gitPluginId)) {
86
+ throw new Error(gitPluginId + ' should be started');
87
+ }
88
+ await pluginService.activatePlugin(gitPluginId);
43
89
  await shell.leftPanelHandler.collapse();
44
90
  scmWidget = await scmContribution.openView({ activate: true, reveal: true });
45
91
  scmService = service;
92
+ await waitForAnimation(() => scmService.selectedRepository, 10000, 'selected repository is not defined');
46
93
  });
47
94
 
48
95
  afterEach(() => {
@@ -53,7 +100,6 @@ describe('SCM', function () {
53
100
  });
54
101
 
55
102
  describe('scm-view', () => {
56
-
57
103
  it('the view should open and activate successfully', () => {
58
104
  assert.notEqual(scmWidget, undefined);
59
105
  assert.strictEqual(scmWidget, shell.activeWidget);
@@ -125,6 +171,9 @@ describe('SCM', function () {
125
171
  const foundRepository = scmService.findRepository(new Uri.default(rootUri));
126
172
  assert.notEqual(foundRepository, undefined);
127
173
  }
174
+ else {
175
+ assert.fail('Selected repository is undefined');
176
+ }
128
177
  });
129
178
 
130
179
  it('should not find a repository for an unknown uri', () => {
@@ -150,6 +199,9 @@ describe('SCM', function () {
150
199
  assert.notEqual(commit, undefined);
151
200
  }
152
201
  }
202
+ else {
203
+ assert.fail('Selected repository is undefined');
204
+ }
153
205
  });
154
206
 
155
207
  });
@@ -102,10 +102,10 @@ describe('TypeScript', function () {
102
102
  const editorWidget = widget instanceof EditorWidget ? widget : undefined;
103
103
  const editor = MonacoEditor.get(editorWidget);
104
104
  assert.isDefined(editor);
105
+ await timeout(1000); // workaround for https://github.com/eclipse-theia/theia/issues/13679
105
106
  // wait till tsserver is running, see:
106
107
  // https://github.com/microsoft/vscode/blob/93cbbc5cae50e9f5f5046343c751b6d010468200/extensions/typescript-language-features/src/extension.ts#L98-L103
107
- await waitForAnimation(() => contextKeyService.match('typescript.isManagedFile'));
108
- // wait till projects are loaded, see:
108
+ // await waitForAnimation(() => contextKeyService.match('typescript.isManagedFile'));
109
109
  // https://github.com/microsoft/vscode/blob/4aac84268c6226d23828cc6a1fe45ee3982927f0/extensions/typescript-language-features/src/typescriptServiceClient.ts#L911
110
110
  await waitForAnimation(() => !progressStatusBarItem.currentProgress);
111
111
  return /** @type {MonacoEditor} */ (editor);
@@ -210,16 +210,8 @@ describe('TypeScript', function () {
210
210
  await assertPeekOpened(editor);
211
211
 
212
212
  console.log('closePeek() - Attempt to close by sending "Escape"');
213
- keybindings.dispatchKeyDown('Escape');
214
- await waitForAnimation(() => {
215
- const isClosed = !contextKeyService.match('listFocus');
216
- if (!isClosed) {
217
- console.log('...');
218
- keybindings.dispatchKeyDown('Escape');
219
- return false;
220
- }
221
- return true;
222
- });
213
+ await dismissWithEscape('listFocus');
214
+
223
215
  assert.isTrue(contextKeyService.match('editorTextFocus'));
224
216
  assert.isFalse(contextKeyService.match('referenceSearchVisible'));
225
217
  assert.isFalse(contextKeyService.match('listFocus'));
@@ -510,7 +502,23 @@ describe('TypeScript', function () {
510
502
  assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber: 28, column: 1 }).word, 'foo');
511
503
  });
512
504
 
505
+ async function dismissWithEscape(contextKey) {
506
+ keybindings.dispatchKeyDown('Escape');
507
+ // once in a while, a second "Escape" is needed to dismiss widget
508
+ return waitForAnimation(() => {
509
+ const suggestWidgetDismissed = !contextKeyService.match(contextKey);
510
+ if (!suggestWidgetDismissed) {
511
+ console.log(`Re-try to dismiss ${contextKey} using "Escape" key`);
512
+ keybindings.dispatchKeyDown('Escape');
513
+ return false;
514
+ }
515
+ return true;
516
+ }, 5000, `${contextKey} widget not dismissed`);
517
+ }
518
+
513
519
  it('editor.action.triggerParameterHints', async function () {
520
+ this.timeout(30000);
521
+ console.log('start trigger parameter hint');
514
522
  const editor = await openEditor(demoFileUri);
515
523
  // const demoInstance = new DemoClass('|demo');
516
524
  editor.getControl().setPosition({ lineNumber: 24, column: 37 });
@@ -520,13 +528,14 @@ describe('TypeScript', function () {
520
528
  assert.isFalse(contextKeyService.match('parameterHintsVisible'));
521
529
 
522
530
  await commands.executeCommand('editor.action.triggerParameterHints');
531
+ console.log('trigger command');
523
532
  await waitForAnimation(() => contextKeyService.match('parameterHintsVisible'));
533
+ console.log('context key matched');
524
534
 
525
535
  assert.isTrue(contextKeyService.match('editorTextFocus'));
526
536
  assert.isTrue(contextKeyService.match('parameterHintsVisible'));
527
537
 
528
- keybindings.dispatchKeyDown('Escape');
529
- await waitForAnimation(() => !contextKeyService.match('parameterHintsVisible'));
538
+ await dismissWithEscape('parameterHintsVisible');
530
539
 
531
540
  assert.isTrue(contextKeyService.match('editorTextFocus'));
532
541
  assert.isFalse(contextKeyService.match('parameterHintsVisible'));
@@ -542,12 +551,13 @@ describe('TypeScript', function () {
542
551
  const hover = editor.getControl().getContribution('editor.contrib.hover');
543
552
 
544
553
  assert.isTrue(contextKeyService.match('editorTextFocus'));
545
- assert.isFalse(Boolean(hover['_contentWidget']?.['_widget']?.['_visibleData']));
554
+ assert.isFalse(contextKeyService.match('editorHoverVisible'));
546
555
  await commands.executeCommand('editor.action.showHover');
547
556
  let doLog = true;
548
- await waitForAnimation(() => hover['_contentWidget']?.['_widget']?.['_visibleData']);
557
+ await waitForAnimation(() => contextKeyService.match('editorHoverVisible'));
558
+ assert.isTrue(contextKeyService.match('editorHoverVisible'));
549
559
  assert.isTrue(contextKeyService.match('editorTextFocus'));
550
- assert.isTrue(Boolean(hover['_contentWidget']?.['_widget']?.['_visibleData']));
560
+
551
561
  assert.deepEqual(nodeAsString(hover['_contentWidget']?.['_widget']?.['_hover']?.['contentsDomNode']).trim(), `
552
562
  DIV {
553
563
  DIV {
@@ -572,8 +582,7 @@ DIV {
572
582
  }
573
583
  }
574
584
  }`.trim());
575
- keybindings.dispatchKeyDown('Escape');
576
- await waitForAnimation(() => !hover['_contentWidget']?.['_widget']?.['_visibleData']);
585
+ await dismissWithEscape('editorHoverVisible');
577
586
  assert.isTrue(contextKeyService.match('editorTextFocus'));
578
587
  assert.isFalse(Boolean(hover['_contentWidget']?.['_widget']?.['_visibleData']));
579
588
  });