@theia/api-tests 1.49.1 → 1.50.1
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 +3 -3
- package/src/monaco-api.spec.js +0 -1
- package/src/saveable.spec.js +1 -1
- package/src/scm.spec.js +53 -1
- package/src/typescript.spec.js +33 -23
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/api-tests",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.50.1",
|
|
4
4
|
"description": "Theia API tests",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.
|
|
6
|
+
"@theia/core": "1.50.1"
|
|
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": "
|
|
23
|
+
"gitHead": "ffefc7ac2c0f6c63256042b7710551304200e5e1"
|
|
24
24
|
}
|
package/src/monaco-api.spec.js
CHANGED
package/src/saveable.spec.js
CHANGED
|
@@ -81,13 +81,13 @@ describe('Saveable', function () {
|
|
|
81
81
|
|
|
82
82
|
afterEach(async () => {
|
|
83
83
|
toTearDown.dispose();
|
|
84
|
-
await preferences.set('files.autoSave', autoSave, undefined, rootUri.toString());
|
|
85
84
|
// @ts-ignore
|
|
86
85
|
editor = undefined;
|
|
87
86
|
// @ts-ignore
|
|
88
87
|
widget = undefined;
|
|
89
88
|
await editorManager.closeAll({ save: false });
|
|
90
89
|
await fileService.delete(fileUri.parent, { fromUserGesture: false, useTrash: false, recursive: true });
|
|
90
|
+
await preferences.set('files.autoSave', autoSave, undefined, rootUri.toString());
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
it('normal save', async function () {
|
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
|
});
|
package/src/typescript.spec.js
CHANGED
|
@@ -64,7 +64,7 @@ describe('TypeScript', function () {
|
|
|
64
64
|
const rootUri = workspaceService.tryGetRoots()[0].resource;
|
|
65
65
|
const demoFileUri = rootUri.resolveToAbsolute('../api-tests/test-ts-workspace/demo-file.ts');
|
|
66
66
|
const definitionFileUri = rootUri.resolveToAbsolute('../api-tests/test-ts-workspace/demo-definitions-file.ts');
|
|
67
|
-
let originalAutoSaveValue = preferences.
|
|
67
|
+
let originalAutoSaveValue = preferences.get('files.autoSave');
|
|
68
68
|
|
|
69
69
|
before(async function () {
|
|
70
70
|
await pluginService.didStart;
|
|
@@ -73,8 +73,9 @@ describe('TypeScript', function () {
|
|
|
73
73
|
throw new Error(pluginId + ' should be started');
|
|
74
74
|
}
|
|
75
75
|
await pluginService.activatePlugin(pluginId);
|
|
76
|
-
})
|
|
77
|
-
await preferences.set('files.
|
|
76
|
+
}));
|
|
77
|
+
await preferences.set('files.autoSave', 'off');
|
|
78
|
+
await preferences.set('files.refactoring.autoSave', 'off');
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
beforeEach(async function () {
|
|
@@ -90,7 +91,7 @@ describe('TypeScript', function () {
|
|
|
90
91
|
});
|
|
91
92
|
|
|
92
93
|
after(async () => {
|
|
93
|
-
await preferences.set('files.autoSave', originalAutoSaveValue
|
|
94
|
+
await preferences.set('files.autoSave', originalAutoSaveValue);
|
|
94
95
|
})
|
|
95
96
|
|
|
96
97
|
/**
|
|
@@ -102,10 +103,10 @@ describe('TypeScript', function () {
|
|
|
102
103
|
const editorWidget = widget instanceof EditorWidget ? widget : undefined;
|
|
103
104
|
const editor = MonacoEditor.get(editorWidget);
|
|
104
105
|
assert.isDefined(editor);
|
|
106
|
+
await timeout(1000); // workaround for https://github.com/eclipse-theia/theia/issues/13679
|
|
105
107
|
// wait till tsserver is running, see:
|
|
106
108
|
// 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:
|
|
109
|
+
// await waitForAnimation(() => contextKeyService.match('typescript.isManagedFile'));
|
|
109
110
|
// https://github.com/microsoft/vscode/blob/4aac84268c6226d23828cc6a1fe45ee3982927f0/extensions/typescript-language-features/src/typescriptServiceClient.ts#L911
|
|
110
111
|
await waitForAnimation(() => !progressStatusBarItem.currentProgress);
|
|
111
112
|
return /** @type {MonacoEditor} */ (editor);
|
|
@@ -210,16 +211,8 @@ describe('TypeScript', function () {
|
|
|
210
211
|
await assertPeekOpened(editor);
|
|
211
212
|
|
|
212
213
|
console.log('closePeek() - Attempt to close by sending "Escape"');
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const isClosed = !contextKeyService.match('listFocus');
|
|
216
|
-
if (!isClosed) {
|
|
217
|
-
console.log('...');
|
|
218
|
-
keybindings.dispatchKeyDown('Escape');
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
return true;
|
|
222
|
-
});
|
|
214
|
+
await dismissWithEscape('listFocus');
|
|
215
|
+
|
|
223
216
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
224
217
|
assert.isFalse(contextKeyService.match('referenceSearchVisible'));
|
|
225
218
|
assert.isFalse(contextKeyService.match('listFocus'));
|
|
@@ -510,7 +503,23 @@ describe('TypeScript', function () {
|
|
|
510
503
|
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber: 28, column: 1 }).word, 'foo');
|
|
511
504
|
});
|
|
512
505
|
|
|
506
|
+
async function dismissWithEscape(contextKey) {
|
|
507
|
+
keybindings.dispatchKeyDown('Escape');
|
|
508
|
+
// once in a while, a second "Escape" is needed to dismiss widget
|
|
509
|
+
return waitForAnimation(() => {
|
|
510
|
+
const suggestWidgetDismissed = !contextKeyService.match(contextKey);
|
|
511
|
+
if (!suggestWidgetDismissed) {
|
|
512
|
+
console.log(`Re-try to dismiss ${contextKey} using "Escape" key`);
|
|
513
|
+
keybindings.dispatchKeyDown('Escape');
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
return true;
|
|
517
|
+
}, 5000, `${contextKey} widget not dismissed`);
|
|
518
|
+
}
|
|
519
|
+
|
|
513
520
|
it('editor.action.triggerParameterHints', async function () {
|
|
521
|
+
this.timeout(30000);
|
|
522
|
+
console.log('start trigger parameter hint');
|
|
514
523
|
const editor = await openEditor(demoFileUri);
|
|
515
524
|
// const demoInstance = new DemoClass('|demo');
|
|
516
525
|
editor.getControl().setPosition({ lineNumber: 24, column: 37 });
|
|
@@ -520,13 +529,14 @@ describe('TypeScript', function () {
|
|
|
520
529
|
assert.isFalse(contextKeyService.match('parameterHintsVisible'));
|
|
521
530
|
|
|
522
531
|
await commands.executeCommand('editor.action.triggerParameterHints');
|
|
532
|
+
console.log('trigger command');
|
|
523
533
|
await waitForAnimation(() => contextKeyService.match('parameterHintsVisible'));
|
|
534
|
+
console.log('context key matched');
|
|
524
535
|
|
|
525
536
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
526
537
|
assert.isTrue(contextKeyService.match('parameterHintsVisible'));
|
|
527
538
|
|
|
528
|
-
|
|
529
|
-
await waitForAnimation(() => !contextKeyService.match('parameterHintsVisible'));
|
|
539
|
+
await dismissWithEscape('parameterHintsVisible');
|
|
530
540
|
|
|
531
541
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
532
542
|
assert.isFalse(contextKeyService.match('parameterHintsVisible'));
|
|
@@ -542,12 +552,13 @@ describe('TypeScript', function () {
|
|
|
542
552
|
const hover = editor.getControl().getContribution('editor.contrib.hover');
|
|
543
553
|
|
|
544
554
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
545
|
-
assert.isFalse(
|
|
555
|
+
assert.isFalse(contextKeyService.match('editorHoverVisible'));
|
|
546
556
|
await commands.executeCommand('editor.action.showHover');
|
|
547
557
|
let doLog = true;
|
|
548
|
-
await waitForAnimation(() =>
|
|
558
|
+
await waitForAnimation(() => contextKeyService.match('editorHoverVisible'));
|
|
559
|
+
assert.isTrue(contextKeyService.match('editorHoverVisible'));
|
|
549
560
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
550
|
-
|
|
561
|
+
|
|
551
562
|
assert.deepEqual(nodeAsString(hover['_contentWidget']?.['_widget']?.['_hover']?.['contentsDomNode']).trim(), `
|
|
552
563
|
DIV {
|
|
553
564
|
DIV {
|
|
@@ -572,8 +583,7 @@ DIV {
|
|
|
572
583
|
}
|
|
573
584
|
}
|
|
574
585
|
}`.trim());
|
|
575
|
-
|
|
576
|
-
await waitForAnimation(() => !hover['_contentWidget']?.['_widget']?.['_visibleData']);
|
|
586
|
+
await dismissWithEscape('editorHoverVisible');
|
|
577
587
|
assert.isTrue(contextKeyService.match('editorTextFocus'));
|
|
578
588
|
assert.isFalse(Boolean(hover['_contentWidget']?.['_widget']?.['_visibleData']));
|
|
579
589
|
});
|