@theia/api-tests 1.45.0 → 1.46.0-next.106
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 +29 -31
- package/src/saveable.spec.js +1 -1
- package/src/typescript.spec.js +51 -47
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/api-tests",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.46.0-next.106+cf038c17c",
|
|
4
4
|
"description": "Theia API tests",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.
|
|
6
|
+
"@theia/core": "1.46.0-next.106+cf038c17c"
|
|
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": "cf038c17c3b3b210d9ae02b09d64921f639247f9"
|
|
24
24
|
}
|
package/src/monaco-api.spec.js
CHANGED
|
@@ -26,7 +26,7 @@ describe('Monaco API', async function () {
|
|
|
26
26
|
const { MonacoResolvedKeybinding } = require('@theia/monaco/lib/browser/monaco-resolved-keybinding');
|
|
27
27
|
const { MonacoTextmateService } = require('@theia/monaco/lib/browser/textmate/monaco-textmate-service');
|
|
28
28
|
const { CommandRegistry } = require('@theia/core/lib/common/command');
|
|
29
|
-
const {
|
|
29
|
+
const { KeyCodeChord, ResolvedChord } = require('@theia/monaco-editor-core/esm/vs/base/common/keybindings');
|
|
30
30
|
const { IKeybindingService } = require('@theia/monaco-editor-core/esm/vs/platform/keybinding/common/keybinding');
|
|
31
31
|
const { StandaloneServices } = require('@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices');
|
|
32
32
|
const { TokenizationRegistry } = require('@theia/monaco-editor-core/esm/vs/editor/common/languages');
|
|
@@ -59,10 +59,10 @@ describe('Monaco API', async function () {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it('KeybindingService.resolveKeybinding', () => {
|
|
62
|
-
const
|
|
63
|
-
const chordKeybinding =
|
|
64
|
-
assert.equal(chordKeybinding.
|
|
65
|
-
assert.equal(chordKeybinding.
|
|
62
|
+
const chord = new KeyCodeChord(true, true, true, true, 41 /* KeyCode.KeyK */);
|
|
63
|
+
const chordKeybinding = chord.toKeybinding();
|
|
64
|
+
assert.equal(chordKeybinding.chords.length, 1);
|
|
65
|
+
assert.equal(chordKeybinding.chords[0], chord);
|
|
66
66
|
|
|
67
67
|
const resolvedKeybindings = StandaloneServices.get(IKeybindingService).resolveKeybinding(chordKeybinding);
|
|
68
68
|
assert.equal(resolvedKeybindings.length, 1);
|
|
@@ -74,9 +74,8 @@ describe('Monaco API', async function () {
|
|
|
74
74
|
const electronAccelerator = resolvedKeybinding.getElectronAccelerator();
|
|
75
75
|
const userSettingsLabel = resolvedKeybinding.getUserSettingsLabel();
|
|
76
76
|
const WYSIWYG = resolvedKeybinding.isWYSIWYG();
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const dispatchParts = resolvedKeybinding.getDispatchParts();
|
|
77
|
+
const parts = resolvedKeybinding.getChords();
|
|
78
|
+
const dispatchParts = resolvedKeybinding.getDispatchChords().map(str => str === null ? '' : str);
|
|
80
79
|
|
|
81
80
|
const platform = window.navigator.platform;
|
|
82
81
|
let expected;
|
|
@@ -89,14 +88,14 @@ describe('Monaco API', async function () {
|
|
|
89
88
|
userSettingsLabel: 'ctrl+shift+alt+cmd+K',
|
|
90
89
|
WYSIWYG: true,
|
|
91
90
|
chord: false,
|
|
92
|
-
parts: [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
parts: [new ResolvedChord(
|
|
92
|
+
true,
|
|
93
|
+
true,
|
|
94
|
+
true,
|
|
95
|
+
true,
|
|
96
|
+
'K',
|
|
97
|
+
'K',
|
|
98
|
+
)],
|
|
100
99
|
dispatchParts: [
|
|
101
100
|
'ctrl+shift+alt+meta+K'
|
|
102
101
|
]
|
|
@@ -108,15 +107,14 @@ describe('Monaco API', async function () {
|
|
|
108
107
|
electronAccelerator: 'Ctrl+Shift+Alt+K',
|
|
109
108
|
userSettingsLabel: 'ctrl+shift+alt+K',
|
|
110
109
|
WYSIWYG: true,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}],
|
|
110
|
+
parts: [new ResolvedChord(
|
|
111
|
+
true,
|
|
112
|
+
true,
|
|
113
|
+
true,
|
|
114
|
+
false,
|
|
115
|
+
'K',
|
|
116
|
+
'K'
|
|
117
|
+
)],
|
|
120
118
|
dispatchParts: [
|
|
121
119
|
'ctrl+shift+alt+K'
|
|
122
120
|
]
|
|
@@ -124,7 +122,7 @@ describe('Monaco API', async function () {
|
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
assert.deepStrictEqual({
|
|
127
|
-
label, ariaLabel, electronAccelerator, userSettingsLabel, WYSIWYG,
|
|
125
|
+
label, ariaLabel, electronAccelerator, userSettingsLabel, WYSIWYG, parts, dispatchParts
|
|
128
126
|
}, expected);
|
|
129
127
|
} else {
|
|
130
128
|
assert.fail(`resolvedKeybinding must be of ${MonacoResolvedKeybinding.name} type`);
|
|
@@ -136,7 +134,7 @@ describe('Monaco API', async function () {
|
|
|
136
134
|
const didChangeColorMap = new Promise(resolve => {
|
|
137
135
|
const toDispose = TokenizationRegistry.onDidChange(() => {
|
|
138
136
|
toDispose.dispose();
|
|
139
|
-
resolve();
|
|
137
|
+
resolve(undefined);
|
|
140
138
|
});
|
|
141
139
|
});
|
|
142
140
|
textmateService['themeService'].setCurrentTheme('light');
|
|
@@ -175,15 +173,15 @@ describe('Monaco API', async function () {
|
|
|
175
173
|
});
|
|
176
174
|
|
|
177
175
|
it('Supports setting contexts using the command registry', async () => {
|
|
178
|
-
const setContext = '
|
|
176
|
+
const setContext = '_setContext';
|
|
179
177
|
const key = 'monaco-api-test-context';
|
|
180
178
|
const firstValue = 'first setting';
|
|
181
179
|
const secondValue = 'second setting';
|
|
182
|
-
assert.isFalse(contextKeys.match(`${key} == ${firstValue}`));
|
|
180
|
+
assert.isFalse(contextKeys.match(`${key} == '${firstValue}'`));
|
|
183
181
|
await commands.executeCommand(setContext, key, firstValue);
|
|
184
|
-
assert.isTrue(contextKeys.match(`${key} == ${firstValue}`));
|
|
182
|
+
assert.isTrue(contextKeys.match(`${key} == '${firstValue}'`));
|
|
185
183
|
await commands.executeCommand(setContext, key, secondValue);
|
|
186
|
-
assert.isTrue(contextKeys.match(`${key} == ${secondValue}`));
|
|
184
|
+
assert.isTrue(contextKeys.match(`${key} == '${secondValue}'`));
|
|
187
185
|
});
|
|
188
186
|
|
|
189
187
|
it('Supports context key: inQuickOpen', async () => {
|
package/src/saveable.spec.js
CHANGED
package/src/typescript.spec.js
CHANGED
|
@@ -19,6 +19,7 @@ describe('TypeScript', function () {
|
|
|
19
19
|
this.timeout(30_000);
|
|
20
20
|
|
|
21
21
|
const { assert } = chai;
|
|
22
|
+
const { timeout } = require('@theia/core/lib/common/promise-util');
|
|
22
23
|
|
|
23
24
|
const Uri = require('@theia/core/lib/common/uri');
|
|
24
25
|
const { DisposableCollection } = require('@theia/core/lib/common/disposable');
|
|
@@ -118,19 +119,28 @@ describe('TypeScript', function () {
|
|
|
118
119
|
*/
|
|
119
120
|
function waitForAnimation(condition, timeout, message) {
|
|
120
121
|
const success = new Promise(async (resolve, reject) => {
|
|
122
|
+
if (timeout === undefined) {
|
|
123
|
+
timeout = 100000;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let timedOut = false;
|
|
127
|
+
const handle = setTimeout(() => {
|
|
128
|
+
console.log(message);
|
|
129
|
+
timedOut = true;
|
|
130
|
+
}, timeout);
|
|
131
|
+
|
|
121
132
|
toTearDown.push({ dispose: () => reject(message ?? 'Test terminated before resolution.') });
|
|
122
133
|
do {
|
|
123
134
|
await animationFrame();
|
|
124
|
-
} while (!condition());
|
|
125
|
-
|
|
135
|
+
} while (!timedOut && !condition());
|
|
136
|
+
if (timedOut) {
|
|
137
|
+
reject(new Error(message ?? 'Wait for animation timed out.'));
|
|
138
|
+
} else {
|
|
139
|
+
clearTimeout(handle);
|
|
140
|
+
resolve(undefined);
|
|
141
|
+
}
|
|
142
|
+
|
|
126
143
|
});
|
|
127
|
-
if (timeout !== undefined) {
|
|
128
|
-
const timedOut = new Promise((_, fail) => {
|
|
129
|
-
const toClear = setTimeout(() => fail(new Error(message ?? 'Wait for animation timed out.')), timeout);
|
|
130
|
-
toTearDown.push({ dispose: () => (fail(new Error(message ?? 'Wait for animation timed out.')), clearTimeout(toClear)) });
|
|
131
|
-
});
|
|
132
|
-
return Promise.race([success, timedOut]);
|
|
133
|
-
}
|
|
134
144
|
return success;
|
|
135
145
|
}
|
|
136
146
|
|
|
@@ -688,11 +698,10 @@ SPAN {
|
|
|
688
698
|
editor.getControl().revealPosition({ lineNumber, column });
|
|
689
699
|
assert.equal(currentChar(), ';', 'Failed at assert 1');
|
|
690
700
|
|
|
691
|
-
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/
|
|
701
|
+
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionController').CodeActionController} */
|
|
692
702
|
const codeActionController = editor.getControl().getContribution('editor.contrib.codeActionController');
|
|
693
703
|
const lightBulbNode = () => {
|
|
694
|
-
const
|
|
695
|
-
const lightBulb = ui && ui['_lightBulbWidget'].rawValue;
|
|
704
|
+
const lightBulb = codeActionController['_lightBulbWidget'].rawValue;
|
|
696
705
|
return lightBulb && lightBulb['_domNode'];
|
|
697
706
|
};
|
|
698
707
|
const lightBulbVisible = () => {
|
|
@@ -700,18 +709,16 @@ SPAN {
|
|
|
700
709
|
return !!node && node.style.visibility !== 'hidden';
|
|
701
710
|
};
|
|
702
711
|
|
|
703
|
-
|
|
704
|
-
await waitForAnimation(() => lightBulbVisible());
|
|
705
|
-
|
|
712
|
+
await timeout(1000); // quick fix is always available: need to wait for the error fix to become available.
|
|
706
713
|
await commands.executeCommand('editor.action.quickFix');
|
|
707
|
-
const codeActionSelector = '.
|
|
714
|
+
const codeActionSelector = '.action-widget';
|
|
708
715
|
assert.isFalse(!!document.querySelector(codeActionSelector), 'Failed at assert 3 - codeActionWidget should not be visible');
|
|
709
716
|
|
|
710
717
|
console.log('Waiting for Quick Fix widget to be visible');
|
|
711
718
|
await waitForAnimation(() => {
|
|
712
719
|
const quickFixWidgetVisible = !!document.querySelector(codeActionSelector);
|
|
713
720
|
if (!quickFixWidgetVisible) {
|
|
714
|
-
console.log('...');
|
|
721
|
+
// console.log('...');
|
|
715
722
|
return false;
|
|
716
723
|
}
|
|
717
724
|
return true;
|
|
@@ -721,20 +728,9 @@ SPAN {
|
|
|
721
728
|
assert.isTrue(lightBulbVisible(), 'Failed at assert 4');
|
|
722
729
|
keybindings.dispatchKeyDown('Enter');
|
|
723
730
|
console.log('Waiting for confirmation that QuickFix has taken effect');
|
|
724
|
-
await waitForAnimation(() => {
|
|
725
|
-
const quickFixHasTakenEffect = !lightBulbVisible();
|
|
726
|
-
if (!quickFixHasTakenEffect) {
|
|
727
|
-
console.log('...');
|
|
728
|
-
return false;
|
|
729
|
-
}
|
|
730
|
-
return true;
|
|
731
|
-
}, 5000, 'Quickfix widget has not been dismissed despite attempts to accept suggestion');
|
|
732
731
|
|
|
733
|
-
await waitForAnimation(() => currentChar() === 'd',
|
|
732
|
+
await waitForAnimation(() => currentChar() === 'd', 10000, 'Failed to detect expected selected char: "d"');
|
|
734
733
|
assert.equal(currentChar(), 'd', 'Failed at assert 5');
|
|
735
|
-
|
|
736
|
-
await waitForAnimation(() => !lightBulbVisible());
|
|
737
|
-
assert.isFalse(lightBulbVisible(), 'Failed at assert 6');
|
|
738
734
|
});
|
|
739
735
|
|
|
740
736
|
it('editor.action.formatDocument', async function () {
|
|
@@ -780,27 +776,12 @@ SPAN {
|
|
|
780
776
|
assert.equal(editor.getControl().getModel().getLineLength(lineNumber), originalLength);
|
|
781
777
|
});
|
|
782
778
|
|
|
783
|
-
for (const referenceViewCommand of ['references-view.find', 'references-view.findImplementations']) {
|
|
784
|
-
it(referenceViewCommand, async function () {
|
|
785
|
-
let steps = 0;
|
|
786
|
-
const editor = await openEditor(demoFileUri);
|
|
787
|
-
editor.getControl().setPosition({ lineNumber: 24, column: 11 });
|
|
788
|
-
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'demoInstance');
|
|
789
|
-
await commands.executeCommand(referenceViewCommand);
|
|
790
|
-
const view = await pluginViewRegistry.openView('references-view.tree', { reveal: true });
|
|
791
|
-
const expectedMessage = referenceViewCommand === 'references-view.find' ? '2 results in 1 file' : '1 result in 1 file';
|
|
792
|
-
const getResultText = () => view.node.getElementsByClassName('theia-TreeViewInfo').item(0)?.textContent;
|
|
793
|
-
await waitForAnimation(() => getResultText() === expectedMessage, 5000);
|
|
794
|
-
assert.equal(getResultText(), expectedMessage);
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
|
|
798
779
|
it('Can execute code actions', async function () {
|
|
799
780
|
const editor = await openEditor(demoFileUri);
|
|
800
|
-
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/
|
|
781
|
+
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codeAction/browser/codeActionController').CodeActionController} */
|
|
801
782
|
const codeActionController = editor.getControl().getContribution('editor.contrib.codeActionController');
|
|
802
783
|
const isActionAvailable = () => {
|
|
803
|
-
const lightbulbVisibility = codeActionController['
|
|
784
|
+
const lightbulbVisibility = codeActionController['_lightBulbWidget'].rawValue?.['_domNode'].style.visibility;
|
|
804
785
|
return lightbulbVisibility !== undefined && lightbulbVisibility !== 'hidden';
|
|
805
786
|
}
|
|
806
787
|
assert.isFalse(isActionAvailable());
|
|
@@ -810,8 +791,16 @@ SPAN {
|
|
|
810
791
|
await waitForAnimation(() => isActionAvailable(), 5000, 'No code action available. (1)');
|
|
811
792
|
assert.isTrue(isActionAvailable());
|
|
812
793
|
|
|
794
|
+
try { // for some reason, we need to wait a second here, otherwise, we run into some cancellation.
|
|
795
|
+
await waitForAnimation(() => false, 1000);
|
|
796
|
+
} catch (e) {
|
|
797
|
+
}
|
|
798
|
+
|
|
813
799
|
await commands.executeCommand('editor.action.quickFix');
|
|
814
|
-
await waitForAnimation(() =>
|
|
800
|
+
await waitForAnimation(() => {
|
|
801
|
+
const elements = document.querySelector('.action-widget');
|
|
802
|
+
return !!elements;
|
|
803
|
+
}, 5000, 'No context menu appeared. (1)');
|
|
815
804
|
await animationFrame();
|
|
816
805
|
|
|
817
806
|
keybindings.dispatchKeyDown('Enter');
|
|
@@ -853,4 +842,19 @@ SPAN {
|
|
|
853
842
|
assert.isNotNull(editor.getControl().getModel());
|
|
854
843
|
await waitForAnimation(() => editor.getControl().getModel().getLineContent(30) === 'import { DefinedInterface } from "./demo-definitions-file";', 5000, 'The named import did not take effect.');
|
|
855
844
|
});
|
|
845
|
+
|
|
846
|
+
for (const referenceViewCommand of ['references-view.find', 'references-view.findImplementations']) {
|
|
847
|
+
it(referenceViewCommand, async function () {
|
|
848
|
+
let steps = 0;
|
|
849
|
+
const editor = await openEditor(demoFileUri);
|
|
850
|
+
editor.getControl().setPosition({ lineNumber: 24, column: 11 });
|
|
851
|
+
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'demoInstance');
|
|
852
|
+
await commands.executeCommand(referenceViewCommand);
|
|
853
|
+
const view = await pluginViewRegistry.openView('references-view.tree', { reveal: true });
|
|
854
|
+
const expectedMessage = referenceViewCommand === 'references-view.find' ? '2 results in 1 file' : '1 result in 1 file';
|
|
855
|
+
const getResultText = () => view.node.getElementsByClassName('theia-TreeViewInfo').item(0)?.textContent;
|
|
856
|
+
await waitForAnimation(() => getResultText() === expectedMessage, 5000);
|
|
857
|
+
assert.equal(getResultText(), expectedMessage);
|
|
858
|
+
});
|
|
859
|
+
}
|
|
856
860
|
});
|