@theia/api-tests 1.26.0-next.4 → 1.26.0-next.44
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/preferences.spec.js +12 -2
- package/src/typescript.spec.js +28 -42
- package/src/undo-redo-selectAll.spec.js +9 -3
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/api-tests",
|
|
3
|
-
"version": "1.26.0-next.
|
|
3
|
+
"version": "1.26.0-next.44+4099a4ec58f",
|
|
4
4
|
"description": "Theia API tests",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.26.0-next.
|
|
6
|
+
"@theia/core": "1.26.0-next.44+4099a4ec58f"
|
|
7
7
|
},
|
|
8
8
|
"license": "EPL-2.0 OR GPL-2.0 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": "4099a4ec58f8573a36b32514d37b7d8541db7030"
|
|
24
24
|
}
|
package/src/preferences.spec.js
CHANGED
|
@@ -66,6 +66,13 @@ describe('Preferences', function () {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
async function deleteAllValues() {
|
|
69
|
+
return setValueTo(undefined);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param {any} value - A JSON value to write to the workspace preference file.
|
|
74
|
+
*/
|
|
75
|
+
async function setValueTo(value) {
|
|
69
76
|
const reference = await modelService.createModelReference(uri);
|
|
70
77
|
if (reference.object.dirty) {
|
|
71
78
|
await reference.object.revert();
|
|
@@ -73,7 +80,7 @@ describe('Preferences', function () {
|
|
|
73
80
|
/** @type {import ('@theia/preferences/lib/browser/folder-preference-provider').FolderPreferenceProvider} */
|
|
74
81
|
const provider = Array.from(folderPreferences['providers'].values()).find(candidate => candidate.getConfigUri().isEqual(uri));
|
|
75
82
|
assert.isDefined(provider);
|
|
76
|
-
await provider['doSetPreference']('', [],
|
|
83
|
+
await provider['doSetPreference']('', [], value);
|
|
77
84
|
reference.dispose();
|
|
78
85
|
}
|
|
79
86
|
|
|
@@ -92,7 +99,10 @@ describe('Preferences', function () {
|
|
|
92
99
|
if (!fileExistsBeforehand) {
|
|
93
100
|
await fileService.delete(uri, { fromUserGesture: false }).catch(() => { });
|
|
94
101
|
} else {
|
|
95
|
-
|
|
102
|
+
let content = '';
|
|
103
|
+
try { content = JSON.parse(contentBeforehand); } catch { }
|
|
104
|
+
// Use the preference service because its promise is guaranteed to resolve after the file change is complete.
|
|
105
|
+
await setValueTo(content);
|
|
96
106
|
}
|
|
97
107
|
});
|
|
98
108
|
|
package/src/typescript.spec.js
CHANGED
|
@@ -48,6 +48,7 @@ describe('TypeScript', function () {
|
|
|
48
48
|
const contextKeyService = container.get(ContextKeyService);
|
|
49
49
|
const commands = container.get(CommandRegistry);
|
|
50
50
|
const openerService = container.get(OpenerService);
|
|
51
|
+
/** @type {KeybindingRegistry} */
|
|
51
52
|
const keybindings = container.get(KeybindingRegistry);
|
|
52
53
|
/** @type {import('@theia/core/lib/browser/preferences/preference-service').PreferenceService} */
|
|
53
54
|
const preferences = container.get(PreferenceService);
|
|
@@ -108,11 +109,12 @@ describe('TypeScript', function () {
|
|
|
108
109
|
/**
|
|
109
110
|
* @param {() => Promise<unknown> | unknown} condition
|
|
110
111
|
* @param {number | undefined} [timeout]
|
|
112
|
+
* @param {string | undefined} [message]
|
|
111
113
|
* @returns {Promise<void>}
|
|
112
114
|
*/
|
|
113
|
-
function waitForAnimation(condition, timeout) {
|
|
114
|
-
const success = new Promise(async (resolve,
|
|
115
|
-
toTearDown.push({ dispose });
|
|
115
|
+
function waitForAnimation(condition, timeout, message) {
|
|
116
|
+
const success = new Promise(async (resolve, reject) => {
|
|
117
|
+
toTearDown.push({ dispose: () => reject(message ?? 'Test terminated before resolution.') });
|
|
116
118
|
do {
|
|
117
119
|
await animationFrame();
|
|
118
120
|
} while (!condition());
|
|
@@ -120,8 +122,8 @@ describe('TypeScript', function () {
|
|
|
120
122
|
});
|
|
121
123
|
if (timeout !== undefined) {
|
|
122
124
|
const timedOut = new Promise((_, fail) => {
|
|
123
|
-
const toClear = setTimeout(() => fail(new Error('Wait for animation timed out.')), timeout);
|
|
124
|
-
toTearDown.push({ dispose: () => (fail(new Error('Wait for animation timed out.')), clearTimeout(toClear)) });
|
|
125
|
+
const toClear = setTimeout(() => fail(new Error(message ?? 'Wait for animation timed out.')), timeout);
|
|
126
|
+
toTearDown.push({ dispose: () => (fail(new Error(message ?? 'Wait for animation timed out.')), clearTimeout(toClear)) });
|
|
125
127
|
});
|
|
126
128
|
return Promise.race([success, timedOut]);
|
|
127
129
|
}
|
|
@@ -277,6 +279,7 @@ describe('TypeScript', function () {
|
|
|
277
279
|
const from = 'an editor' + (preview ? ' preview' : '');
|
|
278
280
|
it('within ' + from, async function () {
|
|
279
281
|
const editor = await openEditor(demoFileUri, preview);
|
|
282
|
+
editor.getControl().revealLine(24);
|
|
280
283
|
// const demoInstance = new Demo|Class('demo');
|
|
281
284
|
editor.getControl().setPosition({ lineNumber: 24, column: 30 });
|
|
282
285
|
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DemoClass');
|
|
@@ -299,6 +302,7 @@ describe('TypeScript', function () {
|
|
|
299
302
|
await editorManager.open(definitionFileUri, { mode: 'open' });
|
|
300
303
|
|
|
301
304
|
const editor = await openEditor(demoFileUri, preview);
|
|
305
|
+
editor.getControl().revealLine(32);
|
|
302
306
|
// const bar: Defined|Interface = { coolField: [] };
|
|
303
307
|
editor.getControl().setPosition({ lineNumber: 32, column: 19 });
|
|
304
308
|
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DefinedInterface');
|
|
@@ -319,6 +323,7 @@ describe('TypeScript', function () {
|
|
|
319
323
|
|
|
320
324
|
it(`from ${from} to an editor preview`, async function () {
|
|
321
325
|
const editor = await openEditor(demoFileUri);
|
|
326
|
+
editor.getControl().revealLine(32);
|
|
322
327
|
// const bar: Defined|Interface = { coolField: [] };
|
|
323
328
|
editor.getControl().setPosition({ lineNumber: 32, column: 19 });
|
|
324
329
|
assert.equal(editor.getControl().getModel().getWordAtPosition(editor.getControl().getPosition()).word, 'DefinedInterface');
|
|
@@ -576,17 +581,17 @@ DIV {
|
|
|
576
581
|
assert.equal(activeEditor.getControl().getModel().getWordAtPosition({ lineNumber, column }).word, 'DemoClass');
|
|
577
582
|
});
|
|
578
583
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
+
it('run reference code lens', async function () {
|
|
585
|
+
const preferenceName = 'typescript.referencesCodeLens.enabled';
|
|
586
|
+
const globalValue = preferences.inspect(preferenceName).globalValue;
|
|
587
|
+
toTearDown.push({ dispose: () => preferences.set(preferenceName, globalValue, PreferenceScope.User) });
|
|
588
|
+
await preferences.set(preferenceName, false, PreferenceScope.User);
|
|
584
589
|
|
|
585
590
|
const editor = await openEditor(demoFileUri);
|
|
586
591
|
|
|
587
|
-
/** @type
|
|
592
|
+
/** @type {import('@theia/monaco-editor-core/src/vs/editor/contrib/codelens/browser/codelensController').CodeLensContribution} */
|
|
588
593
|
const codeLens = editor.getControl().getContribution('css.editor.codeLens');
|
|
589
|
-
const codeLensNode = () => codeLens
|
|
594
|
+
const codeLensNode = () => codeLens['_lenses'][0]?.['_contentWidget']?.['_domNode'];
|
|
590
595
|
const codeLensNodeVisible = () => {
|
|
591
596
|
const n = codeLensNode();
|
|
592
597
|
return !!n && n.style.visibility !== 'hidden';
|
|
@@ -594,46 +599,28 @@ DIV {
|
|
|
594
599
|
|
|
595
600
|
assert.isFalse(codeLensNodeVisible());
|
|
596
601
|
|
|
597
|
-
//
|
|
598
|
-
const position = { lineNumber:
|
|
599
|
-
|
|
600
|
-
range: Range.fromPositions(position, position),
|
|
601
|
-
forceMoveMarkers: false,
|
|
602
|
-
text: 'export '
|
|
603
|
-
}]);
|
|
604
|
-
await preferences.set('javascript.referencesCodeLens.enabled', true, PreferenceScope.User);
|
|
605
|
-
|
|
606
|
-
// Recall `applyEdits` to workaround `vscode` bug, See: https://github.com/eclipse-theia/theia/issues/9714#issuecomment-876582947.
|
|
607
|
-
editor.getControl().getModel().applyEdits([{
|
|
608
|
-
range: Range.fromPositions(position, position),
|
|
609
|
-
forceMoveMarkers: false,
|
|
610
|
-
text: ' '
|
|
611
|
-
}]);
|
|
602
|
+
// |interface DemoInterface {
|
|
603
|
+
const position = { lineNumber: 2, column: 1 };
|
|
604
|
+
await preferences.set(preferenceName, true, PreferenceScope.User);
|
|
612
605
|
|
|
613
606
|
editor.getControl().revealPosition(position);
|
|
614
607
|
await waitForAnimation(() => codeLensNodeVisible());
|
|
615
608
|
|
|
616
609
|
assert.isTrue(codeLensNodeVisible());
|
|
617
610
|
const node = codeLensNode();
|
|
618
|
-
|
|
619
|
-
|
|
611
|
+
assert.isDefined(node);
|
|
612
|
+
assert.equal(nodeAsString(node), `
|
|
620
613
|
SPAN {
|
|
621
614
|
A {
|
|
622
|
-
"
|
|
615
|
+
"1 reference"
|
|
623
616
|
}
|
|
624
617
|
}
|
|
625
618
|
`);
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
} else {
|
|
632
|
-
assert.isDefined(link);
|
|
633
|
-
}
|
|
634
|
-
} else {
|
|
635
|
-
assert.isDefined(node);
|
|
636
|
-
}
|
|
619
|
+
const link = node.getElementsByTagName('a').item(0);
|
|
620
|
+
assert.isDefined(link);
|
|
621
|
+
link.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
|
|
622
|
+
await assertPeekOpened(editor);
|
|
623
|
+
await closePeek(editor);
|
|
637
624
|
});
|
|
638
625
|
|
|
639
626
|
it('editor.action.quickFix', async function () {
|
|
@@ -747,5 +734,4 @@ SPAN {
|
|
|
747
734
|
assert.equal(getResultText(), expectedMessage);
|
|
748
735
|
});
|
|
749
736
|
}
|
|
750
|
-
|
|
751
737
|
});
|
|
@@ -32,6 +32,7 @@ describe('Undo, Redo and Select All', function () {
|
|
|
32
32
|
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
|
|
33
33
|
const { ScmContribution } = require('@theia/scm/lib/browser/scm-contribution');
|
|
34
34
|
const { Range } = require('@theia/monaco-editor-core/esm/vs/editor/common/core/range');
|
|
35
|
+
const { PreferenceService, PreferenceScope } = require('@theia/core/lib/browser');
|
|
35
36
|
|
|
36
37
|
const container = window.theia.container;
|
|
37
38
|
const editorManager = container.get(EditorManager);
|
|
@@ -41,6 +42,8 @@ describe('Undo, Redo and Select All', function () {
|
|
|
41
42
|
const navigatorContribution = container.get(FileNavigatorContribution);
|
|
42
43
|
const shell = container.get(ApplicationShell);
|
|
43
44
|
const scmContribution = container.get(ScmContribution);
|
|
45
|
+
/** @type {PreferenceService} */
|
|
46
|
+
const preferenceService = container.get(PreferenceService)
|
|
44
47
|
|
|
45
48
|
const rootUri = workspaceService.tryGetRoots()[0].resource;
|
|
46
49
|
const fileUri = rootUri.resolve('webpack.config.js');
|
|
@@ -61,8 +64,10 @@ describe('Undo, Redo and Select All', function () {
|
|
|
61
64
|
resolve(undefined);
|
|
62
65
|
});
|
|
63
66
|
}
|
|
64
|
-
|
|
65
|
-
before(() => {
|
|
67
|
+
let originalValue = undefined;
|
|
68
|
+
before(async () => {
|
|
69
|
+
originalValue = preferenceService.inspect('files.autoSave').globalValue;
|
|
70
|
+
await preferenceService.set('files.autoSave', 'off', PreferenceScope.User);
|
|
66
71
|
shell.leftPanelHandler.collapse();
|
|
67
72
|
});
|
|
68
73
|
|
|
@@ -79,7 +84,8 @@ describe('Undo, Redo and Select All', function () {
|
|
|
79
84
|
await editorManager.closeAll({ save: false });
|
|
80
85
|
});
|
|
81
86
|
|
|
82
|
-
after(() => {
|
|
87
|
+
after(async () => {
|
|
88
|
+
await preferenceService.set('files.autoSave', originalValue, PreferenceScope.User);
|
|
83
89
|
shell.leftPanelHandler.collapse();
|
|
84
90
|
});
|
|
85
91
|
|