@theia/test 1.45.0 → 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,36 +1,36 @@
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 { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
- import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
19
-
20
- @injectable()
21
- export class TestContextKeyService {
22
-
23
- @inject(ContextKeyService)
24
- protected readonly contextKeyService: ContextKeyService;
25
-
26
- protected _contextValue: ContextKey<string | undefined>;
27
- get contextValue(): ContextKey<string | undefined> {
28
- return this._contextValue;
29
- }
30
-
31
- @postConstruct()
32
- protected init(): void {
33
- this._contextValue = this.contextKeyService.createKey<string | undefined>('testMessage', undefined);
34
- }
35
-
36
- }
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 { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
18
+ import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
19
+
20
+ @injectable()
21
+ export class TestContextKeyService {
22
+
23
+ @inject(ContextKeyService)
24
+ protected readonly contextKeyService: ContextKeyService;
25
+
26
+ protected _contextValue: ContextKey<string | undefined>;
27
+ get contextValue(): ContextKey<string | undefined> {
28
+ return this._contextValue;
29
+ }
30
+
31
+ @postConstruct()
32
+ protected init(): void {
33
+ this._contextValue = this.contextKeyService.createKey<string | undefined>('testMessage', undefined);
34
+ }
35
+
36
+ }
@@ -1,147 +1,147 @@
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 { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
- import { TestController, TestExecutionState, TestItem, TestRun, TestService } from '../test-service';
19
-
20
- /**
21
- * This class manages the state of "internal" nodes in the test tree
22
- */
23
- @injectable()
24
- export class TestExecutionStateManager {
25
- @inject(TestService)
26
- protected readonly testService: TestService;
27
-
28
- private executionStates = new Map<TestRun, TestExecutionStateMap>();
29
-
30
- @postConstruct()
31
- init(): void {
32
- this.testService.getControllers().forEach(controller => this.addController(controller));
33
- this.testService.onControllersChanged(controllerDelta => {
34
- controllerDelta.added?.forEach(controller => this.addController(controller));
35
- });
36
- }
37
- addController(controller: TestController): void {
38
- controller.testRuns.forEach(run => this.addRun(run));
39
- controller.onRunsChanged(runDelta => {
40
- runDelta.added?.forEach(run => this.addRun(run));
41
- runDelta.removed?.forEach(run => {
42
- this.executionStates.delete(run);
43
- });
44
- });
45
- }
46
- addRun(run: TestRun): void {
47
- this.executionStates.set(run, new TestExecutionStateMap);
48
- run.onDidChangeTestState(updates => {
49
- updates.forEach(update => {
50
- this.updateState(run, update.test, update.oldState?.state, update.newState?.state);
51
- });
52
- });
53
- }
54
-
55
- protected updateState(run: TestRun, item: TestItem, oldState: TestExecutionState | undefined, newState: TestExecutionState | undefined): void {
56
- const map = this.executionStates.get(run)!;
57
- map.reportState(item, oldState, newState);
58
- }
59
-
60
- getComputedState(run: TestRun, item: TestItem): TestExecutionState | undefined {
61
- return this.executionStates.get(run)?.getComputedState(item);
62
- }
63
- }
64
-
65
- class TestExecutionStateMap {
66
- reportState(item: TestItem, oldState: TestExecutionState | undefined, newState: TestExecutionState | undefined): void {
67
- if (oldState !== newState) {
68
- if (item.parent) {
69
- this.reportChildStateChanged(item.parent, oldState, newState);
70
- }
71
- }
72
- }
73
- reportChildStateChanged(parent: TestItem, oldState: TestExecutionState | undefined, newState: TestExecutionState | undefined): void {
74
- if (oldState !== newState) {
75
- const currentParentState = this.getComputedState(parent);
76
- let counts = this.stateCounts.get(parent);
77
- if (!counts) {
78
- counts = [];
79
- counts[TestExecutionState.Queued] = 0;
80
- counts[TestExecutionState.Running] = 0;
81
- counts[TestExecutionState.Passed] = 0;
82
- counts[TestExecutionState.Failed] = 0;
83
- counts[TestExecutionState.Skipped] = 0;
84
- counts[TestExecutionState.Errored] = 0;
85
- this.stateCounts.set(parent, counts);
86
- }
87
- if (oldState) {
88
- counts[oldState]--;
89
- }
90
- if (newState) {
91
- counts[newState]++;
92
- }
93
- const newParentState = this.getComputedState(parent);
94
- if (parent.parent && currentParentState !== newParentState) {
95
- this.reportChildStateChanged(parent.parent, currentParentState, newParentState!);
96
- }
97
- }
98
- }
99
-
100
- private stateCounts: Map<TestItem | TestController, number[]> = new Map();
101
-
102
- updateState(item: TestItem, oldState: TestExecutionState | undefined, newState: TestExecutionState): void {
103
- let parent = item.parent;
104
- while (parent && 'parent' in parent) { // parent is a test item
105
- let counts = this.stateCounts.get(parent);
106
- if (!counts) {
107
- counts = [];
108
- counts[TestExecutionState.Queued] = 0;
109
- counts[TestExecutionState.Running] = 0;
110
- counts[TestExecutionState.Passed] = 0;
111
- counts[TestExecutionState.Failed] = 0;
112
- counts[TestExecutionState.Skipped] = 0;
113
- counts[TestExecutionState.Errored] = 0;
114
- this.stateCounts.set(parent, counts);
115
- }
116
- if (oldState) {
117
- counts[oldState]--;
118
- }
119
- counts[newState]++;
120
- parent = parent.parent;
121
- }
122
- }
123
-
124
- getComputedState(item: TestItem): TestExecutionState | undefined {
125
- const counts = this.stateCounts.get(item);
126
- if (counts) {
127
- if (counts[TestExecutionState.Errored] > 0) {
128
- return TestExecutionState.Errored;
129
- } else if (counts[TestExecutionState.Failed] > 0) {
130
- return TestExecutionState.Failed;
131
- } else if (counts[TestExecutionState.Running] > 0) {
132
- return TestExecutionState.Running;
133
- } else if (counts[TestExecutionState.Queued] > 0) {
134
- return TestExecutionState.Queued;
135
- } else if (counts[TestExecutionState.Passed] > 0) {
136
- return TestExecutionState.Passed;
137
- } else if (counts[TestExecutionState.Skipped] > 0) {
138
- return TestExecutionState.Skipped;
139
- } else {
140
- return undefined;
141
- }
142
- } else {
143
- return undefined;
144
- }
145
- }
146
- }
147
-
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 { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
+ import { TestController, TestExecutionState, TestItem, TestRun, TestService } from '../test-service';
19
+
20
+ /**
21
+ * This class manages the state of "internal" nodes in the test tree
22
+ */
23
+ @injectable()
24
+ export class TestExecutionStateManager {
25
+ @inject(TestService)
26
+ protected readonly testService: TestService;
27
+
28
+ private executionStates = new Map<TestRun, TestExecutionStateMap>();
29
+
30
+ @postConstruct()
31
+ init(): void {
32
+ this.testService.getControllers().forEach(controller => this.addController(controller));
33
+ this.testService.onControllersChanged(controllerDelta => {
34
+ controllerDelta.added?.forEach(controller => this.addController(controller));
35
+ });
36
+ }
37
+ addController(controller: TestController): void {
38
+ controller.testRuns.forEach(run => this.addRun(run));
39
+ controller.onRunsChanged(runDelta => {
40
+ runDelta.added?.forEach(run => this.addRun(run));
41
+ runDelta.removed?.forEach(run => {
42
+ this.executionStates.delete(run);
43
+ });
44
+ });
45
+ }
46
+ addRun(run: TestRun): void {
47
+ this.executionStates.set(run, new TestExecutionStateMap);
48
+ run.onDidChangeTestState(updates => {
49
+ updates.forEach(update => {
50
+ this.updateState(run, update.test, update.oldState?.state, update.newState?.state);
51
+ });
52
+ });
53
+ }
54
+
55
+ protected updateState(run: TestRun, item: TestItem, oldState: TestExecutionState | undefined, newState: TestExecutionState | undefined): void {
56
+ const map = this.executionStates.get(run)!;
57
+ map.reportState(item, oldState, newState);
58
+ }
59
+
60
+ getComputedState(run: TestRun, item: TestItem): TestExecutionState | undefined {
61
+ return this.executionStates.get(run)?.getComputedState(item);
62
+ }
63
+ }
64
+
65
+ class TestExecutionStateMap {
66
+ reportState(item: TestItem, oldState: TestExecutionState | undefined, newState: TestExecutionState | undefined): void {
67
+ if (oldState !== newState) {
68
+ if (item.parent) {
69
+ this.reportChildStateChanged(item.parent, oldState, newState);
70
+ }
71
+ }
72
+ }
73
+ reportChildStateChanged(parent: TestItem, oldState: TestExecutionState | undefined, newState: TestExecutionState | undefined): void {
74
+ if (oldState !== newState) {
75
+ const currentParentState = this.getComputedState(parent);
76
+ let counts = this.stateCounts.get(parent);
77
+ if (!counts) {
78
+ counts = [];
79
+ counts[TestExecutionState.Queued] = 0;
80
+ counts[TestExecutionState.Running] = 0;
81
+ counts[TestExecutionState.Passed] = 0;
82
+ counts[TestExecutionState.Failed] = 0;
83
+ counts[TestExecutionState.Skipped] = 0;
84
+ counts[TestExecutionState.Errored] = 0;
85
+ this.stateCounts.set(parent, counts);
86
+ }
87
+ if (oldState) {
88
+ counts[oldState]--;
89
+ }
90
+ if (newState) {
91
+ counts[newState]++;
92
+ }
93
+ const newParentState = this.getComputedState(parent);
94
+ if (parent.parent && currentParentState !== newParentState) {
95
+ this.reportChildStateChanged(parent.parent, currentParentState, newParentState!);
96
+ }
97
+ }
98
+ }
99
+
100
+ private stateCounts: Map<TestItem | TestController, number[]> = new Map();
101
+
102
+ updateState(item: TestItem, oldState: TestExecutionState | undefined, newState: TestExecutionState): void {
103
+ let parent = item.parent;
104
+ while (parent && 'parent' in parent) { // parent is a test item
105
+ let counts = this.stateCounts.get(parent);
106
+ if (!counts) {
107
+ counts = [];
108
+ counts[TestExecutionState.Queued] = 0;
109
+ counts[TestExecutionState.Running] = 0;
110
+ counts[TestExecutionState.Passed] = 0;
111
+ counts[TestExecutionState.Failed] = 0;
112
+ counts[TestExecutionState.Skipped] = 0;
113
+ counts[TestExecutionState.Errored] = 0;
114
+ this.stateCounts.set(parent, counts);
115
+ }
116
+ if (oldState) {
117
+ counts[oldState]--;
118
+ }
119
+ counts[newState]++;
120
+ parent = parent.parent;
121
+ }
122
+ }
123
+
124
+ getComputedState(item: TestItem): TestExecutionState | undefined {
125
+ const counts = this.stateCounts.get(item);
126
+ if (counts) {
127
+ if (counts[TestExecutionState.Errored] > 0) {
128
+ return TestExecutionState.Errored;
129
+ } else if (counts[TestExecutionState.Failed] > 0) {
130
+ return TestExecutionState.Failed;
131
+ } else if (counts[TestExecutionState.Running] > 0) {
132
+ return TestExecutionState.Running;
133
+ } else if (counts[TestExecutionState.Queued] > 0) {
134
+ return TestExecutionState.Queued;
135
+ } else if (counts[TestExecutionState.Passed] > 0) {
136
+ return TestExecutionState.Passed;
137
+ } else if (counts[TestExecutionState.Skipped] > 0) {
138
+ return TestExecutionState.Skipped;
139
+ } else {
140
+ return undefined;
141
+ }
142
+ } else {
143
+ return undefined;
144
+ }
145
+ }
146
+ }
147
+