@theia/test 1.45.1 → 1.46.0-next.72

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.
Files changed (53) hide show
  1. package/lib/browser/constants.d.ts +45 -45
  2. package/lib/browser/constants.js +17 -17
  3. package/lib/browser/test-service.d.ts +154 -154
  4. package/lib/browser/test-service.js +247 -247
  5. package/lib/browser/view/test-context-key-service.d.ts +7 -7
  6. package/lib/browser/view/test-context-key-service.js +51 -51
  7. package/lib/browser/view/test-execution-state-manager.d.ts +13 -13
  8. package/lib/browser/view/test-execution-state-manager.js +173 -173
  9. package/lib/browser/view/test-output-ui-model.d.ts +47 -47
  10. package/lib/browser/view/test-output-ui-model.js +151 -151
  11. package/lib/browser/view/test-output-view-contribution.d.ts +5 -5
  12. package/lib/browser/view/test-output-view-contribution.js +47 -47
  13. package/lib/browser/view/test-output-widget.d.ts +24 -24
  14. package/lib/browser/view/test-output-widget.js +158 -158
  15. package/lib/browser/view/test-result-view-contribution.d.ts +5 -5
  16. package/lib/browser/view/test-result-view-contribution.js +47 -47
  17. package/lib/browser/view/test-result-widget.d.ts +20 -20
  18. package/lib/browser/view/test-result-widget.js +108 -108
  19. package/lib/browser/view/test-run-view-contribution.d.ts +17 -17
  20. package/lib/browser/view/test-run-view-contribution.js +100 -100
  21. package/lib/browser/view/test-run-widget.d.ts +58 -58
  22. package/lib/browser/view/test-run-widget.js +310 -310
  23. package/lib/browser/view/test-tree-widget.d.ts +67 -67
  24. package/lib/browser/view/test-tree-widget.js +386 -386
  25. package/lib/browser/view/test-view-contribution.d.ts +45 -45
  26. package/lib/browser/view/test-view-contribution.js +288 -288
  27. package/lib/browser/view/test-view-frontend-module.d.ts +6 -6
  28. package/lib/browser/view/test-view-frontend-module.js +121 -121
  29. package/lib/common/collections.d.ts +46 -46
  30. package/lib/common/collections.js +210 -210
  31. package/lib/common/tree-delta.d.ts +51 -51
  32. package/lib/common/tree-delta.js +240 -240
  33. package/lib/common/tree-delta.spec.d.ts +1 -1
  34. package/lib/common/tree-delta.spec.js +139 -139
  35. package/package.json +8 -8
  36. package/src/browser/constants.ts +71 -71
  37. package/src/browser/style/index.css +41 -41
  38. package/src/browser/test-service.ts +355 -355
  39. package/src/browser/view/test-context-key-service.ts +36 -36
  40. package/src/browser/view/test-execution-state-manager.ts +147 -147
  41. package/src/browser/view/test-output-ui-model.ts +156 -156
  42. package/src/browser/view/test-output-view-contribution.ts +34 -34
  43. package/src/browser/view/test-output-widget.ts +148 -148
  44. package/src/browser/view/test-result-view-contribution.ts +34 -34
  45. package/src/browser/view/test-result-widget.ts +92 -92
  46. package/src/browser/view/test-run-view-contribution.ts +89 -89
  47. package/src/browser/view/test-run-widget.tsx +271 -271
  48. package/src/browser/view/test-tree-widget.tsx +360 -360
  49. package/src/browser/view/test-view-contribution.ts +300 -300
  50. package/src/browser/view/test-view-frontend-module.ts +134 -134
  51. package/src/common/collections.ts +223 -223
  52. package/src/common/tree-delta.spec.ts +166 -166
  53. package/src/common/tree-delta.ts +259 -259
@@ -1,300 +1,300 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2023 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
- import { AbstractViewContribution, FrontendApplicationContribution, ViewContainerTitleOptions, Widget, codicon } from '@theia/core/lib/browser';
18
- import { Command, CommandRegistry, MenuModelRegistry, nls } from '@theia/core';
19
- import { inject, injectable } from '@theia/core/shared/inversify';
20
- import { TestItem, TestRunProfileKind, TestService } from '../test-service';
21
- import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
22
- import { TestTreeWidget } from './test-tree-widget';
23
- import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
24
- import { TestCommandId } from '../constants';
25
- import { NavigationLocationService } from '@theia/editor/lib/browser/navigation/navigation-location-service';
26
- import { NavigationLocation } from '@theia/editor/lib/browser/navigation/navigation-location';
27
- import { FileService } from '@theia/filesystem/lib/browser/file-service';
28
- import { FileNavigatorCommands } from '@theia/navigator/lib/browser/file-navigator-commands';
29
-
30
- export namespace TestViewCommands {
31
- /**
32
- * Command which refreshes all test.
33
- */
34
- export const REFRESH: Command = Command.toDefaultLocalizedCommand({
35
- id: TestCommandId.RefreshTestsAction,
36
- label: 'Refresh Tests',
37
- category: 'Test',
38
- iconClass: codicon('refresh')
39
- });
40
-
41
- /**
42
- * Command which cancels the refresh
43
- */
44
- export const CANCEL_REFRESH: Command = Command.toDefaultLocalizedCommand({
45
- id: TestCommandId.CancelTestRefreshAction,
46
- label: 'Cancel Test Refresh',
47
- category: 'Test',
48
- iconClass: codicon('stop')
49
- });
50
-
51
- export const RUN_ALL_TESTS: Command = Command.toDefaultLocalizedCommand({
52
- id: TestCommandId.RunAllAction,
53
- label: 'Run All Tests',
54
- category: 'Test',
55
- iconClass: codicon('run-all')
56
- });
57
-
58
- export const DEBUG_ALL_TESTS: Command = Command.toDefaultLocalizedCommand({
59
- id: TestCommandId.DebugAllAction,
60
- label: 'Debug Tests',
61
- category: 'Test',
62
- iconClass: codicon('debug-all')
63
- });
64
-
65
- export const RUN_TEST: Command = Command.toDefaultLocalizedCommand({
66
- id: TestCommandId.RunAction,
67
- label: 'Run Test',
68
- category: 'Test',
69
- iconClass: codicon('run')
70
- });
71
-
72
- export const RUN_TEST_WITH_PROFILE: Command = Command.toDefaultLocalizedCommand({
73
- id: TestCommandId.RunUsingProfileAction,
74
- category: 'Test',
75
- label: 'Execute using Profile...'
76
- });
77
-
78
- export const DEBUG_TEST: Command = Command.toDefaultLocalizedCommand({
79
- id: TestCommandId.DebugAction,
80
- label: 'Debug Test',
81
- category: 'Test',
82
- iconClass: codicon('debug-alt')
83
- });
84
-
85
- export const CANCEL_ALL_RUNS: Command = Command.toLocalizedCommand({
86
- id: 'testing.cancelAllRuns',
87
- label: 'Cancel All Test Runs',
88
- category: 'Test',
89
- iconClass: codicon('debug-stop')
90
- }, 'theia/test/cancelAllTestRuns', nls.getDefaultKey('Test'));
91
-
92
- export const CANCEL_RUN: Command = Command.toDefaultLocalizedCommand({
93
- id: TestCommandId.CancelTestRunAction,
94
- label: 'Cancel Test Run',
95
- category: 'Test',
96
- iconClass: codicon('debug-stop')
97
- });
98
-
99
- export const GOTO_TEST: Command = Command.toDefaultLocalizedCommand({
100
- id: TestCommandId.GoToTest,
101
- label: 'Go to Test',
102
- category: 'Test',
103
- iconClass: codicon('go-to-file')
104
- });
105
-
106
- export const CONFIGURE_PROFILES: Command = Command.toDefaultLocalizedCommand({
107
- id: TestCommandId.ConfigureTestProfilesAction,
108
- label: 'Configure Test Profiles',
109
- category: 'Test'
110
- });
111
-
112
- export const CLEAR_ALL_RESULTS: Command = Command.toDefaultLocalizedCommand({
113
- id: TestCommandId.ClearTestResultsAction,
114
- label: 'Clear All Results',
115
- category: 'Test',
116
- iconClass: codicon('trash')
117
- });
118
- }
119
-
120
- export const TEST_VIEW_CONTEXT_MENU = ['test-view-context-menu'];
121
- export const TEST_VIEW_INLINE_MENU = [...TEST_VIEW_CONTEXT_MENU, 'inline'];
122
-
123
- export const TEST_VIEW_CONTAINER_ID = 'test-view-container';
124
- export const TEST_VIEW_CONTAINER_TITLE_OPTIONS: ViewContainerTitleOptions = {
125
- label: nls.localizeByDefault('Testing'),
126
- iconClass: codicon('beaker'),
127
- closeable: true
128
- };
129
-
130
- @injectable()
131
- export class TestViewContribution extends AbstractViewContribution<TestTreeWidget> implements
132
- FrontendApplicationContribution, TabBarToolbarContribution {
133
-
134
- @inject(TestService) protected readonly testService: TestService;
135
- @inject(ContextKeyService) protected readonly contextKeys: ContextKeyService;
136
- @inject(NavigationLocationService) navigationService: NavigationLocationService;
137
- @inject(FileService) fileSystem: FileService;
138
-
139
- constructor() {
140
- super({
141
- viewContainerId: TEST_VIEW_CONTAINER_ID,
142
- widgetId: TestTreeWidget.ID,
143
- widgetName: nls.localizeByDefault('Test Explorer'),
144
- defaultWidgetOptions: {
145
- area: 'left',
146
- rank: 600,
147
- }
148
- });
149
- }
150
-
151
- async initializeLayout(): Promise<void> {
152
- await this.openView({ activate: false });
153
- }
154
-
155
- override registerCommands(commands: CommandRegistry): void {
156
- super.registerCommands(commands);
157
- commands.registerCommand(TestViewCommands.REFRESH, {
158
- isEnabled: w => this.withWidget(w, () => !this.testService.isRefreshing),
159
- isVisible: w => this.withWidget(w, () => !this.testService.isRefreshing),
160
- execute: () => this.testService.refresh()
161
- });
162
-
163
- commands.registerCommand(TestViewCommands.CANCEL_REFRESH, {
164
- isEnabled: w => this.withWidget(w, () => this.testService.isRefreshing),
165
- isVisible: w => this.withWidget(w, () => this.testService.isRefreshing),
166
- execute: () => this.testService.cancelRefresh()
167
- });
168
-
169
- commands.registerCommand(TestViewCommands.RUN_ALL_TESTS, {
170
- isEnabled: w => this.withWidget(w, () => true),
171
- isVisible: w => this.withWidget(w, () => true),
172
- execute: () => this.testService.runAllTests(TestRunProfileKind.Run)
173
- });
174
-
175
- commands.registerCommand(TestViewCommands.DEBUG_ALL_TESTS, {
176
- isEnabled: w => this.withWidget(w, () => true),
177
- isVisible: w => this.withWidget(w, () => true),
178
- execute: () => this.testService.runAllTests(TestRunProfileKind.Debug)
179
- });
180
-
181
- commands.registerCommand(TestViewCommands.RUN_TEST, {
182
- isEnabled: t => TestItem.is(t),
183
- isVisible: t => TestItem.is(t),
184
- execute: t => {
185
- this.testService.runTests(TestRunProfileKind.Run, [t]);
186
- }
187
- });
188
-
189
- commands.registerCommand(TestViewCommands.DEBUG_TEST, {
190
- isEnabled: t => TestItem.is(t),
191
- isVisible: t => TestItem.is(t),
192
- execute: t => {
193
- this.testService.runTests(TestRunProfileKind.Debug, [t]);
194
- }
195
- });
196
-
197
- commands.registerCommand(TestViewCommands.RUN_TEST_WITH_PROFILE, {
198
- isEnabled: t => TestItem.is(t),
199
- isVisible: t => TestItem.is(t),
200
- execute: t => {
201
- this.testService.runTestsWithProfile([t]);
202
- }
203
- });
204
-
205
- commands.registerCommand(TestViewCommands.CANCEL_ALL_RUNS, {
206
- isEnabled: w => this.withWidget(w, () => true),
207
- isVisible: w => this.withWidget(w, () => true),
208
- execute: () => this.cancelAllRuns()
209
- });
210
-
211
- commands.registerCommand(TestViewCommands.GOTO_TEST, {
212
- isEnabled: t => TestItem.is(t) && !!t.uri,
213
- isVisible: t => TestItem.is(t) && !!t.uri,
214
- execute: t => {
215
- if (TestItem.is(t)) {
216
- this.fileSystem.resolve(t.uri!).then(stat => {
217
- if (stat.isFile) {
218
- this.navigationService.reveal(NavigationLocation.create(t.uri!, t.range ? t.range.start : { line: 0, character: 0 }));
219
- } else {
220
- commands.executeCommand(FileNavigatorCommands.REVEAL_IN_NAVIGATOR.id, t.uri!);
221
- }
222
- });
223
- }
224
- }
225
- });
226
-
227
- commands.registerCommand(TestViewCommands.CONFIGURE_PROFILES, {
228
- execute: () => {
229
- this.testService.configureProfile();
230
- }
231
- });
232
- }
233
-
234
- protected cancelAllRuns(): void {
235
- this.testService.getControllers().forEach(controller => controller.testRuns.forEach(run => run.cancel()));
236
- }
237
-
238
- override registerMenus(menus: MenuModelRegistry): void {
239
- super.registerMenus(menus);
240
- menus.registerMenuAction(TEST_VIEW_INLINE_MENU, {
241
- commandId: TestViewCommands.RUN_TEST.id,
242
- order: 'a'
243
- });
244
- menus.registerMenuAction(TEST_VIEW_INLINE_MENU, {
245
- commandId: TestViewCommands.DEBUG_TEST.id,
246
- order: 'aa'
247
- });
248
- menus.registerMenuAction(TEST_VIEW_INLINE_MENU, {
249
- commandId: TestViewCommands.GOTO_TEST.id,
250
- order: 'aaa'
251
- });
252
-
253
- menus.registerMenuAction(TEST_VIEW_CONTEXT_MENU, {
254
- commandId: TestViewCommands.RUN_TEST_WITH_PROFILE.id,
255
- order: 'aaaa'
256
- });
257
- }
258
-
259
- registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
260
- toolbar.registerItem({
261
- id: TestViewCommands.REFRESH.id,
262
- command: TestViewCommands.REFRESH.id,
263
- priority: 0,
264
- onDidChange: this.testService.onDidChangeIsRefreshing
265
- });
266
-
267
- toolbar.registerItem({
268
- id: TestViewCommands.CANCEL_REFRESH.id,
269
- command: TestViewCommands.CANCEL_REFRESH.id,
270
- priority: 0,
271
- onDidChange: this.testService.onDidChangeIsRefreshing
272
- });
273
-
274
- toolbar.registerItem({
275
- id: TestViewCommands.RUN_ALL_TESTS.id,
276
- command: TestViewCommands.RUN_ALL_TESTS.id,
277
- priority: 1
278
- });
279
-
280
- toolbar.registerItem({
281
- id: TestViewCommands.DEBUG_ALL_TESTS.id,
282
- command: TestViewCommands.DEBUG_ALL_TESTS.id,
283
- priority: 2
284
- });
285
-
286
- toolbar.registerItem({
287
- id: TestViewCommands.CANCEL_ALL_RUNS.id,
288
- command: TestViewCommands.CANCEL_ALL_RUNS.id,
289
- priority: 3
290
- });
291
-
292
- }
293
-
294
- protected withWidget<T>(widget: Widget | undefined = this.tryGetWidget(), cb: (widget: TestTreeWidget) => T): T | false {
295
- if (widget instanceof TestTreeWidget && widget.id === TestTreeWidget.ID) {
296
- return cb(widget);
297
- }
298
- return false;
299
- }
300
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 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
+ import { AbstractViewContribution, FrontendApplicationContribution, ViewContainerTitleOptions, Widget, codicon } from '@theia/core/lib/browser';
18
+ import { Command, CommandRegistry, MenuModelRegistry, nls } from '@theia/core';
19
+ import { inject, injectable } from '@theia/core/shared/inversify';
20
+ import { TestItem, TestRunProfileKind, TestService } from '../test-service';
21
+ import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
22
+ import { TestTreeWidget } from './test-tree-widget';
23
+ import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
24
+ import { TestCommandId } from '../constants';
25
+ import { NavigationLocationService } from '@theia/editor/lib/browser/navigation/navigation-location-service';
26
+ import { NavigationLocation } from '@theia/editor/lib/browser/navigation/navigation-location';
27
+ import { FileService } from '@theia/filesystem/lib/browser/file-service';
28
+ import { FileNavigatorCommands } from '@theia/navigator/lib/browser/file-navigator-commands';
29
+
30
+ export namespace TestViewCommands {
31
+ /**
32
+ * Command which refreshes all test.
33
+ */
34
+ export const REFRESH: Command = Command.toDefaultLocalizedCommand({
35
+ id: TestCommandId.RefreshTestsAction,
36
+ label: 'Refresh Tests',
37
+ category: 'Test',
38
+ iconClass: codicon('refresh')
39
+ });
40
+
41
+ /**
42
+ * Command which cancels the refresh
43
+ */
44
+ export const CANCEL_REFRESH: Command = Command.toDefaultLocalizedCommand({
45
+ id: TestCommandId.CancelTestRefreshAction,
46
+ label: 'Cancel Test Refresh',
47
+ category: 'Test',
48
+ iconClass: codicon('stop')
49
+ });
50
+
51
+ export const RUN_ALL_TESTS: Command = Command.toDefaultLocalizedCommand({
52
+ id: TestCommandId.RunAllAction,
53
+ label: 'Run All Tests',
54
+ category: 'Test',
55
+ iconClass: codicon('run-all')
56
+ });
57
+
58
+ export const DEBUG_ALL_TESTS: Command = Command.toDefaultLocalizedCommand({
59
+ id: TestCommandId.DebugAllAction,
60
+ label: 'Debug Tests',
61
+ category: 'Test',
62
+ iconClass: codicon('debug-all')
63
+ });
64
+
65
+ export const RUN_TEST: Command = Command.toDefaultLocalizedCommand({
66
+ id: TestCommandId.RunAction,
67
+ label: 'Run Test',
68
+ category: 'Test',
69
+ iconClass: codicon('run')
70
+ });
71
+
72
+ export const RUN_TEST_WITH_PROFILE: Command = Command.toDefaultLocalizedCommand({
73
+ id: TestCommandId.RunUsingProfileAction,
74
+ category: 'Test',
75
+ label: 'Execute using Profile...'
76
+ });
77
+
78
+ export const DEBUG_TEST: Command = Command.toDefaultLocalizedCommand({
79
+ id: TestCommandId.DebugAction,
80
+ label: 'Debug Test',
81
+ category: 'Test',
82
+ iconClass: codicon('debug-alt')
83
+ });
84
+
85
+ export const CANCEL_ALL_RUNS: Command = Command.toLocalizedCommand({
86
+ id: 'testing.cancelAllRuns',
87
+ label: 'Cancel All Test Runs',
88
+ category: 'Test',
89
+ iconClass: codicon('debug-stop')
90
+ }, 'theia/test/cancelAllTestRuns', nls.getDefaultKey('Test'));
91
+
92
+ export const CANCEL_RUN: Command = Command.toDefaultLocalizedCommand({
93
+ id: TestCommandId.CancelTestRunAction,
94
+ label: 'Cancel Test Run',
95
+ category: 'Test',
96
+ iconClass: codicon('debug-stop')
97
+ });
98
+
99
+ export const GOTO_TEST: Command = Command.toDefaultLocalizedCommand({
100
+ id: TestCommandId.GoToTest,
101
+ label: 'Go to Test',
102
+ category: 'Test',
103
+ iconClass: codicon('go-to-file')
104
+ });
105
+
106
+ export const CONFIGURE_PROFILES: Command = Command.toDefaultLocalizedCommand({
107
+ id: TestCommandId.ConfigureTestProfilesAction,
108
+ label: 'Configure Test Profiles',
109
+ category: 'Test'
110
+ });
111
+
112
+ export const CLEAR_ALL_RESULTS: Command = Command.toDefaultLocalizedCommand({
113
+ id: TestCommandId.ClearTestResultsAction,
114
+ label: 'Clear All Results',
115
+ category: 'Test',
116
+ iconClass: codicon('trash')
117
+ });
118
+ }
119
+
120
+ export const TEST_VIEW_CONTEXT_MENU = ['test-view-context-menu'];
121
+ export const TEST_VIEW_INLINE_MENU = [...TEST_VIEW_CONTEXT_MENU, 'inline'];
122
+
123
+ export const TEST_VIEW_CONTAINER_ID = 'test-view-container';
124
+ export const TEST_VIEW_CONTAINER_TITLE_OPTIONS: ViewContainerTitleOptions = {
125
+ label: nls.localizeByDefault('Testing'),
126
+ iconClass: codicon('beaker'),
127
+ closeable: true
128
+ };
129
+
130
+ @injectable()
131
+ export class TestViewContribution extends AbstractViewContribution<TestTreeWidget> implements
132
+ FrontendApplicationContribution, TabBarToolbarContribution {
133
+
134
+ @inject(TestService) protected readonly testService: TestService;
135
+ @inject(ContextKeyService) protected readonly contextKeys: ContextKeyService;
136
+ @inject(NavigationLocationService) navigationService: NavigationLocationService;
137
+ @inject(FileService) fileSystem: FileService;
138
+
139
+ constructor() {
140
+ super({
141
+ viewContainerId: TEST_VIEW_CONTAINER_ID,
142
+ widgetId: TestTreeWidget.ID,
143
+ widgetName: nls.localizeByDefault('Test Explorer'),
144
+ defaultWidgetOptions: {
145
+ area: 'left',
146
+ rank: 600,
147
+ }
148
+ });
149
+ }
150
+
151
+ async initializeLayout(): Promise<void> {
152
+ await this.openView({ activate: false });
153
+ }
154
+
155
+ override registerCommands(commands: CommandRegistry): void {
156
+ super.registerCommands(commands);
157
+ commands.registerCommand(TestViewCommands.REFRESH, {
158
+ isEnabled: w => this.withWidget(w, () => !this.testService.isRefreshing),
159
+ isVisible: w => this.withWidget(w, () => !this.testService.isRefreshing),
160
+ execute: () => this.testService.refresh()
161
+ });
162
+
163
+ commands.registerCommand(TestViewCommands.CANCEL_REFRESH, {
164
+ isEnabled: w => this.withWidget(w, () => this.testService.isRefreshing),
165
+ isVisible: w => this.withWidget(w, () => this.testService.isRefreshing),
166
+ execute: () => this.testService.cancelRefresh()
167
+ });
168
+
169
+ commands.registerCommand(TestViewCommands.RUN_ALL_TESTS, {
170
+ isEnabled: w => this.withWidget(w, () => true),
171
+ isVisible: w => this.withWidget(w, () => true),
172
+ execute: () => this.testService.runAllTests(TestRunProfileKind.Run)
173
+ });
174
+
175
+ commands.registerCommand(TestViewCommands.DEBUG_ALL_TESTS, {
176
+ isEnabled: w => this.withWidget(w, () => true),
177
+ isVisible: w => this.withWidget(w, () => true),
178
+ execute: () => this.testService.runAllTests(TestRunProfileKind.Debug)
179
+ });
180
+
181
+ commands.registerCommand(TestViewCommands.RUN_TEST, {
182
+ isEnabled: t => TestItem.is(t),
183
+ isVisible: t => TestItem.is(t),
184
+ execute: t => {
185
+ this.testService.runTests(TestRunProfileKind.Run, [t]);
186
+ }
187
+ });
188
+
189
+ commands.registerCommand(TestViewCommands.DEBUG_TEST, {
190
+ isEnabled: t => TestItem.is(t),
191
+ isVisible: t => TestItem.is(t),
192
+ execute: t => {
193
+ this.testService.runTests(TestRunProfileKind.Debug, [t]);
194
+ }
195
+ });
196
+
197
+ commands.registerCommand(TestViewCommands.RUN_TEST_WITH_PROFILE, {
198
+ isEnabled: t => TestItem.is(t),
199
+ isVisible: t => TestItem.is(t),
200
+ execute: t => {
201
+ this.testService.runTestsWithProfile([t]);
202
+ }
203
+ });
204
+
205
+ commands.registerCommand(TestViewCommands.CANCEL_ALL_RUNS, {
206
+ isEnabled: w => this.withWidget(w, () => true),
207
+ isVisible: w => this.withWidget(w, () => true),
208
+ execute: () => this.cancelAllRuns()
209
+ });
210
+
211
+ commands.registerCommand(TestViewCommands.GOTO_TEST, {
212
+ isEnabled: t => TestItem.is(t) && !!t.uri,
213
+ isVisible: t => TestItem.is(t) && !!t.uri,
214
+ execute: t => {
215
+ if (TestItem.is(t)) {
216
+ this.fileSystem.resolve(t.uri!).then(stat => {
217
+ if (stat.isFile) {
218
+ this.navigationService.reveal(NavigationLocation.create(t.uri!, t.range ? t.range.start : { line: 0, character: 0 }));
219
+ } else {
220
+ commands.executeCommand(FileNavigatorCommands.REVEAL_IN_NAVIGATOR.id, t.uri!);
221
+ }
222
+ });
223
+ }
224
+ }
225
+ });
226
+
227
+ commands.registerCommand(TestViewCommands.CONFIGURE_PROFILES, {
228
+ execute: () => {
229
+ this.testService.configureProfile();
230
+ }
231
+ });
232
+ }
233
+
234
+ protected cancelAllRuns(): void {
235
+ this.testService.getControllers().forEach(controller => controller.testRuns.forEach(run => run.cancel()));
236
+ }
237
+
238
+ override registerMenus(menus: MenuModelRegistry): void {
239
+ super.registerMenus(menus);
240
+ menus.registerMenuAction(TEST_VIEW_INLINE_MENU, {
241
+ commandId: TestViewCommands.RUN_TEST.id,
242
+ order: 'a'
243
+ });
244
+ menus.registerMenuAction(TEST_VIEW_INLINE_MENU, {
245
+ commandId: TestViewCommands.DEBUG_TEST.id,
246
+ order: 'aa'
247
+ });
248
+ menus.registerMenuAction(TEST_VIEW_INLINE_MENU, {
249
+ commandId: TestViewCommands.GOTO_TEST.id,
250
+ order: 'aaa'
251
+ });
252
+
253
+ menus.registerMenuAction(TEST_VIEW_CONTEXT_MENU, {
254
+ commandId: TestViewCommands.RUN_TEST_WITH_PROFILE.id,
255
+ order: 'aaaa'
256
+ });
257
+ }
258
+
259
+ registerToolbarItems(toolbar: TabBarToolbarRegistry): void {
260
+ toolbar.registerItem({
261
+ id: TestViewCommands.REFRESH.id,
262
+ command: TestViewCommands.REFRESH.id,
263
+ priority: 0,
264
+ onDidChange: this.testService.onDidChangeIsRefreshing
265
+ });
266
+
267
+ toolbar.registerItem({
268
+ id: TestViewCommands.CANCEL_REFRESH.id,
269
+ command: TestViewCommands.CANCEL_REFRESH.id,
270
+ priority: 0,
271
+ onDidChange: this.testService.onDidChangeIsRefreshing
272
+ });
273
+
274
+ toolbar.registerItem({
275
+ id: TestViewCommands.RUN_ALL_TESTS.id,
276
+ command: TestViewCommands.RUN_ALL_TESTS.id,
277
+ priority: 1
278
+ });
279
+
280
+ toolbar.registerItem({
281
+ id: TestViewCommands.DEBUG_ALL_TESTS.id,
282
+ command: TestViewCommands.DEBUG_ALL_TESTS.id,
283
+ priority: 2
284
+ });
285
+
286
+ toolbar.registerItem({
287
+ id: TestViewCommands.CANCEL_ALL_RUNS.id,
288
+ command: TestViewCommands.CANCEL_ALL_RUNS.id,
289
+ priority: 3
290
+ });
291
+
292
+ }
293
+
294
+ protected withWidget<T>(widget: Widget | undefined = this.tryGetWidget(), cb: (widget: TestTreeWidget) => T): T | false {
295
+ if (widget instanceof TestTreeWidget && widget.id === TestTreeWidget.ID) {
296
+ return cb(widget);
297
+ }
298
+ return false;
299
+ }
300
+ }