@codingame/monaco-vscode-testing-service-override 1.83.16

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 (33) hide show
  1. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  2. package/external/tslib/tslib.es6.js +11 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +1 -0
  5. package/package.json +30 -0
  6. package/testing.d.ts +5 -0
  7. package/testing.js +28 -0
  8. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/display.js +3 -0
  9. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/index.js +76 -0
  10. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/listProjection.js +186 -0
  11. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testItemContextOverlay.js +18 -0
  12. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testingObjectTree.js +46 -0
  13. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/testingViewState.js +17 -0
  14. package/vscode/src/vs/workbench/contrib/testing/browser/explorerProjections/treeProjection.js +220 -0
  15. package/vscode/src/vs/workbench/contrib/testing/browser/icons.js +149 -0
  16. package/vscode/src/vs/workbench/contrib/testing/browser/media/testing.css.js +6 -0
  17. package/vscode/src/vs/workbench/contrib/testing/browser/testExplorerActions.js +1427 -0
  18. package/vscode/src/vs/workbench/contrib/testing/browser/testing.contribution.js +178 -0
  19. package/vscode/src/vs/workbench/contrib/testing/browser/testingDecorations.js +879 -0
  20. package/vscode/src/vs/workbench/contrib/testing/browser/testingExplorerFilter.js +237 -0
  21. package/vscode/src/vs/workbench/contrib/testing/browser/testingExplorerView.js +1225 -0
  22. package/vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.css.js +6 -0
  23. package/vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.js +1991 -0
  24. package/vscode/src/vs/workbench/contrib/testing/browser/testingProgressUiService.js +142 -0
  25. package/vscode/src/vs/workbench/contrib/testing/browser/testingViewPaneContainer.js +47 -0
  26. package/vscode/src/vs/workbench/contrib/testing/browser/theme.js +130 -0
  27. package/vscode/src/vs/workbench/contrib/testing/common/configuration.js +213 -0
  28. package/vscode/src/vs/workbench/contrib/testing/common/constants.js +59 -0
  29. package/vscode/src/vs/workbench/contrib/testing/common/mainThreadTestCollection.js +129 -0
  30. package/vscode/src/vs/workbench/contrib/testing/common/testExclusions.js +48 -0
  31. package/vscode/src/vs/workbench/contrib/testing/common/testServiceImpl.js +293 -0
  32. package/vscode/src/vs/workbench/contrib/testing/common/testingContentProvider.js +125 -0
  33. package/vscode/src/vs/workbench/contrib/testing/common/testingUri.js +67 -0
@@ -0,0 +1,3 @@
1
+ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=( Object.keys(r.attributes)),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
2
+
3
+ export { n as default };
@@ -0,0 +1,11 @@
1
+ function __decorate(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ }
7
+ function __param(paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ }
10
+
11
+ export { __decorate, __param };
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from './testing.js';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from './testing.js';
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@codingame/monaco-vscode-testing-service-override",
3
+ "version": "1.83.16",
4
+ "keywords": [],
5
+ "author": {
6
+ "name": "CodinGame",
7
+ "url": "http://www.codingame.com"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/CodinGame/monaco-vscode-api.git"
13
+ },
14
+ "type": "module",
15
+ "private": false,
16
+ "description": "VSCode public API plugged on the monaco editor - testing service-override",
17
+ "main": "index.js",
18
+ "module": "index.js",
19
+ "types": "index.d.ts",
20
+ "dependencies": {
21
+ "vscode": "npm:@codingame/monaco-vscode-api@1.83.16",
22
+ "monaco-editor": "0.44.0",
23
+ "xterm-addon-canvas": "0.6.0-beta.27",
24
+ "xterm-addon-image": "0.6.0-beta.21",
25
+ "xterm-addon-search": "0.14.0-beta.27",
26
+ "xterm-addon-serialize": "0.12.0-beta.26",
27
+ "xterm-addon-unicode11": "0.7.0-beta.26",
28
+ "xterm-addon-webgl": "0.17.0-beta.26"
29
+ }
30
+ }
package/testing.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { IEditorOverrideServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
2
+
3
+ declare function getServiceOverride(): IEditorOverrideServices;
4
+
5
+ export { getServiceOverride as default };
package/testing.js ADDED
@@ -0,0 +1,28 @@
1
+ import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
2
+ import { ITestProfileService, TestProfileService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testProfileService';
3
+ import { ITestResultService, TestResultService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResultService';
4
+ import { ITestResultStorage, TestResultStorage } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResultStorage';
5
+ import { ITestService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testService';
6
+ import { TestService } from './vscode/src/vs/workbench/contrib/testing/common/testServiceImpl.js';
7
+ import { ITestingDecorationsService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingDecorations';
8
+ import { TestingDecorationService } from './vscode/src/vs/workbench/contrib/testing/browser/testingDecorations.js';
9
+ import { ITestingPeekOpener } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingPeekOpener';
10
+ import { ITestingContinuousRunService, TestingContinuousRunService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingContinuousRunService';
11
+ import { ITestExplorerFilterState, TestExplorerFilterState } from 'vscode/vscode/vs/workbench/contrib/testing/common/testExplorerFilterState';
12
+ import { TestingPeekOpener } from './vscode/src/vs/workbench/contrib/testing/browser/testingOutputPeek.js';
13
+ import './vscode/src/vs/workbench/contrib/testing/browser/testing.contribution.js';
14
+
15
+ function getServiceOverride() {
16
+ return {
17
+ [( ITestService.toString())]: new SyncDescriptor(TestService, [], true),
18
+ [( ITestResultStorage.toString())]: new SyncDescriptor(TestResultStorage, [], true),
19
+ [( ITestProfileService.toString())]: new SyncDescriptor(TestProfileService, [], true),
20
+ [( ITestingContinuousRunService.toString())]: new SyncDescriptor(TestingContinuousRunService, [], true),
21
+ [( ITestResultService.toString())]: new SyncDescriptor(TestResultService, [], true),
22
+ [( ITestExplorerFilterState.toString())]: new SyncDescriptor(TestExplorerFilterState, [], true),
23
+ [( ITestingPeekOpener.toString())]: new SyncDescriptor(TestingPeekOpener, [], true),
24
+ [( ITestingDecorationsService.toString())]: new SyncDescriptor(TestingDecorationService, [], true)
25
+ };
26
+ }
27
+
28
+ export { getServiceOverride as default };
@@ -0,0 +1,3 @@
1
+ const flatTestItemDelimiter = ' \u203A ';
2
+
3
+ export { flatTestItemDelimiter };
@@ -0,0 +1,76 @@
1
+ import { ObjectTreeElementCollapseState } from 'monaco-editor/esm/vs/base/browser/ui/tree/tree.js';
2
+ import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
3
+ import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
4
+ import { isCollapsedInSerializedTestTree } from './testingViewState.js';
5
+ import { InternalTestItem } from 'vscode/vscode/vs/workbench/contrib/testing/common/testTypes';
6
+
7
+ let idCounter = 0;
8
+ const getId = () => String(idCounter++);
9
+ class TestItemTreeElement {
10
+ constructor(test,
11
+ parent = null) {
12
+ this.test = test;
13
+ this.parent = parent;
14
+ this.changeEmitter = ( new Emitter());
15
+ this.onChange = this.changeEmitter.event;
16
+ this.children = ( new Set());
17
+ this.treeId = getId();
18
+ this.depth = this.parent ? this.parent.depth + 1 : 0;
19
+ this.retired = false;
20
+ this.state = 0 ;
21
+ }
22
+ toJSON() {
23
+ if (this.depth === 0) {
24
+ return { controllerId: this.test.controllerId };
25
+ }
26
+ const context = {
27
+ $mid: 16 ,
28
+ tests: [InternalTestItem.serialize(this.test)],
29
+ };
30
+ for (let p = this.parent; p && p.depth > 0; p = p.parent) {
31
+ context.tests.unshift(InternalTestItem.serialize(p.test));
32
+ }
33
+ return context;
34
+ }
35
+ }
36
+ class TestTreeErrorMessage {
37
+ get description() {
38
+ return typeof this.message === 'string' ? this.message : this.message.value;
39
+ }
40
+ constructor(message, parent) {
41
+ this.message = message;
42
+ this.parent = parent;
43
+ this.treeId = getId();
44
+ this.children = ( new Set());
45
+ }
46
+ }
47
+ const testIdentityProvider = {
48
+ getId(element) {
49
+ return element.treeId + '\0' + (element instanceof TestTreeErrorMessage ? 'error' : element.test.expand);
50
+ }
51
+ };
52
+ const getChildrenForParent = (serialized, rootsWithChildren, node) => {
53
+ let it;
54
+ if (node === null) {
55
+ const rootsWithChildrenArr = [...rootsWithChildren];
56
+ if (rootsWithChildrenArr.length === 1) {
57
+ return getChildrenForParent(serialized, rootsWithChildrenArr, rootsWithChildrenArr[0]);
58
+ }
59
+ it = rootsWithChildrenArr;
60
+ }
61
+ else {
62
+ it = node.children;
63
+ }
64
+ return ( Iterable.map(it, element => (element instanceof TestTreeErrorMessage
65
+ ? { element }
66
+ : {
67
+ element,
68
+ collapsible: element.test.expand !== 0 ,
69
+ collapsed: isCollapsedInSerializedTestTree(serialized, element.test.item.extId) ?? element.depth > 0
70
+ ? ObjectTreeElementCollapseState.PreserveOrCollapsed
71
+ : ObjectTreeElementCollapseState.PreserveOrExpanded,
72
+ children: getChildrenForParent(serialized, rootsWithChildren, element),
73
+ })));
74
+ };
75
+
76
+ export { TestItemTreeElement, TestTreeErrorMessage, getChildrenForParent, testIdentityProvider };
@@ -0,0 +1,186 @@
1
+ import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
3
+ import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
4
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
5
+ import { flatTestItemDelimiter } from './display.js';
6
+ import { getChildrenForParent, testIdentityProvider, TestItemTreeElement, TestTreeErrorMessage } from './index.js';
7
+ import { isCollapsedInSerializedTestTree } from './testingViewState.js';
8
+ import { TestId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testId';
9
+ import { ITestResultService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResultService';
10
+ import { ITestService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testService';
11
+ import { applyTestItemUpdate } from 'vscode/vscode/vs/workbench/contrib/testing/common/testTypes';
12
+
13
+ class ListTestItemElement extends TestItemTreeElement {
14
+ get description() {
15
+ return ( this.chain.map(c => c.item.label)).join(flatTestItemDelimiter);
16
+ }
17
+ constructor(test, parent, chain) {
18
+ super({ ...test, item: { ...test.item } }, parent);
19
+ this.chain = chain;
20
+ this.descriptionParts = [];
21
+ this.updateErrorVisibility();
22
+ }
23
+ update(patch) {
24
+ applyTestItemUpdate(this.test, patch);
25
+ this.updateErrorVisibility(patch);
26
+ this.fireChange();
27
+ }
28
+ fireChange() {
29
+ this.changeEmitter.fire();
30
+ }
31
+ updateErrorVisibility(patch) {
32
+ if (this.errorChild && (!this.test.item.error || patch?.item?.error)) {
33
+ this.children.delete(this.errorChild);
34
+ this.errorChild = undefined;
35
+ }
36
+ if (this.test.item.error && !this.errorChild) {
37
+ this.errorChild = ( new TestTreeErrorMessage(this.test.item.error, this));
38
+ this.children.add(this.errorChild);
39
+ }
40
+ }
41
+ }
42
+ let ListProjection = class ListProjection extends Disposable {
43
+ get rootsWithChildren() {
44
+ const rootsIt = ( Iterable.map(this.testService.collection.rootItems, r => this.items.get(r.item.extId)));
45
+ return Iterable.filter(rootsIt, (r) => !!r?.children.size);
46
+ }
47
+ constructor(lastState, testService, results) {
48
+ super();
49
+ this.lastState = lastState;
50
+ this.testService = testService;
51
+ this.results = results;
52
+ this.updateEmitter = ( new Emitter());
53
+ this.items = ( new Map());
54
+ this.onUpdate = this.updateEmitter.event;
55
+ this._register(testService.onDidProcessDiff((diff) => this.applyDiff(diff)));
56
+ this._register(results.onResultsChanged((evt) => {
57
+ if (!('removed' in evt)) {
58
+ return;
59
+ }
60
+ for (const inTree of ( this.items.values())) {
61
+ const lookup = this.results.getStateById(inTree.test.item.extId)?.[1];
62
+ inTree.duration = lookup?.ownDuration;
63
+ inTree.state = lookup?.ownComputedState || 0 ;
64
+ inTree.fireChange();
65
+ }
66
+ }));
67
+ this._register(results.onTestChanged(ev => {
68
+ if (ev.reason === 2 ) {
69
+ return;
70
+ }
71
+ let result = ev.item;
72
+ if (result.ownComputedState === 0 || ev.result !== results.results[0]) {
73
+ const fallback = results.getStateById(result.item.extId);
74
+ if (fallback) {
75
+ result = fallback[1];
76
+ }
77
+ }
78
+ const item = this.items.get(result.item.extId);
79
+ if (!item) {
80
+ return;
81
+ }
82
+ item.retired = !!result.retired;
83
+ item.state = result.computedState;
84
+ item.duration = result.ownDuration;
85
+ item.fireChange();
86
+ }));
87
+ for (const test of testService.collection.all) {
88
+ this.storeItem(test);
89
+ }
90
+ }
91
+ getElementByTestId(testId) {
92
+ return this.items.get(testId);
93
+ }
94
+ applyDiff(diff) {
95
+ for (const op of diff) {
96
+ switch (op.op) {
97
+ case 0 : {
98
+ this.storeItem(op.item);
99
+ break;
100
+ }
101
+ case 1 : {
102
+ this.items.get(op.item.extId)?.update(op.item);
103
+ break;
104
+ }
105
+ case 3 : {
106
+ for (const [id, item] of this.items) {
107
+ if (id === op.itemId || TestId.isChild(op.itemId, id)) {
108
+ this.unstoreItem(item);
109
+ }
110
+ }
111
+ break;
112
+ }
113
+ }
114
+ }
115
+ if (diff.length !== 0) {
116
+ this.updateEmitter.fire();
117
+ }
118
+ }
119
+ applyTo(tree) {
120
+ tree.setChildren(null, getChildrenForParent(this.lastState, this.rootsWithChildren, null), {
121
+ diffIdentityProvider: testIdentityProvider,
122
+ diffDepth: Infinity
123
+ });
124
+ }
125
+ expandElement(element, depth) {
126
+ if (!(element instanceof ListTestItemElement)) {
127
+ return;
128
+ }
129
+ if (element.test.expand === 0 ) {
130
+ return;
131
+ }
132
+ this.testService.collection.expand(element.test.item.extId, depth);
133
+ }
134
+ unstoreItem(treeElement) {
135
+ this.items.delete(treeElement.test.item.extId);
136
+ treeElement.parent?.children.delete(treeElement);
137
+ const parentId = TestId.fromString(treeElement.test.item.extId).parentId;
138
+ if (!parentId) {
139
+ return;
140
+ }
141
+ for (const id of parentId.idsToRoot()) {
142
+ const parentTest = this.testService.collection.getNodeById(( id.toString()));
143
+ if (parentTest) {
144
+ if (parentTest.children.size === 0 && !( this.items.has(( id.toString())))) {
145
+ this._storeItem(parentId, parentTest);
146
+ }
147
+ break;
148
+ }
149
+ }
150
+ }
151
+ _storeItem(testId, item) {
152
+ const displayedParent = testId.isRoot ? null : this.items.get(item.controllerId);
153
+ const chain = ( [...testId.idsFromRoot()].slice(1, -1).map(id => this.testService.collection.getNodeById(( id.toString()))));
154
+ const treeElement = ( new ListTestItemElement(item, displayedParent, chain));
155
+ displayedParent?.children.add(treeElement);
156
+ this.items.set(treeElement.test.item.extId, treeElement);
157
+ if (treeElement.depth === 0 || isCollapsedInSerializedTestTree(this.lastState, treeElement.test.item.extId) === false) {
158
+ this.expandElement(treeElement, Infinity);
159
+ }
160
+ const prevState = this.results.getStateById(treeElement.test.item.extId)?.[1];
161
+ if (prevState) {
162
+ treeElement.retired = !!prevState.retired;
163
+ treeElement.state = prevState.computedState;
164
+ treeElement.duration = prevState.ownDuration;
165
+ }
166
+ }
167
+ storeItem(item) {
168
+ const testId = TestId.fromString(item.item.extId);
169
+ for (const parentId of testId.idsToRoot()) {
170
+ if (!parentId.isRoot) {
171
+ const prevParent = this.items.get(( parentId.toString()));
172
+ if (prevParent) {
173
+ this.unstoreItem(prevParent);
174
+ break;
175
+ }
176
+ }
177
+ }
178
+ this._storeItem(testId, item);
179
+ }
180
+ };
181
+ ListProjection = ( __decorate([
182
+ ( __param(1, ITestService)),
183
+ ( __param(2, ITestResultService))
184
+ ], ListProjection));
185
+
186
+ export { ListProjection };
@@ -0,0 +1,18 @@
1
+ import { capabilityContextKeys } from 'vscode/vscode/vs/workbench/contrib/testing/common/testProfileService';
2
+ import { TestId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testId';
3
+ import { TestingContextKeys } from 'vscode/vscode/vs/workbench/contrib/testing/common/testingContextKeys';
4
+
5
+ const getTestItemContextOverlay = (test, capabilities) => {
6
+ if (!test) {
7
+ return [];
8
+ }
9
+ const testId = TestId.fromString(test.item.extId);
10
+ return [
11
+ [TestingContextKeys.testItemExtId.key, testId.localId],
12
+ [TestingContextKeys.controllerId.key, test.controllerId],
13
+ [TestingContextKeys.testItemHasUri.key, !!test.item.uri],
14
+ ...capabilityContextKeys(capabilities),
15
+ ];
16
+ };
17
+
18
+ export { getTestItemContextOverlay };
@@ -0,0 +1,46 @@
1
+ import { WorkbenchObjectTree } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
2
+ import { TestItemTreeElement } from './index.js';
3
+ import { TestId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testId';
4
+
5
+ class TestingObjectTree extends WorkbenchObjectTree {
6
+ getOptimizedViewState(updatePreviousState) {
7
+ const root = updatePreviousState || {};
8
+ const build = (node, parent) => {
9
+ if (!(node.element instanceof TestItemTreeElement)) {
10
+ return false;
11
+ }
12
+ const localId = TestId.localId(node.element.test.item.extId);
13
+ const inTree = parent.children?.[localId] || {};
14
+ inTree.collapsed = node.depth === 0 || !node.collapsed ? node.collapsed : undefined;
15
+ let hasAnyNonDefaultValue = inTree.collapsed !== undefined;
16
+ if (node.children.length) {
17
+ for (const child of node.children) {
18
+ hasAnyNonDefaultValue = build(child, inTree) || hasAnyNonDefaultValue;
19
+ }
20
+ }
21
+ if (hasAnyNonDefaultValue) {
22
+ parent.children ??= {};
23
+ parent.children[localId] = inTree;
24
+ }
25
+ else if (parent.children?.hasOwnProperty(localId)) {
26
+ delete parent.children[localId];
27
+ }
28
+ return hasAnyNonDefaultValue;
29
+ };
30
+ root.children ??= {};
31
+ for (const node of this.getNode().children) {
32
+ if (node.element instanceof TestItemTreeElement) {
33
+ if (node.element.test.controllerId === node.element.test.item.extId) {
34
+ build(node, root);
35
+ }
36
+ else {
37
+ const ctrlNode = root.children[node.element.test.controllerId] ??= { children: {} };
38
+ build(node, ctrlNode);
39
+ }
40
+ }
41
+ }
42
+ return root;
43
+ }
44
+ }
45
+
46
+ export { TestingObjectTree };
@@ -0,0 +1,17 @@
1
+ import { TestId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testId';
2
+
3
+ function isCollapsedInSerializedTestTree(serialized, id) {
4
+ if (!(id instanceof TestId)) {
5
+ id = TestId.fromString(id);
6
+ }
7
+ let node = serialized;
8
+ for (const part of id.path) {
9
+ if (!node.children?.hasOwnProperty(part)) {
10
+ return undefined;
11
+ }
12
+ node = node.children[part];
13
+ }
14
+ return node.collapsed;
15
+ }
16
+
17
+ export { isCollapsedInSerializedTestTree };
@@ -0,0 +1,220 @@
1
+ import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
3
+ import { Iterable } from 'monaco-editor/esm/vs/base/common/iterator.js';
4
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
5
+ import { getChildrenForParent, testIdentityProvider, TestItemTreeElement, TestTreeErrorMessage } from './index.js';
6
+ import { isCollapsedInSerializedTestTree } from './testingViewState.js';
7
+ import { refreshComputedState } from 'vscode/vscode/vs/workbench/contrib/testing/common/getComputedState';
8
+ import { TestId } from 'vscode/vscode/vs/workbench/contrib/testing/common/testId';
9
+ import { ITestResultService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testResultService';
10
+ import { ITestService } from 'vscode/vscode/vs/workbench/contrib/testing/common/testService';
11
+ import { applyTestItemUpdate } from 'vscode/vscode/vs/workbench/contrib/testing/common/testTypes';
12
+
13
+ const computedStateAccessor = {
14
+ getOwnState: i => i instanceof TestItemTreeElement ? i.ownState : 0 ,
15
+ getCurrentComputedState: i => i.state,
16
+ setComputedState: (i, s) => i.state = s,
17
+ getCurrentComputedDuration: i => i.duration,
18
+ getOwnDuration: i => i instanceof TestItemTreeElement ? i.ownDuration : undefined,
19
+ setComputedDuration: (i, d) => i.duration = d,
20
+ getChildren: i => Iterable.filter(( i.children.values()), (t) => t instanceof TreeTestItemElement),
21
+ *getParents(i) {
22
+ for (let parent = i.parent; parent; parent = parent.parent) {
23
+ yield parent;
24
+ }
25
+ },
26
+ };
27
+ class TreeTestItemElement extends TestItemTreeElement {
28
+ get description() {
29
+ return this.test.item.description;
30
+ }
31
+ constructor(test, parent, addedOrRemoved) {
32
+ super({ ...test, item: { ...test.item } }, parent);
33
+ this.addedOrRemoved = addedOrRemoved;
34
+ this.ownState = 0 ;
35
+ this.updateErrorVisibility();
36
+ }
37
+ update(patch) {
38
+ applyTestItemUpdate(this.test, patch);
39
+ this.updateErrorVisibility(patch);
40
+ this.fireChange();
41
+ }
42
+ fireChange() {
43
+ this.changeEmitter.fire();
44
+ }
45
+ updateErrorVisibility(patch) {
46
+ if (this.errorChild && (!this.test.item.error || patch?.item?.error)) {
47
+ this.addedOrRemoved(this);
48
+ this.children.delete(this.errorChild);
49
+ this.errorChild = undefined;
50
+ }
51
+ if (this.test.item.error && !this.errorChild) {
52
+ this.errorChild = ( new TestTreeErrorMessage(this.test.item.error, this));
53
+ this.children.add(this.errorChild);
54
+ this.addedOrRemoved(this);
55
+ }
56
+ }
57
+ }
58
+ let TreeProjection = class TreeProjection extends Disposable {
59
+ get rootsWithChildren() {
60
+ const rootsIt = ( Iterable.map(this.testService.collection.rootItems, r => this.items.get(r.item.extId)));
61
+ return Iterable.filter(rootsIt, (r) => !!r?.children.size);
62
+ }
63
+ constructor(lastState, testService, results) {
64
+ super();
65
+ this.lastState = lastState;
66
+ this.testService = testService;
67
+ this.results = results;
68
+ this.updateEmitter = ( new Emitter());
69
+ this.changedParents = ( new Set());
70
+ this.resortedParents = ( new Set());
71
+ this.items = ( new Map());
72
+ this.onUpdate = this.updateEmitter.event;
73
+ this._register(testService.onDidProcessDiff((diff) => this.applyDiff(diff)));
74
+ this._register(results.onResultsChanged((evt) => {
75
+ if (!('removed' in evt)) {
76
+ return;
77
+ }
78
+ for (const inTree of [...( this.items.values())].sort((a, b) => b.depth - a.depth)) {
79
+ const lookup = this.results.getStateById(inTree.test.item.extId)?.[1];
80
+ inTree.ownDuration = lookup?.ownDuration;
81
+ refreshComputedState(computedStateAccessor, inTree, lookup?.ownComputedState ?? 0 ).forEach(i => i.fireChange());
82
+ }
83
+ }));
84
+ this._register(results.onTestChanged(ev => {
85
+ if (ev.reason === 2 ) {
86
+ return;
87
+ }
88
+ let result = ev.item;
89
+ if (result.ownComputedState === 0 || ev.result !== results.results[0]) {
90
+ const fallback = results.getStateById(result.item.extId);
91
+ if (fallback) {
92
+ result = fallback[1];
93
+ }
94
+ }
95
+ const item = this.items.get(result.item.extId);
96
+ if (!item) {
97
+ return;
98
+ }
99
+ const refreshDuration = ev.reason === 1 && ev.previousOwnDuration !== result.ownDuration;
100
+ const explicitComputed = item.children.size ? undefined : result.computedState;
101
+ item.retired = !!result.retired;
102
+ item.ownState = result.ownComputedState;
103
+ item.ownDuration = result.ownDuration;
104
+ item.fireChange();
105
+ refreshComputedState(computedStateAccessor, item, explicitComputed, refreshDuration).forEach(i => i.fireChange());
106
+ }));
107
+ for (const test of testService.collection.all) {
108
+ this.storeItem(this.createItem(test));
109
+ }
110
+ }
111
+ getElementByTestId(testId) {
112
+ return this.items.get(testId);
113
+ }
114
+ applyDiff(diff) {
115
+ for (const op of diff) {
116
+ switch (op.op) {
117
+ case 0 : {
118
+ const item = this.createItem(op.item);
119
+ this.storeItem(item);
120
+ break;
121
+ }
122
+ case 1 : {
123
+ const patch = op.item;
124
+ const existing = this.items.get(patch.extId);
125
+ if (!existing) {
126
+ break;
127
+ }
128
+ const needsParentUpdate = existing.test.expand === 0 && patch.expand;
129
+ existing.update(patch);
130
+ if (needsParentUpdate) {
131
+ this.changedParents.add(existing.parent);
132
+ }
133
+ else {
134
+ this.resortedParents.add(existing.parent);
135
+ }
136
+ break;
137
+ }
138
+ case 3 : {
139
+ const toRemove = this.items.get(op.itemId);
140
+ if (!toRemove) {
141
+ break;
142
+ }
143
+ const affectsRootElement = toRemove.depth === 1 && toRemove.parent?.children.size === 1;
144
+ this.changedParents.add(affectsRootElement ? null : toRemove.parent);
145
+ const queue = [[toRemove]];
146
+ while (queue.length) {
147
+ for (const item of queue.pop()) {
148
+ if (item instanceof TreeTestItemElement) {
149
+ queue.push(this.unstoreItem(item));
150
+ }
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+ if (diff.length !== 0) {
157
+ this.updateEmitter.fire();
158
+ }
159
+ }
160
+ applyTo(tree) {
161
+ for (const s of [this.changedParents, this.resortedParents]) {
162
+ for (const element of s) {
163
+ if (element && !tree.hasElement(element)) {
164
+ s.delete(element);
165
+ }
166
+ }
167
+ }
168
+ for (const parent of this.changedParents) {
169
+ tree.setChildren(parent, getChildrenForParent(this.lastState, this.rootsWithChildren, parent), { diffIdentityProvider: testIdentityProvider });
170
+ }
171
+ for (const parent of this.resortedParents) {
172
+ tree.resort(parent, false);
173
+ }
174
+ }
175
+ expandElement(element, depth) {
176
+ if (!(element instanceof TreeTestItemElement)) {
177
+ return;
178
+ }
179
+ if (element.test.expand === 0 ) {
180
+ return;
181
+ }
182
+ this.testService.collection.expand(element.test.item.extId, depth);
183
+ }
184
+ createItem(item) {
185
+ const parentId = TestId.parentId(item.item.extId);
186
+ const parent = parentId ? this.items.get(parentId) : null;
187
+ return ( new TreeTestItemElement(item, parent, n => this.changedParents.add(n)));
188
+ }
189
+ unstoreItem(treeElement) {
190
+ const parent = treeElement.parent;
191
+ parent?.children.delete(treeElement);
192
+ this.items.delete(treeElement.test.item.extId);
193
+ if (parent instanceof TreeTestItemElement) {
194
+ refreshComputedState(computedStateAccessor, parent, undefined, !!treeElement.duration).forEach(i => i.fireChange());
195
+ }
196
+ return treeElement.children;
197
+ }
198
+ storeItem(treeElement) {
199
+ treeElement.parent?.children.add(treeElement);
200
+ this.items.set(treeElement.test.item.extId, treeElement);
201
+ const affectsRootElement = treeElement.depth === 1 && treeElement.parent?.children.size === 1;
202
+ this.changedParents.add(affectsRootElement ? null : treeElement.parent);
203
+ if (treeElement.depth === 0 || isCollapsedInSerializedTestTree(this.lastState, treeElement.test.item.extId) === false) {
204
+ this.expandElement(treeElement, 0);
205
+ }
206
+ const prevState = this.results.getStateById(treeElement.test.item.extId)?.[1];
207
+ if (prevState) {
208
+ treeElement.retired = !!prevState.retired;
209
+ treeElement.ownState = prevState.computedState;
210
+ treeElement.ownDuration = prevState.ownDuration;
211
+ refreshComputedState(computedStateAccessor, treeElement, undefined, !!treeElement.ownDuration).forEach(i => i.fireChange());
212
+ }
213
+ }
214
+ };
215
+ TreeProjection = ( __decorate([
216
+ ( __param(1, ITestService)),
217
+ ( __param(2, ITestResultService))
218
+ ], TreeProjection));
219
+
220
+ export { TreeProjection };