@theia/api-tests 1.36.0-next.30 → 1.36.0-next.31
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/explorer-open-close.spec.js +155 -0
- package/src/find-replace.spec.js +57 -23
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/api-tests",
|
|
3
|
-
"version": "1.36.0-next.
|
|
3
|
+
"version": "1.36.0-next.31+fa1db709b",
|
|
4
4
|
"description": "Theia API tests",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.36.0-next.
|
|
6
|
+
"@theia/core": "1.36.0-next.31+fa1db709b"
|
|
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": "fa1db709b28fd0760c4756f3c1cea6d19d199cff"
|
|
24
24
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 Ericsson 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('Explorer and Editor - open and close', function () {
|
|
19
|
+
this.timeout(90_000);
|
|
20
|
+
const { assert } = chai;
|
|
21
|
+
|
|
22
|
+
const { DisposableCollection } = require('@theia/core/lib/common/disposable');
|
|
23
|
+
const { EditorManager } = require('@theia/editor/lib/browser/editor-manager');
|
|
24
|
+
const { WorkspaceService } = require('@theia/workspace/lib/browser/workspace-service');
|
|
25
|
+
const { FileNavigatorContribution } = require('@theia/navigator/lib/browser/navigator-contribution');
|
|
26
|
+
const { ApplicationShell } = require('@theia/core/lib/browser/shell/application-shell');
|
|
27
|
+
const { HostedPluginSupport } = require('@theia/plugin-ext/lib/hosted/browser/hosted-plugin');
|
|
28
|
+
const { ProgressStatusBarItem } = require('@theia/core/lib/browser/progress-status-bar-item');
|
|
29
|
+
const { EXPLORER_VIEW_CONTAINER_ID } = require('@theia/navigator/lib/browser/navigator-widget-factory');
|
|
30
|
+
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
|
|
31
|
+
const container = window.theia.container;
|
|
32
|
+
const editorManager = container.get(EditorManager);
|
|
33
|
+
const workspaceService = container.get(WorkspaceService);
|
|
34
|
+
const navigatorContribution = container.get(FileNavigatorContribution);
|
|
35
|
+
const shell = container.get(ApplicationShell);
|
|
36
|
+
const rootUri = workspaceService.tryGetRoots()[0].resource;
|
|
37
|
+
const pluginService = container.get(HostedPluginSupport);
|
|
38
|
+
const progressStatusBarItem = container.get(ProgressStatusBarItem);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const fileUri = rootUri.resolve('webpack.config.js');
|
|
42
|
+
const toTearDown = new DisposableCollection();
|
|
43
|
+
|
|
44
|
+
function pause(ms = 500) {
|
|
45
|
+
console.debug(`pause test for: ${ms} ms`);
|
|
46
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
before(async () => {
|
|
50
|
+
await pluginService.didStart;
|
|
51
|
+
await editorManager.closeAll({ save: false });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
afterEach(async () => {
|
|
55
|
+
await editorManager.closeAll({ save: false });
|
|
56
|
+
await navigatorContribution.closeView();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
after(async () => {
|
|
60
|
+
toTearDown.dispose();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
for (var i = 0; i < 5; i++) {
|
|
64
|
+
let ordering = 0;
|
|
65
|
+
it('Open/Close explorer and editor - ordering: ' + ordering++ + ', iteration #' + i, async function () {
|
|
66
|
+
await openExplorer();
|
|
67
|
+
await openEditor();
|
|
68
|
+
await closeEditor();
|
|
69
|
+
await closeExplorer();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('Open/Close explorer and editor - ordering: ' + ordering++ + ', iteration #' + i, async function () {
|
|
73
|
+
await openExplorer();
|
|
74
|
+
await openEditor();
|
|
75
|
+
await closeExplorer();
|
|
76
|
+
await closeEditor();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('Open/Close editor, explorer - ordering: ' + ordering++ + ', iteration - #' + i, async function () {
|
|
80
|
+
await openEditor();
|
|
81
|
+
await openExplorer();
|
|
82
|
+
await closeEditor();
|
|
83
|
+
await closeExplorer();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('Open/Close editor, explorer - ordering: ' + ordering++ + ', iteration - #' + i, async function () {
|
|
87
|
+
await openEditor();
|
|
88
|
+
await openExplorer();
|
|
89
|
+
await closeExplorer();
|
|
90
|
+
await closeEditor();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('Open/Close explorer #' + i, async function () {
|
|
94
|
+
await openExplorer();
|
|
95
|
+
await closeExplorer();
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
it('open/close explorer in quick succession', async function () {
|
|
100
|
+
for (let i = 0; i < 20; i++) {
|
|
101
|
+
await openExplorer();
|
|
102
|
+
await closeExplorer();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('open/close editor in quick succession', async function () {
|
|
107
|
+
await openExplorer();
|
|
108
|
+
for (let i = 0; i < 20; i++) {
|
|
109
|
+
await openEditor();
|
|
110
|
+
await closeEditor();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
async function openExplorer() {
|
|
115
|
+
await navigatorContribution.openView({ activate: true });
|
|
116
|
+
const widget = await shell.revealWidget(EXPLORER_VIEW_CONTAINER_ID);
|
|
117
|
+
assert.isDefined(widget, 'Explorer widget should exist');
|
|
118
|
+
}
|
|
119
|
+
async function closeExplorer() {
|
|
120
|
+
await navigatorContribution.closeView();
|
|
121
|
+
assert.isUndefined(await shell.revealWidget(EXPLORER_VIEW_CONTAINER_ID), 'Explorer widget should not exist');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function openEditor() {
|
|
125
|
+
await editorManager.open(fileUri, { mode: 'activate' });
|
|
126
|
+
await waitLanguageServerReady();
|
|
127
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
128
|
+
assert.isDefined(activeEditor);
|
|
129
|
+
assert.equal(activeEditor.uri.resolveToAbsolute().toString(), fileUri.resolveToAbsolute().toString());
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function closeEditor() {
|
|
133
|
+
await editorManager.closeAll({ save: false });
|
|
134
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
135
|
+
assert.isUndefined(activeEditor);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function waitLanguageServerReady() {
|
|
139
|
+
// quite a bit of jitter in the "Initializing LS" status bar entry,
|
|
140
|
+
// so we want to read a few times in a row that it's done (undefined)
|
|
141
|
+
const MAX_N = 5
|
|
142
|
+
let n = MAX_N;
|
|
143
|
+
while (n > 0) {
|
|
144
|
+
await pause(1);
|
|
145
|
+
if (progressStatusBarItem.currentProgress) {
|
|
146
|
+
n = MAX_N;
|
|
147
|
+
} else {
|
|
148
|
+
n--;
|
|
149
|
+
}
|
|
150
|
+
if (n < MAX_N) {
|
|
151
|
+
console.debug('n = ' + n);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
package/src/find-replace.spec.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
// @ts-check
|
|
18
18
|
describe('Find and Replace', function () {
|
|
19
|
-
this.timeout(
|
|
19
|
+
this.timeout(20_000);
|
|
20
20
|
const { assert } = chai;
|
|
21
21
|
|
|
22
22
|
const { animationFrame } = require('@theia/core/lib/browser/browser');
|
|
@@ -29,6 +29,10 @@ describe('Find and Replace', function () {
|
|
|
29
29
|
const { ContextKeyService } = require('@theia/core/lib/browser/context-key-service');
|
|
30
30
|
const { FileNavigatorContribution } = require('@theia/navigator/lib/browser/navigator-contribution');
|
|
31
31
|
const { ApplicationShell } = require('@theia/core/lib/browser/shell/application-shell');
|
|
32
|
+
const { HostedPluginSupport } = require('@theia/plugin-ext/lib/hosted/browser/hosted-plugin');
|
|
33
|
+
const { ProgressStatusBarItem } = require('@theia/core/lib/browser/progress-status-bar-item');
|
|
34
|
+
const { EXPLORER_VIEW_CONTAINER_ID } = require('@theia/navigator/lib/browser/navigator-widget-factory');
|
|
35
|
+
const { MonacoEditor } = require('@theia/monaco/lib/browser/monaco-editor');
|
|
32
36
|
const container = window.theia.container;
|
|
33
37
|
const editorManager = container.get(EditorManager);
|
|
34
38
|
const workspaceService = container.get(WorkspaceService);
|
|
@@ -38,10 +42,17 @@ describe('Find and Replace', function () {
|
|
|
38
42
|
const navigatorContribution = container.get(FileNavigatorContribution);
|
|
39
43
|
const shell = container.get(ApplicationShell);
|
|
40
44
|
const rootUri = workspaceService.tryGetRoots()[0].resource;
|
|
41
|
-
const
|
|
45
|
+
const pluginService = container.get(HostedPluginSupport);
|
|
46
|
+
const progressStatusBarItem = container.get(ProgressStatusBarItem);
|
|
47
|
+
const fileUri = rootUri.resolve('../api-tests/test-ts-workspace/demo-file.ts');
|
|
42
48
|
|
|
43
49
|
const toTearDown = new DisposableCollection();
|
|
44
50
|
|
|
51
|
+
function pause(ms = 500) {
|
|
52
|
+
console.debug(`pause test for: ${ms} ms`);
|
|
53
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
54
|
+
}
|
|
55
|
+
|
|
45
56
|
/**
|
|
46
57
|
* @template T
|
|
47
58
|
* @param {() => Promise<T> | T} condition
|
|
@@ -57,32 +68,23 @@ describe('Find and Replace', function () {
|
|
|
57
68
|
});
|
|
58
69
|
}
|
|
59
70
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
before(() => {
|
|
67
|
-
shell.leftPanelHandler.collapse();
|
|
71
|
+
before(async () => {
|
|
72
|
+
await pluginService.didStart;
|
|
73
|
+
await shell.leftPanelHandler.collapse();
|
|
74
|
+
await editorManager.closeAll({ save: false });
|
|
68
75
|
});
|
|
69
76
|
|
|
70
77
|
beforeEach(async function () {
|
|
71
78
|
await navigatorContribution.closeView();
|
|
72
|
-
await pause();
|
|
73
|
-
await editorManager.closeAll({ save: false });
|
|
74
|
-
await pause();
|
|
75
79
|
});
|
|
76
80
|
|
|
77
81
|
afterEach(async () => {
|
|
78
|
-
toTearDown.dispose();
|
|
79
|
-
await navigatorContribution.closeView();
|
|
80
|
-
await pause();
|
|
81
82
|
await editorManager.closeAll({ save: false });
|
|
82
83
|
});
|
|
83
84
|
|
|
84
|
-
after(() => {
|
|
85
|
-
shell.leftPanelHandler.collapse();
|
|
85
|
+
after(async () => {
|
|
86
|
+
await shell.leftPanelHandler.collapse();
|
|
87
|
+
toTearDown.dispose();
|
|
86
88
|
});
|
|
87
89
|
|
|
88
90
|
/**
|
|
@@ -109,28 +111,60 @@ describe('Find and Replace', function () {
|
|
|
109
111
|
|
|
110
112
|
for (const command of [CommonCommands.FIND, CommonCommands.REPLACE]) {
|
|
111
113
|
it(command.label + ' in the active editor', async function () {
|
|
112
|
-
await
|
|
114
|
+
await openExplorer();
|
|
113
115
|
|
|
114
|
-
await
|
|
116
|
+
await openEditor();
|
|
115
117
|
|
|
116
118
|
await assertEditorFindReplace(command);
|
|
117
119
|
});
|
|
118
120
|
|
|
119
121
|
it(command.label + ' in the active explorer without the current editor', async function () {
|
|
120
|
-
await
|
|
122
|
+
await openExplorer();
|
|
121
123
|
|
|
122
124
|
// should not throw
|
|
123
125
|
await commands.executeCommand(command.id);
|
|
124
126
|
});
|
|
125
127
|
|
|
126
128
|
it(command.label + ' in the active explorer with the current editor', async function () {
|
|
127
|
-
await
|
|
129
|
+
await openEditor();
|
|
128
130
|
|
|
129
|
-
await
|
|
131
|
+
await openExplorer();
|
|
130
132
|
|
|
131
133
|
await assertEditorFindReplace(command);
|
|
132
134
|
});
|
|
133
135
|
|
|
134
136
|
}
|
|
135
137
|
|
|
138
|
+
async function openExplorer() {
|
|
139
|
+
await navigatorContribution.openView({ activate: true });
|
|
140
|
+
const widget = await shell.revealWidget(EXPLORER_VIEW_CONTAINER_ID);
|
|
141
|
+
assert.isDefined(widget, 'Explorer widget should exist');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function openEditor() {
|
|
145
|
+
await editorManager.open(fileUri, { mode: 'activate' });
|
|
146
|
+
await waitLanguageServerReady();
|
|
147
|
+
const activeEditor = /** @type {MonacoEditor} */ MonacoEditor.get(editorManager.activeEditor);
|
|
148
|
+
assert.isDefined(activeEditor);
|
|
149
|
+
// @ts-ignore
|
|
150
|
+
assert.equal(activeEditor.uri.resolveToAbsolute().toString(), fileUri.resolveToAbsolute().toString());
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async function waitLanguageServerReady() {
|
|
154
|
+
// quite a bit of jitter in the "Initializing LS" status bar entry,
|
|
155
|
+
// so we want to read a few times in a row that it's done (undefined)
|
|
156
|
+
const MAX_N = 5
|
|
157
|
+
let n = MAX_N;
|
|
158
|
+
while (n > 0) {
|
|
159
|
+
await pause(1);
|
|
160
|
+
if (progressStatusBarItem.currentProgress) {
|
|
161
|
+
n = MAX_N;
|
|
162
|
+
} else {
|
|
163
|
+
n--;
|
|
164
|
+
}
|
|
165
|
+
if (n < 5) {
|
|
166
|
+
console.debug('n = ' + n);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
136
170
|
});
|