@theia/api-tests 1.34.2 → 1.34.3
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/LICENSE +641 -641
- package/package.json +3 -3
- package/src/api-tests.d.ts +21 -21
- package/src/browser-utils.spec.js +53 -53
- package/src/contribution-filter.spec.js +36 -36
- package/src/file-search.spec.js +132 -132
- package/src/find-replace.spec.js +129 -129
- package/src/keybindings.spec.js +117 -117
- package/src/launch-preferences.spec.js +697 -697
- package/src/menus.spec.js +176 -176
- package/src/monaco-api.spec.js +188 -188
- package/src/navigator.spec.js +92 -92
- package/src/preferences.spec.js +207 -207
- package/src/saveable.spec.js +503 -503
- package/src/scm.spec.js +173 -173
- package/src/shell.spec.js +41 -41
- package/src/task-configurations.spec.js +112 -112
- package/src/typescript.spec.js +779 -779
- package/src/undo-redo-selectAll.spec.js +193 -193
- package/src/views.spec.js +76 -76
package/src/monaco-api.spec.js
CHANGED
|
@@ -1,188 +1,188 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
// @ts-check
|
|
18
|
-
describe('Monaco API', async function () {
|
|
19
|
-
this.timeout(5000);
|
|
20
|
-
|
|
21
|
-
const { assert } = chai;
|
|
22
|
-
|
|
23
|
-
const { EditorManager } = require('@theia/editor/lib/browser/editor-manager');
|
|
24
|
-
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');
|
|
25
|
-
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
|
|
26
|
-
const { MonacoResolvedKeybinding } = require('@theia/monaco/lib/browser/monaco-resolved-keybinding');
|
|
27
|
-
const { MonacoTextmateService } = require('@theia/monaco/lib/browser/textmate/monaco-textmate-service');
|
|
28
|
-
const { CommandRegistry } = require('@theia/core/lib/common/command');
|
|
29
|
-
const { SimpleKeybinding } = require('@theia/monaco-editor-core/esm/vs/base/common/keybindings');
|
|
30
|
-
const { IKeybindingService } = require('@theia/monaco-editor-core/esm/vs/platform/keybinding/common/keybinding');
|
|
31
|
-
const { StandaloneServices } = require('@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices');
|
|
32
|
-
const { TokenizationRegistry } = require('@theia/monaco-editor-core/esm/vs/editor/common/languages');
|
|
33
|
-
const { MonacoContextKeyService } = require('@theia/monaco/lib/browser/monaco-context-key-service');
|
|
34
|
-
const { URI } = require('@theia/monaco-editor-core/esm/vs/base/common/uri');
|
|
35
|
-
|
|
36
|
-
const container = window.theia.container;
|
|
37
|
-
const editorManager = container.get(EditorManager);
|
|
38
|
-
const workspaceService = container.get(WorkspaceService);
|
|
39
|
-
const textmateService = container.get(MonacoTextmateService);
|
|
40
|
-
/** @type {import('@theia/core/src/common/command').CommandRegistry} */
|
|
41
|
-
const commands = container.get(CommandRegistry);
|
|
42
|
-
/** @type {import('@theia/monaco/src/browser/monaco-context-key-service').MonacoContextKeyService} */
|
|
43
|
-
const contextKeys = container.get(MonacoContextKeyService);
|
|
44
|
-
|
|
45
|
-
/** @type {MonacoEditor} */
|
|
46
|
-
let monacoEditor;
|
|
47
|
-
|
|
48
|
-
before(async () => {
|
|
49
|
-
const root = workspaceService.tryGetRoots()[0];
|
|
50
|
-
const editor = await editorManager.open(root.resource.resolve('package.json'), {
|
|
51
|
-
mode: 'reveal'
|
|
52
|
-
});
|
|
53
|
-
monacoEditor = /** @type {MonacoEditor} */ (MonacoEditor.get(editor));
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
after(async () => {
|
|
57
|
-
await editorManager.closeAll({ save: false });
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('KeybindingService.resolveKeybinding', () => {
|
|
61
|
-
const simpleKeybinding = new SimpleKeybinding(true, true, true, true, 41 /* KeyCode.KeyK */);
|
|
62
|
-
const chordKeybinding = simpleKeybinding.toChord();
|
|
63
|
-
assert.equal(chordKeybinding.parts.length, 1);
|
|
64
|
-
assert.equal(chordKeybinding.parts[0], simpleKeybinding);
|
|
65
|
-
|
|
66
|
-
const resolvedKeybindings = StandaloneServices.get(IKeybindingService).resolveKeybinding(chordKeybinding);
|
|
67
|
-
assert.equal(resolvedKeybindings.length, 1);
|
|
68
|
-
|
|
69
|
-
const resolvedKeybinding = resolvedKeybindings[0];
|
|
70
|
-
if (resolvedKeybinding instanceof MonacoResolvedKeybinding) {
|
|
71
|
-
const label = resolvedKeybinding.getLabel();
|
|
72
|
-
const ariaLabel = resolvedKeybinding.getAriaLabel();
|
|
73
|
-
const electronAccelerator = resolvedKeybinding.getElectronAccelerator();
|
|
74
|
-
const userSettingsLabel = resolvedKeybinding.getUserSettingsLabel();
|
|
75
|
-
const WYSIWYG = resolvedKeybinding.isWYSIWYG();
|
|
76
|
-
const chord = resolvedKeybinding.isChord();
|
|
77
|
-
const parts = resolvedKeybinding.getParts();
|
|
78
|
-
const dispatchParts = resolvedKeybinding.getDispatchParts();
|
|
79
|
-
|
|
80
|
-
const platform = window.navigator.platform;
|
|
81
|
-
let expected;
|
|
82
|
-
if (platform.includes('Mac')) {
|
|
83
|
-
// Mac os
|
|
84
|
-
expected = {
|
|
85
|
-
label: '⌃⇧⌥⌘K',
|
|
86
|
-
ariaLabel: '⌃⇧⌥⌘K',
|
|
87
|
-
electronAccelerator: 'Ctrl+Shift+Alt+Cmd+K',
|
|
88
|
-
userSettingsLabel: 'ctrl+shift+alt+cmd+K',
|
|
89
|
-
WYSIWYG: true,
|
|
90
|
-
chord: false,
|
|
91
|
-
parts: [{
|
|
92
|
-
altKey: true,
|
|
93
|
-
ctrlKey: true,
|
|
94
|
-
keyAriaLabel: 'K',
|
|
95
|
-
keyLabel: 'K',
|
|
96
|
-
metaKey: true,
|
|
97
|
-
shiftKey: true
|
|
98
|
-
}],
|
|
99
|
-
dispatchParts: [
|
|
100
|
-
'ctrl+shift+alt+meta+K'
|
|
101
|
-
]
|
|
102
|
-
};
|
|
103
|
-
} else {
|
|
104
|
-
expected = {
|
|
105
|
-
label: 'Ctrl+Shift+Alt+K',
|
|
106
|
-
ariaLabel: 'Ctrl+Shift+Alt+K',
|
|
107
|
-
electronAccelerator: 'Ctrl+Shift+Alt+K',
|
|
108
|
-
userSettingsLabel: 'ctrl+shift+alt+K',
|
|
109
|
-
WYSIWYG: true,
|
|
110
|
-
chord: false,
|
|
111
|
-
parts: [{
|
|
112
|
-
altKey: true,
|
|
113
|
-
ctrlKey: true,
|
|
114
|
-
keyAriaLabel: 'K',
|
|
115
|
-
keyLabel: 'K',
|
|
116
|
-
metaKey: false,
|
|
117
|
-
shiftKey: true
|
|
118
|
-
}],
|
|
119
|
-
dispatchParts: [
|
|
120
|
-
'ctrl+shift+alt+K'
|
|
121
|
-
]
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
assert.deepStrictEqual({
|
|
126
|
-
label, ariaLabel, electronAccelerator, userSettingsLabel, WYSIWYG, chord, parts, dispatchParts
|
|
127
|
-
}, expected);
|
|
128
|
-
} else {
|
|
129
|
-
assert.fail(`resolvedKeybinding must be of ${MonacoResolvedKeybinding.name} type`);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('TokenizationRegistry.getColorMap', async () => {
|
|
134
|
-
if (textmateService['monacoThemeRegistry'].getThemeData().base !== 'vs') {
|
|
135
|
-
const didChangeColorMap = new Promise(resolve => {
|
|
136
|
-
const toDispose = TokenizationRegistry.onDidChange(() => {
|
|
137
|
-
toDispose.dispose();
|
|
138
|
-
resolve();
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
textmateService['themeService'].setCurrentTheme('light');
|
|
142
|
-
await didChangeColorMap;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const textMateColorMap = textmateService['grammarRegistry'].getColorMap();
|
|
146
|
-
assert.notEqual(textMateColorMap.indexOf('#795E26'), -1, 'Expected custom toke colors for the light theme to be enabled.');
|
|
147
|
-
|
|
148
|
-
const monacoColorMap = (TokenizationRegistry.getColorMap() || []).
|
|
149
|
-
splice(0, textMateColorMap.length).map(c => c.toString().toUpperCase());
|
|
150
|
-
assert.deepStrictEqual(monacoColorMap, textMateColorMap, 'Expected textmate colors to have the same index in the monaco color map.');
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('OpenerService.open', async () => {
|
|
154
|
-
const hoverContribution = monacoEditor.getControl().getContribution('editor.contrib.hover');
|
|
155
|
-
assert.isDefined(hoverContribution);
|
|
156
|
-
if (!('_openerService' in hoverContribution)) {
|
|
157
|
-
assert.fail('hoverContribution does not have OpenerService');
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
/** @type {import('@theia/monaco-editor-core/esm/vs/editor/browser/services/openerService').OpenerService} */
|
|
161
|
-
const openerService = hoverContribution['_openerService'];
|
|
162
|
-
|
|
163
|
-
let opened = false;
|
|
164
|
-
const id = '__test:OpenerService.open';
|
|
165
|
-
const unregisterCommand = commands.registerCommand({ id }, {
|
|
166
|
-
execute: arg => (console.log(arg), opened = arg === 'foo')
|
|
167
|
-
});
|
|
168
|
-
try {
|
|
169
|
-
await openerService.open(URI.parse('command:' + id + '?"foo"'));
|
|
170
|
-
assert.isTrue(opened);
|
|
171
|
-
} finally {
|
|
172
|
-
unregisterCommand.dispose();
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('Supports setting contexts using the command registry', async () => {
|
|
177
|
-
const setContext = 'setContext';
|
|
178
|
-
const key = 'monaco-api-test-context';
|
|
179
|
-
const firstValue = 'first setting';
|
|
180
|
-
const secondValue = 'second setting';
|
|
181
|
-
assert.isFalse(contextKeys.match(`${key} == ${firstValue}`));
|
|
182
|
-
await commands.executeCommand(setContext, key, firstValue);
|
|
183
|
-
assert.isTrue(contextKeys.match(`${key} == ${firstValue}`));
|
|
184
|
-
await commands.executeCommand(setContext, key, secondValue);
|
|
185
|
-
assert.isTrue(contextKeys.match(`${key} == ${secondValue}`));
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
// @ts-check
|
|
18
|
+
describe('Monaco API', async function () {
|
|
19
|
+
this.timeout(5000);
|
|
20
|
+
|
|
21
|
+
const { assert } = chai;
|
|
22
|
+
|
|
23
|
+
const { EditorManager } = require('@theia/editor/lib/browser/editor-manager');
|
|
24
|
+
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');
|
|
25
|
+
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
|
|
26
|
+
const { MonacoResolvedKeybinding } = require('@theia/monaco/lib/browser/monaco-resolved-keybinding');
|
|
27
|
+
const { MonacoTextmateService } = require('@theia/monaco/lib/browser/textmate/monaco-textmate-service');
|
|
28
|
+
const { CommandRegistry } = require('@theia/core/lib/common/command');
|
|
29
|
+
const { SimpleKeybinding } = require('@theia/monaco-editor-core/esm/vs/base/common/keybindings');
|
|
30
|
+
const { IKeybindingService } = require('@theia/monaco-editor-core/esm/vs/platform/keybinding/common/keybinding');
|
|
31
|
+
const { StandaloneServices } = require('@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices');
|
|
32
|
+
const { TokenizationRegistry } = require('@theia/monaco-editor-core/esm/vs/editor/common/languages');
|
|
33
|
+
const { MonacoContextKeyService } = require('@theia/monaco/lib/browser/monaco-context-key-service');
|
|
34
|
+
const { URI } = require('@theia/monaco-editor-core/esm/vs/base/common/uri');
|
|
35
|
+
|
|
36
|
+
const container = window.theia.container;
|
|
37
|
+
const editorManager = container.get(EditorManager);
|
|
38
|
+
const workspaceService = container.get(WorkspaceService);
|
|
39
|
+
const textmateService = container.get(MonacoTextmateService);
|
|
40
|
+
/** @type {import('@theia/core/src/common/command').CommandRegistry} */
|
|
41
|
+
const commands = container.get(CommandRegistry);
|
|
42
|
+
/** @type {import('@theia/monaco/src/browser/monaco-context-key-service').MonacoContextKeyService} */
|
|
43
|
+
const contextKeys = container.get(MonacoContextKeyService);
|
|
44
|
+
|
|
45
|
+
/** @type {MonacoEditor} */
|
|
46
|
+
let monacoEditor;
|
|
47
|
+
|
|
48
|
+
before(async () => {
|
|
49
|
+
const root = workspaceService.tryGetRoots()[0];
|
|
50
|
+
const editor = await editorManager.open(root.resource.resolve('package.json'), {
|
|
51
|
+
mode: 'reveal'
|
|
52
|
+
});
|
|
53
|
+
monacoEditor = /** @type {MonacoEditor} */ (MonacoEditor.get(editor));
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
after(async () => {
|
|
57
|
+
await editorManager.closeAll({ save: false });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('KeybindingService.resolveKeybinding', () => {
|
|
61
|
+
const simpleKeybinding = new SimpleKeybinding(true, true, true, true, 41 /* KeyCode.KeyK */);
|
|
62
|
+
const chordKeybinding = simpleKeybinding.toChord();
|
|
63
|
+
assert.equal(chordKeybinding.parts.length, 1);
|
|
64
|
+
assert.equal(chordKeybinding.parts[0], simpleKeybinding);
|
|
65
|
+
|
|
66
|
+
const resolvedKeybindings = StandaloneServices.get(IKeybindingService).resolveKeybinding(chordKeybinding);
|
|
67
|
+
assert.equal(resolvedKeybindings.length, 1);
|
|
68
|
+
|
|
69
|
+
const resolvedKeybinding = resolvedKeybindings[0];
|
|
70
|
+
if (resolvedKeybinding instanceof MonacoResolvedKeybinding) {
|
|
71
|
+
const label = resolvedKeybinding.getLabel();
|
|
72
|
+
const ariaLabel = resolvedKeybinding.getAriaLabel();
|
|
73
|
+
const electronAccelerator = resolvedKeybinding.getElectronAccelerator();
|
|
74
|
+
const userSettingsLabel = resolvedKeybinding.getUserSettingsLabel();
|
|
75
|
+
const WYSIWYG = resolvedKeybinding.isWYSIWYG();
|
|
76
|
+
const chord = resolvedKeybinding.isChord();
|
|
77
|
+
const parts = resolvedKeybinding.getParts();
|
|
78
|
+
const dispatchParts = resolvedKeybinding.getDispatchParts();
|
|
79
|
+
|
|
80
|
+
const platform = window.navigator.platform;
|
|
81
|
+
let expected;
|
|
82
|
+
if (platform.includes('Mac')) {
|
|
83
|
+
// Mac os
|
|
84
|
+
expected = {
|
|
85
|
+
label: '⌃⇧⌥⌘K',
|
|
86
|
+
ariaLabel: '⌃⇧⌥⌘K',
|
|
87
|
+
electronAccelerator: 'Ctrl+Shift+Alt+Cmd+K',
|
|
88
|
+
userSettingsLabel: 'ctrl+shift+alt+cmd+K',
|
|
89
|
+
WYSIWYG: true,
|
|
90
|
+
chord: false,
|
|
91
|
+
parts: [{
|
|
92
|
+
altKey: true,
|
|
93
|
+
ctrlKey: true,
|
|
94
|
+
keyAriaLabel: 'K',
|
|
95
|
+
keyLabel: 'K',
|
|
96
|
+
metaKey: true,
|
|
97
|
+
shiftKey: true
|
|
98
|
+
}],
|
|
99
|
+
dispatchParts: [
|
|
100
|
+
'ctrl+shift+alt+meta+K'
|
|
101
|
+
]
|
|
102
|
+
};
|
|
103
|
+
} else {
|
|
104
|
+
expected = {
|
|
105
|
+
label: 'Ctrl+Shift+Alt+K',
|
|
106
|
+
ariaLabel: 'Ctrl+Shift+Alt+K',
|
|
107
|
+
electronAccelerator: 'Ctrl+Shift+Alt+K',
|
|
108
|
+
userSettingsLabel: 'ctrl+shift+alt+K',
|
|
109
|
+
WYSIWYG: true,
|
|
110
|
+
chord: false,
|
|
111
|
+
parts: [{
|
|
112
|
+
altKey: true,
|
|
113
|
+
ctrlKey: true,
|
|
114
|
+
keyAriaLabel: 'K',
|
|
115
|
+
keyLabel: 'K',
|
|
116
|
+
metaKey: false,
|
|
117
|
+
shiftKey: true
|
|
118
|
+
}],
|
|
119
|
+
dispatchParts: [
|
|
120
|
+
'ctrl+shift+alt+K'
|
|
121
|
+
]
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
assert.deepStrictEqual({
|
|
126
|
+
label, ariaLabel, electronAccelerator, userSettingsLabel, WYSIWYG, chord, parts, dispatchParts
|
|
127
|
+
}, expected);
|
|
128
|
+
} else {
|
|
129
|
+
assert.fail(`resolvedKeybinding must be of ${MonacoResolvedKeybinding.name} type`);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('TokenizationRegistry.getColorMap', async () => {
|
|
134
|
+
if (textmateService['monacoThemeRegistry'].getThemeData().base !== 'vs') {
|
|
135
|
+
const didChangeColorMap = new Promise(resolve => {
|
|
136
|
+
const toDispose = TokenizationRegistry.onDidChange(() => {
|
|
137
|
+
toDispose.dispose();
|
|
138
|
+
resolve();
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
textmateService['themeService'].setCurrentTheme('light');
|
|
142
|
+
await didChangeColorMap;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const textMateColorMap = textmateService['grammarRegistry'].getColorMap();
|
|
146
|
+
assert.notEqual(textMateColorMap.indexOf('#795E26'), -1, 'Expected custom toke colors for the light theme to be enabled.');
|
|
147
|
+
|
|
148
|
+
const monacoColorMap = (TokenizationRegistry.getColorMap() || []).
|
|
149
|
+
splice(0, textMateColorMap.length).map(c => c.toString().toUpperCase());
|
|
150
|
+
assert.deepStrictEqual(monacoColorMap, textMateColorMap, 'Expected textmate colors to have the same index in the monaco color map.');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('OpenerService.open', async () => {
|
|
154
|
+
const hoverContribution = monacoEditor.getControl().getContribution('editor.contrib.hover');
|
|
155
|
+
assert.isDefined(hoverContribution);
|
|
156
|
+
if (!('_openerService' in hoverContribution)) {
|
|
157
|
+
assert.fail('hoverContribution does not have OpenerService');
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
/** @type {import('@theia/monaco-editor-core/esm/vs/editor/browser/services/openerService').OpenerService} */
|
|
161
|
+
const openerService = hoverContribution['_openerService'];
|
|
162
|
+
|
|
163
|
+
let opened = false;
|
|
164
|
+
const id = '__test:OpenerService.open';
|
|
165
|
+
const unregisterCommand = commands.registerCommand({ id }, {
|
|
166
|
+
execute: arg => (console.log(arg), opened = arg === 'foo')
|
|
167
|
+
});
|
|
168
|
+
try {
|
|
169
|
+
await openerService.open(URI.parse('command:' + id + '?"foo"'));
|
|
170
|
+
assert.isTrue(opened);
|
|
171
|
+
} finally {
|
|
172
|
+
unregisterCommand.dispose();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('Supports setting contexts using the command registry', async () => {
|
|
177
|
+
const setContext = 'setContext';
|
|
178
|
+
const key = 'monaco-api-test-context';
|
|
179
|
+
const firstValue = 'first setting';
|
|
180
|
+
const secondValue = 'second setting';
|
|
181
|
+
assert.isFalse(contextKeys.match(`${key} == ${firstValue}`));
|
|
182
|
+
await commands.executeCommand(setContext, key, firstValue);
|
|
183
|
+
assert.isTrue(contextKeys.match(`${key} == ${firstValue}`));
|
|
184
|
+
await commands.executeCommand(setContext, key, secondValue);
|
|
185
|
+
assert.isTrue(contextKeys.match(`${key} == ${secondValue}`));
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
});
|
package/src/navigator.spec.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
// @ts-check
|
|
18
|
-
describe('Navigator', function () {
|
|
19
|
-
this.timeout(5000);
|
|
20
|
-
|
|
21
|
-
const { assert } = chai;
|
|
22
|
-
|
|
23
|
-
const { FileService } = require('@theia/filesystem/lib/browser/file-service');
|
|
24
|
-
const { DirNode, FileNode } = require('@theia/filesystem/lib/browser/file-tree/file-tree');
|
|
25
|
-
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');
|
|
26
|
-
const { FileNavigatorContribution } = require('@theia/navigator/lib/browser/navigator-contribution');
|
|
27
|
-
|
|
28
|
-
/** @type {import('inversify').Container} */
|
|
29
|
-
const container = window['theia'].container;
|
|
30
|
-
const fileService = container.get(FileService);
|
|
31
|
-
const workspaceService = container.get(WorkspaceService);
|
|
32
|
-
const navigatorContribution = container.get(FileNavigatorContribution);
|
|
33
|
-
|
|
34
|
-
const rootUri = workspaceService.tryGetRoots()[0].resource;
|
|
35
|
-
const fileUri = rootUri.resolve('.test/nested/source/text.txt');
|
|
36
|
-
const targetUri = rootUri.resolve('.test/target');
|
|
37
|
-
|
|
38
|
-
beforeEach(async () => {
|
|
39
|
-
await fileService.create(fileUri, 'foo', { fromUserGesture: false, overwrite: true });
|
|
40
|
-
await fileService.createFolder(targetUri);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
afterEach(async () => {
|
|
44
|
-
await fileService.delete(targetUri.parent, { fromUserGesture: false, useTrash: false, recursive: true });
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
/** @type {Array<['copy' | 'move', boolean]>} */
|
|
48
|
-
const operations = [
|
|
49
|
-
['copy', false],
|
|
50
|
-
['move', false]
|
|
51
|
-
];
|
|
52
|
-
/** @type {Array<['file' | 'dir', boolean]>} */
|
|
53
|
-
const fileTypes = [
|
|
54
|
-
['file', false],
|
|
55
|
-
['dir', false],
|
|
56
|
-
];
|
|
57
|
-
for (const [operation, onlyOperation] of operations) {
|
|
58
|
-
for (const [fileType, onlyFileType] of fileTypes) {
|
|
59
|
-
const ExpectedNodeType = fileType === 'file' ? FileNode : DirNode;
|
|
60
|
-
(onlyOperation || onlyFileType ? it.only : it)(operation + ' ' + fileType, async function () {
|
|
61
|
-
const navigator = await navigatorContribution.openView({ reveal: true });
|
|
62
|
-
await navigator.model.refresh();
|
|
63
|
-
|
|
64
|
-
const sourceUri = fileType === 'file' ? fileUri : fileUri.parent;
|
|
65
|
-
const sourceNode = await navigator.model.revealFile(sourceUri);
|
|
66
|
-
if (!ExpectedNodeType.is(sourceNode)) {
|
|
67
|
-
return assert.isTrue(ExpectedNodeType.is(sourceNode));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const targetNode = await navigator.model.revealFile(targetUri);
|
|
71
|
-
if (!DirNode.is(targetNode)) {
|
|
72
|
-
return assert.isTrue(DirNode.is(targetNode));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let actualUri;
|
|
76
|
-
if (operation === 'copy') {
|
|
77
|
-
actualUri = await navigator.model.copy(sourceUri, targetNode);
|
|
78
|
-
} else {
|
|
79
|
-
actualUri = await navigator.model.move(sourceNode, targetNode);
|
|
80
|
-
}
|
|
81
|
-
if (!actualUri) {
|
|
82
|
-
return assert.isDefined(actualUri);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
await navigator.model.refresh(targetNode);
|
|
86
|
-
const actualNode = await navigator.model.revealFile(actualUri);
|
|
87
|
-
assert.isTrue(ExpectedNodeType.is(actualNode));
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
});
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2020 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
// @ts-check
|
|
18
|
+
describe('Navigator', function () {
|
|
19
|
+
this.timeout(5000);
|
|
20
|
+
|
|
21
|
+
const { assert } = chai;
|
|
22
|
+
|
|
23
|
+
const { FileService } = require('@theia/filesystem/lib/browser/file-service');
|
|
24
|
+
const { DirNode, FileNode } = require('@theia/filesystem/lib/browser/file-tree/file-tree');
|
|
25
|
+
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');
|
|
26
|
+
const { FileNavigatorContribution } = require('@theia/navigator/lib/browser/navigator-contribution');
|
|
27
|
+
|
|
28
|
+
/** @type {import('inversify').Container} */
|
|
29
|
+
const container = window['theia'].container;
|
|
30
|
+
const fileService = container.get(FileService);
|
|
31
|
+
const workspaceService = container.get(WorkspaceService);
|
|
32
|
+
const navigatorContribution = container.get(FileNavigatorContribution);
|
|
33
|
+
|
|
34
|
+
const rootUri = workspaceService.tryGetRoots()[0].resource;
|
|
35
|
+
const fileUri = rootUri.resolve('.test/nested/source/text.txt');
|
|
36
|
+
const targetUri = rootUri.resolve('.test/target');
|
|
37
|
+
|
|
38
|
+
beforeEach(async () => {
|
|
39
|
+
await fileService.create(fileUri, 'foo', { fromUserGesture: false, overwrite: true });
|
|
40
|
+
await fileService.createFolder(targetUri);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
afterEach(async () => {
|
|
44
|
+
await fileService.delete(targetUri.parent, { fromUserGesture: false, useTrash: false, recursive: true });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/** @type {Array<['copy' | 'move', boolean]>} */
|
|
48
|
+
const operations = [
|
|
49
|
+
['copy', false],
|
|
50
|
+
['move', false]
|
|
51
|
+
];
|
|
52
|
+
/** @type {Array<['file' | 'dir', boolean]>} */
|
|
53
|
+
const fileTypes = [
|
|
54
|
+
['file', false],
|
|
55
|
+
['dir', false],
|
|
56
|
+
];
|
|
57
|
+
for (const [operation, onlyOperation] of operations) {
|
|
58
|
+
for (const [fileType, onlyFileType] of fileTypes) {
|
|
59
|
+
const ExpectedNodeType = fileType === 'file' ? FileNode : DirNode;
|
|
60
|
+
(onlyOperation || onlyFileType ? it.only : it)(operation + ' ' + fileType, async function () {
|
|
61
|
+
const navigator = await navigatorContribution.openView({ reveal: true });
|
|
62
|
+
await navigator.model.refresh();
|
|
63
|
+
|
|
64
|
+
const sourceUri = fileType === 'file' ? fileUri : fileUri.parent;
|
|
65
|
+
const sourceNode = await navigator.model.revealFile(sourceUri);
|
|
66
|
+
if (!ExpectedNodeType.is(sourceNode)) {
|
|
67
|
+
return assert.isTrue(ExpectedNodeType.is(sourceNode));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const targetNode = await navigator.model.revealFile(targetUri);
|
|
71
|
+
if (!DirNode.is(targetNode)) {
|
|
72
|
+
return assert.isTrue(DirNode.is(targetNode));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let actualUri;
|
|
76
|
+
if (operation === 'copy') {
|
|
77
|
+
actualUri = await navigator.model.copy(sourceUri, targetNode);
|
|
78
|
+
} else {
|
|
79
|
+
actualUri = await navigator.model.move(sourceNode, targetNode);
|
|
80
|
+
}
|
|
81
|
+
if (!actualUri) {
|
|
82
|
+
return assert.isDefined(actualUri);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
await navigator.model.refresh(targetNode);
|
|
86
|
+
const actualNode = await navigator.model.revealFile(actualUri);
|
|
87
|
+
assert.isTrue(ExpectedNodeType.is(actualNode));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
});
|