@theia/api-tests 1.48.0 → 1.48.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 CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@theia/api-tests",
3
- "version": "1.48.0",
3
+ "version": "1.48.1",
4
4
  "description": "Theia API tests",
5
5
  "dependencies": {
6
- "@theia/core": "1.48.0"
6
+ "@theia/core": "1.48.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": "ffae6a0739f7924a7cacafeb5ceb1140d93fe010"
23
+ "gitHead": "04c631933dfd14f58d1df5b9b28dd5596c84ec04"
24
24
  }
@@ -1,21 +1,21 @@
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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- interface Window {
18
- theia: {
19
- container: import('inversify').Container
20
- }
21
- }
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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ interface Window {
18
+ theia: {
19
+ container: import('inversify').Container
20
+ }
21
+ }
@@ -1,54 +1,54 @@
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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- // @ts-check
18
- describe('animationFrame', function () {
19
- this.timeout(5_000);
20
- const { assert } = chai;
21
- const { animationFrame } = require('@theia/core/lib/browser/browser');
22
-
23
- class FrameCounter {
24
- constructor() {
25
- this.count = 0;
26
- this.stop = false;
27
- this.run();
28
- }
29
- run() {
30
- requestAnimationFrame(this.nextFrame.bind(this));
31
- }
32
- nextFrame() {
33
- this.count++;
34
- if (!this.stop) {
35
- this.run();
36
- }
37
- }
38
- }
39
-
40
- it('should resolve after one frame', async () => {
41
- const counter = new FrameCounter();
42
- await animationFrame();
43
- counter.stop = true;
44
- assert.equal(counter.count, 1);
45
- });
46
-
47
- it('should resolve after the given number of frames', async () => {
48
- const counter = new FrameCounter();
49
- await animationFrame(10);
50
- counter.stop = true;
51
- assert.equal(counter.count, 10);
52
- });
53
-
54
- });
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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ // @ts-check
18
+ describe('animationFrame', function () {
19
+ this.timeout(5_000);
20
+ const { assert } = chai;
21
+ const { animationFrame } = require('@theia/core/lib/browser/browser');
22
+
23
+ class FrameCounter {
24
+ constructor() {
25
+ this.count = 0;
26
+ this.stop = false;
27
+ this.run();
28
+ }
29
+ run() {
30
+ requestAnimationFrame(this.nextFrame.bind(this));
31
+ }
32
+ nextFrame() {
33
+ this.count++;
34
+ if (!this.stop) {
35
+ this.run();
36
+ }
37
+ }
38
+ }
39
+
40
+ it('should resolve after one frame', async () => {
41
+ const counter = new FrameCounter();
42
+ await animationFrame();
43
+ counter.stop = true;
44
+ assert.equal(counter.count, 1);
45
+ });
46
+
47
+ it('should resolve after the given number of frames', async () => {
48
+ const counter = new FrameCounter();
49
+ await animationFrame(10);
50
+ counter.stop = true;
51
+ assert.equal(counter.count, 10);
52
+ });
53
+
54
+ });
@@ -1,36 +1,36 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 STMicroelectronics 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-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- // @ts-check
18
- describe('Contribution filter', function () {
19
- this.timeout(5000);
20
- const { assert } = chai;
21
-
22
- const { CommandRegistry, CommandContribution } = require('@theia/core/lib/common/command');
23
- const { SampleFilteredCommandContribution, SampleFilteredCommand } = require('@theia/api-samples/lib/browser/contribution-filter/sample-filtered-command-contribution');
24
-
25
- const container = window.theia.container;
26
- const commands = container.get(CommandRegistry);
27
-
28
- it('filtered command in container but not in registry', async function () {
29
- const allCommands = container.getAll(CommandContribution);
30
- assert.isDefined(allCommands.find(contribution => contribution instanceof SampleFilteredCommandContribution),
31
- 'SampleFilteredCommandContribution is not bound in container');
32
- const filteredCommand = commands.getCommand(SampleFilteredCommand.FILTERED.id);
33
- assert.isUndefined(filteredCommand, 'SampleFilteredCommandContribution should be filtered out but is present in "CommandRegistry"');
34
- });
35
-
36
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 STMicroelectronics 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-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ // @ts-check
18
+ describe('Contribution filter', function () {
19
+ this.timeout(5000);
20
+ const { assert } = chai;
21
+
22
+ const { CommandRegistry, CommandContribution } = require('@theia/core/lib/common/command');
23
+ const { SampleFilteredCommandContribution, SampleFilteredCommand } = require('@theia/api-samples/lib/browser/contribution-filter/sample-filtered-command-contribution');
24
+
25
+ const container = window.theia.container;
26
+ const commands = container.get(CommandRegistry);
27
+
28
+ it('filtered command in container but not in registry', async function () {
29
+ const allCommands = container.getAll(CommandContribution);
30
+ assert.isDefined(allCommands.find(contribution => contribution instanceof SampleFilteredCommandContribution),
31
+ 'SampleFilteredCommandContribution is not bound in container');
32
+ const filteredCommand = commands.getCommand(SampleFilteredCommand.FILTERED.id);
33
+ assert.isUndefined(filteredCommand, 'SampleFilteredCommandContribution should be filtered out but is present in "CommandRegistry"');
34
+ });
35
+
36
+ });
@@ -1,155 +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-only 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
- });
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-only 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
+ });