codecharta-visualization 1.88.0 → 1.89.0

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 (124) hide show
  1. package/app/app.module.ts +20 -10
  2. package/app/codeCharta/codeCharta.component.html +0 -2
  3. package/app/codeCharta/codeCharta.model.ts +1 -0
  4. package/app/codeCharta/services/ajs-upgraded-providers.ts +13 -0
  5. package/app/codeCharta/state/angular-redux/effects/createEffect.spec.ts +37 -0
  6. package/app/codeCharta/state/angular-redux/effects/createEffect.ts +25 -0
  7. package/app/codeCharta/state/angular-redux/effects/effects.module.ts +36 -0
  8. package/app/codeCharta/state/angular-redux/ofType.ts +11 -0
  9. package/app/codeCharta/state/angular-redux/state.ts +12 -0
  10. package/app/codeCharta/state/angular-redux/store.ts +1 -1
  11. package/app/codeCharta/state/effects/addBlacklistItemsIfNotResultsInEmptyMap/addBlacklistItemsIfNotResultsInEmptyMap.effect.spec.ts +60 -0
  12. package/app/codeCharta/state/effects/addBlacklistItemsIfNotResultsInEmptyMap/addBlacklistItemsIfNotResultsInEmptyMap.effect.ts +56 -0
  13. package/app/codeCharta/state/effects/addBlacklistItemsIfNotResultsInEmptyMap/resultsInEmptyMap.ts +22 -0
  14. package/app/codeCharta/state/effects/nodeContextMenu/excludeButton/excludeButton.component.html +3 -0
  15. package/app/codeCharta/state/effects/nodeContextMenu/excludeButton/excludeButton.component.ts +26 -0
  16. package/app/codeCharta/state/effects/nodeContextMenu/flattenButtons/flattenButtons.component.html +13 -0
  17. package/app/codeCharta/state/effects/nodeContextMenu/flattenButtons/flattenButtons.component.spec.ts +55 -0
  18. package/app/codeCharta/state/effects/nodeContextMenu/flattenButtons/flattenButtons.component.ts +34 -0
  19. package/app/codeCharta/state/effects/nodeContextMenu/flattenButtons/flattenButtons.module.ts +11 -0
  20. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/focusButtons/focusButtons.component.html +0 -0
  21. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/focusButtons/focusButtons.component.spec.ts +2 -2
  22. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/focusButtons/focusButtons.component.ts +5 -5
  23. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/focusButtons/focusButtons.module.ts +1 -1
  24. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/focusButtons/isNodeFocused.pipe.spec.ts +0 -0
  25. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/focusButtons/isNodeFocused.pipe.ts +2 -2
  26. package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.component.html +6 -0
  27. package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.component.spec.ts +64 -0
  28. package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.component.ts +39 -0
  29. package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.module.ts +11 -0
  30. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/markFolderRow/markFolderRow.component.html +3 -3
  31. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/markFolderRow/markFolderRow.component.scss +0 -0
  32. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/markFolderRow/markFolderRow.component.spec.ts +2 -2
  33. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/markFolderRow/markFolderRow.component.ts +6 -6
  34. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/markFolderRow/markFolderRow.module.ts +1 -1
  35. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/markFolderRow/selectors/markFolderItems.selector.spec.ts +0 -0
  36. package/app/codeCharta/state/effects/nodeContextMenu/markFolderRow/selectors/markFolderItems.selector.ts +29 -0
  37. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/nodeContextMenu.e2e.ts +4 -16
  38. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/nodeContextMenu.po.ts +1 -1
  39. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenu.service.spec.ts +78 -0
  40. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenu.service.ts +72 -0
  41. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/lastPartOfNodePath.pipe.spec.ts +11 -0
  42. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/lastPartOfNodePath.pipe.ts +8 -0
  43. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.component.html +17 -0
  44. package/app/codeCharta/{ui/nodeContextMenu/nodeContextMenu.component.scss → state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.component.scss} +6 -11
  45. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.component.spec.ts +49 -0
  46. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.component.ts +19 -0
  47. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.module.ts +18 -0
  48. package/app/codeCharta/state/effects/nodeContextMenu/openNodeContextMenu.effect.spec.ts +32 -0
  49. package/app/codeCharta/state/effects/nodeContextMenu/openNodeContextMenu.effect.ts +33 -0
  50. package/app/codeCharta/state/effects/nodeContextMenu/rightClickedCodeMapNode.selector.ts +8 -0
  51. package/app/codeCharta/state/effects/unfocusNodesOnLoadingMap.effect.spec.ts +47 -0
  52. package/app/codeCharta/state/effects/unfocusNodesOnLoadingMap.effect.ts +18 -0
  53. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/areAllNecessaryRenderDataAvailable.selector.ts +30 -0
  54. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/utils/areDynamicSettingsAvailable.spec.ts +36 -0
  55. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/utils/areDynamicSettingsAvailable.ts +10 -0
  56. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/utils/areMetricsAvailable.spec.ts +13 -0
  57. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/utils/areMetricsAvailable.ts +8 -0
  58. package/app/codeCharta/state/store/appSettings/appSettings.actions.ts +2 -0
  59. package/app/codeCharta/state/store/appSettings/appSettings.reducer.ts +2 -0
  60. package/app/codeCharta/state/store/appSettings/invertArea/invertArea.actions.ts +32 -0
  61. package/app/codeCharta/state/store/appSettings/invertArea/invertArea.reducer.spec.ts +26 -0
  62. package/app/codeCharta/state/store/appSettings/invertArea/invertArea.reducer.ts +12 -0
  63. package/app/codeCharta/state/store/appSettings/invertArea/invertArea.selector.ts +3 -0
  64. package/app/codeCharta/state/store/appSettings/isLoadingMap/isLoadingMap.reducer.spec.ts +14 -3
  65. package/app/codeCharta/state/store/appSettings/isLoadingMap/isLoadingMap.reducer.ts +41 -6
  66. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.actions.ts +33 -2
  67. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.reducer.spec.ts +17 -1
  68. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.reducer.ts +3 -1
  69. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.service.spec.ts +1 -19
  70. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.service.ts +5 -28
  71. package/app/codeCharta/state/store/lookUp/idToNode/idToNode.selector.ts +4 -0
  72. package/app/codeCharta/state/store/lookUp/lookUp.selector.ts +3 -0
  73. package/app/codeCharta/state/store/metricData/nodeMetricData/nodeMetricData.service.ts +0 -4
  74. package/app/codeCharta/state/store/store.ts +5 -1
  75. package/app/codeCharta/state/store.service.spec.ts +20 -7
  76. package/app/codeCharta/state/store.service.ts +3 -36
  77. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.component.html +3 -1
  78. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.component.scss +6 -2
  79. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.component.ts +1 -1
  80. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.module.ts +3 -0
  81. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.po.ts +4 -4
  82. package/app/codeCharta/ui/areaSettingsPanel/invertAreaOption/invertAreaOption.component.html +1 -0
  83. package/app/codeCharta/ui/areaSettingsPanel/invertAreaOption/invertAreaOption.component.scss +26 -0
  84. package/app/codeCharta/ui/areaSettingsPanel/invertAreaOption/invertAreaOption.component.spec.ts +29 -0
  85. package/app/codeCharta/ui/areaSettingsPanel/invertAreaOption/invertAreaOption.component.ts +24 -0
  86. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/aggregationType.pipe.spec.ts +19 -0
  87. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/{aggregationSymbol.pipe.ts → aggregationType.pipe.ts} +4 -4
  88. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/attributeTypeSelector.component.html +4 -12
  89. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/attributeTypeSelector.component.scss +11 -20
  90. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/attributeTypeSelector.component.spec.ts +8 -15
  91. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/attributeTypeSelector.module.ts +2 -2
  92. package/app/codeCharta/ui/codeMap/codeMap.preRender.service.spec.ts +1 -9
  93. package/app/codeCharta/ui/codeMap/codeMap.preRender.service.ts +9 -32
  94. package/app/codeCharta/ui/dialogs/dialogs.ts +3 -0
  95. package/app/codeCharta/ui/dialogs/errorDialog/errorDialog.component.html +7 -0
  96. package/app/codeCharta/ui/dialogs/errorDialog/errorDialog.component.ts +9 -0
  97. package/app/codeCharta/ui/mapTreeView/mapTreeView.level.e2e.ts +1 -1
  98. package/app/codeCharta/ui/mapTreeView/mapTreeView.level.po.ts +1 -1
  99. package/app/codeCharta/ui/ribbonBar/ribbonBar.component.html +2 -2
  100. package/app/codeCharta/ui/ribbonBar/ribbonBar.e2e.ts +3 -3
  101. package/app/codeCharta/ui/searchBar/searchBar.component.html +5 -0
  102. package/app/codeCharta/ui/searchBar/searchBar.component.scss +11 -0
  103. package/app/codeCharta/ui/searchBar/searchBar.component.spec.ts +10 -0
  104. package/app/codeCharta/ui/searchBar/searchBar.component.ts +1 -1
  105. package/app/codeCharta/ui/sortingOption/sortingOption.component.spec.ts +1 -1
  106. package/app/codeCharta/ui/ui.ts +0 -2
  107. package/app/codeCharta/util/algorithm/treeMapLayout/treeMapGenerator.spec.ts +1 -1
  108. package/app/codeCharta/util/algorithm/treeMapLayout/treeMapGenerator.ts +14 -7
  109. package/app/codeCharta/util/customConfigBuilder.ts +1 -0
  110. package/app/codeCharta/util/dataMocks.ts +2 -0
  111. package/app/codeCharta/util/reduxHelper.ts +11 -0
  112. package/app/material/material.module.ts +17 -1
  113. package/conf/webpack.loaders.js +4 -1
  114. package/dist/webpack/bundle.js +4582 -950
  115. package/dist/webpack/bundle.js.map +1 -1
  116. package/package.json +2 -2
  117. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/aggregationSymbol.pipe.spec.ts +0 -19
  118. package/app/codeCharta/ui/nodeContextMenu/markFolderRow/selectors/markFolderItems.selector.ts +0 -29
  119. package/app/codeCharta/ui/nodeContextMenu/markFolderRow/selectors/rightClickedNode.selector.spec.ts +0 -15
  120. package/app/codeCharta/ui/nodeContextMenu/markFolderRow/selectors/rightClickedNode.selector.ts +0 -9
  121. package/app/codeCharta/ui/nodeContextMenu/nodeContextMenu.component.html +0 -45
  122. package/app/codeCharta/ui/nodeContextMenu/nodeContextMenu.component.spec.ts +0 -365
  123. package/app/codeCharta/ui/nodeContextMenu/nodeContextMenu.component.ts +0 -198
  124. package/app/codeCharta/ui/nodeContextMenu/nodeContextMenu.module.ts +0 -15
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/MaibornWolff/codecharta.git"
11
11
  },
12
12
  "name": "codecharta-visualization",
13
- "version": "1.88.0",
13
+ "version": "1.89.0",
14
14
  "engines": {
15
15
  "node": ">=16"
16
16
  },
@@ -171,7 +171,7 @@
171
171
  "eslint-config-prettier": "^8.2.0",
172
172
  "eslint-plugin-unicorn": "^40.0.0",
173
173
  "file-loader": "^6.2.0",
174
- "html-loader": "^1.1.0",
174
+ "html-loader": "^3.0.0",
175
175
  "html-loader-jest": "^0.2.1",
176
176
  "html-webpack-plugin": "^5.3.1",
177
177
  "jest": "^26.6.3",
@@ -1,19 +0,0 @@
1
- import { AttributeTypeValue } from "../../../codeCharta.model"
2
- import { AggregationSymbolPipe } from "./aggregationSymbol.pipe"
3
-
4
- describe("aggregationSymbolPipe", () => {
5
- it("should map `AttributeTypeValue.relative` to x͂", () => {
6
- const getAttributeTypeOfNodesByMetricSelector = () => AttributeTypeValue.relative
7
- expect(new AggregationSymbolPipe().transform("some-metric-name", getAttributeTypeOfNodesByMetricSelector)).toBe("x͂")
8
- })
9
-
10
- it("should map `AttributeTypeValue.absolute` to Σ", () => {
11
- const getAttributeTypeOfNodesByMetricSelector = () => AttributeTypeValue.absolute
12
- expect(new AggregationSymbolPipe().transform("some-metric-name", getAttributeTypeOfNodesByMetricSelector)).toBe("Σ")
13
- })
14
-
15
- it("should default to Σ", () => {
16
- const getAttributeTypeOfNodesByMetricSelector = () => "" as AttributeTypeValue
17
- expect(new AggregationSymbolPipe().transform("some-metric-name", getAttributeTypeOfNodesByMetricSelector)).toBe("Σ")
18
- })
19
- })
@@ -1,29 +0,0 @@
1
- import { MarkedPackage, Node } from "../../../../codeCharta.model"
2
- import { createSelector } from "../../../../state/angular-redux/createSelector"
3
- import { mapColorsSelector } from "../../../../state/store/appSettings/mapColors/mapColors.selector"
4
- import { markedPackagesSelector } from "../../../../state/store/fileSettings/markedPackages/markedPackages.selector"
5
- import { findIndexOfMarkedPackageOrParent } from "../../../../state/store/fileSettings/markedPackages/util/findIndexOfMarkedPackageOrParent"
6
- import { CcState } from "../../../../state/store/store"
7
- import { rightClickedNodeSelector } from "./rightClickedNode.selector"
8
-
9
- export type MarkFolderItem = {
10
- color: string
11
- isMarked: boolean
12
- }
13
-
14
- const markingColorsSelector = createSelector([mapColorsSelector], mapColors => mapColors.markingColors)
15
-
16
- export const _getMarkFolderItems = (node: Pick<Node, "path">, markingColors: string[], markedPackages: MarkedPackage[]) => {
17
- if (node === null) return markingColors.map(color => ({ color, isMarked: false }))
18
-
19
- const nodeIndexWithinMarkedPackages = findIndexOfMarkedPackageOrParent(markedPackages, node.path)
20
- return markingColors.map(color => ({
21
- color,
22
- isMarked: nodeIndexWithinMarkedPackages !== -1 && color === markedPackages[nodeIndexWithinMarkedPackages].color
23
- }))
24
- }
25
-
26
- export const markFolderItemsSelector: (state: CcState) => MarkFolderItem[] = createSelector(
27
- [rightClickedNodeSelector, markingColorsSelector, markedPackagesSelector],
28
- _getMarkFolderItems
29
- )
@@ -1,15 +0,0 @@
1
- import { CodeMapBuilding } from "../../../codeMap/rendering/codeMapBuilding"
2
- import { _getNode } from "./rightClickedNode.selector"
3
-
4
- describe("rightClickedNodeSelector's _getNode", () => {
5
- it("should return null when no building was right clicked on", () => {
6
- expect(_getNode(new Map(), null)).toBe(null)
7
- })
8
-
9
- it("should return node", () => {
10
- const node = { id: 1 }
11
- const codeMapBuilding = { node } as CodeMapBuilding
12
- const idToBuilding = new Map([[1, codeMapBuilding]])
13
- expect(_getNode(idToBuilding, { nodeId: 1 })).toBe(node)
14
- })
15
- })
@@ -1,9 +0,0 @@
1
- import { createSelector } from "../../../../state/angular-redux/createSelector"
2
- import { rightClickedNodeDataSelector } from "../../../../state/store/appStatus/rightClickedNodeData/rightClickedNodeData.selector"
3
- import { idToBuildingSelector } from "../../../../state/store/lookUp/idToBuilding/idToBuilding.selector"
4
- import { CodeMapBuilding } from "../../../codeMap/rendering/codeMapBuilding"
5
-
6
- export const _getNode = (idToBuilding: Map<number, CodeMapBuilding>, rightClickedNodeData: { nodeId: number }) =>
7
- rightClickedNodeData !== null ? idToBuilding.get(rightClickedNodeData.nodeId).node : null
8
-
9
- export const rightClickedNodeSelector = createSelector([idToBuildingSelector, rightClickedNodeDataSelector], _getNode)
@@ -1,45 +0,0 @@
1
- <md-card id="codemap-context-menu" ng-show="$ctrl.rightClickedNodeData !== null">
2
- <div ng-if="$ctrl.nodeIsFolder()">
3
- <cc-mark-folder-row></cc-mark-folder-row>
4
- <md-divider></md-divider>
5
- </div>
6
-
7
- <div class="button-group">
8
- <md-button ng-disabled="true" title="{{ $ctrl._viewModel.nodePath }}">
9
- {{ $ctrl._viewModel.lastPartOfNodePath }}
10
- </md-button>
11
-
12
- <cc-focus-buttons [code-map-node]="$ctrl._viewModel.codeMapNode"></cc-focus-buttons>
13
- <md-button
14
- ng-if="!$ctrl._viewModel.codeMapNode.isFlattened"
15
- ng-click="$ctrl.flattenNode()"
16
- id="flatten-button"
17
- title="Flatten node and children-nodes, but keep an empty space"
18
- >
19
- <img alt="flattenIcon" class="png-icon" src="../../../assets/flatten.png" style="width: 17px; height: 17px" />
20
- Flatten
21
- </md-button>
22
- <md-button
23
- ng-if="$ctrl._viewModel.codeMapNode.isFlattened"
24
- ng-click="$ctrl.showFlattenedNode()"
25
- title="Show node and children-nodes"
26
- ><img alt="flattenIcon" class="png-icon" src="../../../assets/flatten.png" style="width: 17px; height: 17px" /> Show</md-button
27
- >
28
- <md-button
29
- ng-if="!$ctrl.isNodeConstantlyHighlighted()"
30
- title="Highlight node constantly"
31
- ng-click="$ctrl.addNodeToConstantHighlight()"
32
- ><i class="fa fa-cubes"></i> Keep Highlight</md-button
33
- >
34
- <md-button
35
- ng-if="$ctrl.isNodeConstantlyHighlighted()"
36
- title="Remove constant highlight"
37
- ng-click="$ctrl.removeNodeFromConstantHighlight()"
38
- ><i class="fa fa-cubes"></i> Remove Highlight</md-button
39
- >
40
-
41
- <md-button ng-click="$ctrl.excludeNode()" id="exclude-button" title="Exclude node and children-nodes and reorder the CodeMap"
42
- ><i class="fa fa-ban"></i> Exclude</md-button
43
- >
44
- </div>
45
- </md-card>
@@ -1,365 +0,0 @@
1
- import "./nodeContextMenu.module"
2
-
3
- import { IRootScopeService, IWindowService } from "angular"
4
- import { instantiateModule, getService } from "../../../../mocks/ng.mockhelper"
5
- import { NodeContextMenuController } from "./nodeContextMenu.component"
6
- import {
7
- CODE_MAP_BUILDING,
8
- CODE_MAP_BUILDING_TS_NODE,
9
- CONSTANT_HIGHLIGHT,
10
- TEST_DELTA_MAP_A,
11
- VALID_FILE_NODE_WITH_ID,
12
- VALID_NODE_WITH_PATH
13
- } from "../../util/dataMocks"
14
- import { CodeMapPreRenderService } from "../codeMap/codeMap.preRender.service"
15
- import { StoreService } from "../../state/store.service"
16
- import { BlacklistType, NodeType } from "../../codeCharta.model"
17
- import { addBlacklistItem } from "../../state/store/fileSettings/blacklist/blacklist.actions"
18
- import { NodeDecorator } from "../../util/nodeDecorator"
19
- import { ThreeSceneService } from "../codeMap/threeViewer/threeSceneService"
20
- import { CodeMapBuilding } from "../codeMap/rendering/codeMapBuilding"
21
- import { setIdToBuilding } from "../../state/store/lookUp/idToBuilding/idToBuilding.actions"
22
- import { DialogService } from "../dialog/dialog.service"
23
- import { BlacklistService } from "../../state/store/fileSettings/blacklist/blacklist.service"
24
-
25
- describe("nodeContextMenuController", () => {
26
- let element: Element
27
- let nodeContextMenuController: NodeContextMenuController
28
- let $window: IWindowService
29
- let $rootScope: IRootScopeService
30
- let storeService: StoreService
31
- let codeMapPreRenderService: CodeMapPreRenderService
32
- let threeSceneService: ThreeSceneService
33
- let dialogService: DialogService
34
- let blacklistService: BlacklistService
35
-
36
- beforeEach(() => {
37
- restartSystem()
38
- mockElement()
39
- mockWindow()
40
- withMockedCodeMapPreRenderService()
41
- withMockedThreeSceneService()
42
- rebuildController()
43
-
44
- NodeDecorator.decorateMapWithPathAttribute(TEST_DELTA_MAP_A)
45
- })
46
-
47
- function restartSystem() {
48
- instantiateModule("app.codeCharta.ui.nodeContextMenu")
49
-
50
- $window = getService<IWindowService>("$window")
51
- $rootScope = getService<IRootScopeService>("$rootScope")
52
- storeService = getService<StoreService>("storeService")
53
- codeMapPreRenderService = getService<CodeMapPreRenderService>("codeMapPreRenderService")
54
- threeSceneService = getService<ThreeSceneService>("threeSceneService")
55
- dialogService = getService<DialogService>("dialogService")
56
- blacklistService = getService<BlacklistService>("blacklistService")
57
- }
58
-
59
- function mockElement() {
60
- // @ts-ignore we only care about few properties for the test.
61
- element = [{ children: [{ clientWidth: 50, clientHeight: 100 }] }]
62
- }
63
-
64
- function mockWindow() {
65
- $window = { innerWidth: 800, innerHeight: 600 } as IWindowService
66
- }
67
-
68
- function rebuildController() {
69
- nodeContextMenuController = new NodeContextMenuController(
70
- element,
71
- $window,
72
- $rootScope,
73
- storeService,
74
- codeMapPreRenderService,
75
- threeSceneService,
76
- dialogService,
77
- blacklistService
78
- )
79
- }
80
-
81
- function withMockedCodeMapPreRenderService() {
82
- codeMapPreRenderService.getRenderMap = jest.fn().mockReturnValue(TEST_DELTA_MAP_A.map)
83
- }
84
-
85
- function withMockedThreeSceneService() {
86
- threeSceneService = jest.fn().mockReturnValue({
87
- addNodeAndChildrenToConstantHighlight: jest.fn(),
88
- removeNodeAndChildrenFromConstantHighlight: jest.fn(),
89
- getConstantHighlight: jest.fn().mockReturnValue(CONSTANT_HIGHLIGHT)
90
- })()
91
- }
92
-
93
- describe("onShowNodeContextMenu", () => {
94
- let mockedWheelTargetElement
95
- beforeEach(() => {
96
- nodeContextMenuController.setPosition = jest.fn()
97
- nodeContextMenuController.calculatePosition = jest.fn().mockReturnValue({ x: 1, y: 2 })
98
-
99
- document.body.addEventListener = jest.fn()
100
- mockedWheelTargetElement = { addEventListener: jest.fn(), removeEventListener: jest.fn() }
101
- // @ts-ignore
102
- jest.spyOn(document, "getElementById").mockImplementation(() => mockedWheelTargetElement)
103
- })
104
-
105
- it("should set the correct building after some timeout", () => {
106
- nodeContextMenuController.showNodeContextMenu("/root", NodeType.FOLDER, 42, 24)
107
-
108
- expect(nodeContextMenuController["_viewModel"].codeMapNode).toEqual(TEST_DELTA_MAP_A.map)
109
- expect(nodeContextMenuController.calculatePosition).toHaveBeenCalledWith(42, 24)
110
- expect(nodeContextMenuController.setPosition).toHaveBeenCalledTimes(1)
111
- expect(nodeContextMenuController.setPosition).toBeCalledWith(1, 2)
112
-
113
- expect(document.body.addEventListener).toHaveBeenNthCalledWith(1, "click", expect.anything(), expect.anything())
114
- expect(document.body.addEventListener).toHaveBeenNthCalledWith(2, "mousedown", expect.anything(), expect.anything())
115
-
116
- expect(document.getElementById).toHaveBeenCalledWith("codeMap")
117
- expect(mockedWheelTargetElement.addEventListener).toHaveBeenCalledWith("wheel", expect.anything(), expect.anything())
118
- })
119
-
120
- it("should not shorten the path if it has no sub paths", () => {
121
- nodeContextMenuController.showNodeContextMenu("/root", NodeType.FOLDER, 42, 24)
122
-
123
- expect(nodeContextMenuController["_viewModel"].nodePath).toEqual(TEST_DELTA_MAP_A.map.path)
124
- expect(nodeContextMenuController["_viewModel"].lastPartOfNodePath).toBe(TEST_DELTA_MAP_A.map.path)
125
- })
126
-
127
- it("should set the complete and shortened node path", () => {
128
- nodeContextMenuController.showNodeContextMenu("/root/big leaf", NodeType.FILE, 521, 588)
129
- const nodePath = TEST_DELTA_MAP_A.map.children[0].path
130
-
131
- expect(nodeContextMenuController["_viewModel"].nodePath).toEqual(nodePath)
132
- expect(nodeContextMenuController["_viewModel"].lastPartOfNodePath).toBe(`...${nodePath.slice(nodePath.lastIndexOf("/"))}`)
133
- })
134
-
135
- it("should remove all listener on hide", () => {
136
- const documentRemoveEventListenerSpy = jest.spyOn(document.body, "removeEventListener")
137
-
138
- nodeContextMenuController.hideNodeContextMenu()
139
-
140
- expect(documentRemoveEventListenerSpy).toHaveBeenCalledWith(
141
- "click",
142
- nodeContextMenuController.onBodyLeftClickHideNodeContextMenu,
143
- true
144
- )
145
- expect(documentRemoveEventListenerSpy).toHaveBeenCalledWith(
146
- "mousedown",
147
- nodeContextMenuController.onBodyRightClickHideNodeContextMenu,
148
- true
149
- )
150
- expect(mockedWheelTargetElement.removeEventListener).toHaveBeenCalledWith(
151
- "wheel",
152
- nodeContextMenuController.onMapWheelHideNodeContextMenu,
153
- true
154
- )
155
- })
156
- })
157
-
158
- describe("calculatePosition", () => {
159
- function testPositionCalculation(expectedX, expectedY, mouseX, mouseY) {
160
- const { x, y } = nodeContextMenuController.calculatePosition(mouseX, mouseY)
161
- expect(x).toBe(expectedX)
162
- expect(y).toBe(expectedY)
163
- }
164
-
165
- it("should calculate the position for the menu correctly, when it fits in the window", () => {
166
- testPositionCalculation(400, 300, 400, 300)
167
- })
168
-
169
- it("should calculate the position for the menu correctly, when it doesn't fit in the window.innerWidth", () => {
170
- testPositionCalculation(750, 300, 799, 300)
171
- })
172
-
173
- it("should calculate the position for the menu correctly, when it doesn't fit in the window.innerHeight", () => {
174
- testPositionCalculation(400, 500, 400, 599)
175
- })
176
-
177
- it("should calculate the position for the menu correctly, when it doesn't fit in the window.innerHeight and window.innerWidth", () => {
178
- testPositionCalculation(750, 500, 799, 599)
179
- })
180
- })
181
-
182
- describe("removeNodeFromConstantHighlight", () => {
183
- it("should call addNodeandChildrenToConstantHighlight", () => {
184
- nodeContextMenuController.addNodeToConstantHighlight()
185
-
186
- expect(threeSceneService.addNodeAndChildrenToConstantHighlight).toHaveBeenCalled()
187
- })
188
- })
189
-
190
- describe("addNodeToConstantHighlight", () => {
191
- it("should call addNodeandChildrenToConstantHighlight", () => {
192
- nodeContextMenuController.removeNodeFromConstantHighlight()
193
-
194
- expect(threeSceneService.removeNodeAndChildrenFromConstantHighlight).toHaveBeenCalled()
195
- })
196
- })
197
-
198
- describe("isNodeConstantlyHighlighted", () => {
199
- beforeEach(() => {
200
- const idToBuilding = new Map<number, CodeMapBuilding>()
201
- idToBuilding.set(CODE_MAP_BUILDING.id, CODE_MAP_BUILDING)
202
- idToBuilding.set(CODE_MAP_BUILDING_TS_NODE.id, CODE_MAP_BUILDING_TS_NODE)
203
- storeService.dispatch(setIdToBuilding(idToBuilding))
204
- })
205
- it("should return false if codeMapNode is not existing", () => {
206
- nodeContextMenuController["_viewModel"].codeMapNode = null
207
-
208
- const result = nodeContextMenuController.isNodeConstantlyHighlighted()
209
-
210
- expect(result).toEqual(false)
211
- })
212
-
213
- it("should return false if codeMapNode exists but is not in constant Highlight", () => {
214
- threeSceneService.getConstantHighlight = jest.fn().mockReturnValue(new Map())
215
- nodeContextMenuController["_viewModel"].codeMapNode = VALID_FILE_NODE_WITH_ID
216
-
217
- const result = nodeContextMenuController.isNodeConstantlyHighlighted()
218
-
219
- expect(threeSceneService.getConstantHighlight).toHaveBeenCalled()
220
- expect(result).toEqual(false)
221
- })
222
-
223
- it("should return true if codeMapNode exists and in constant Highlight", () => {
224
- nodeContextMenuController["_viewModel"].codeMapNode = VALID_FILE_NODE_WITH_ID
225
-
226
- const result = nodeContextMenuController.isNodeConstantlyHighlighted()
227
-
228
- expect(result).toEqual(true)
229
- })
230
- })
231
-
232
- describe("flattenNode", () => {
233
- it("should add flattened blacklistItem", () => {
234
- nodeContextMenuController["_viewModel"].codeMapNode = VALID_NODE_WITH_PATH.children[1]
235
- const expected = {
236
- nodeType: NodeType.FOLDER,
237
- path: "/root/Parent Leaf",
238
- type: BlacklistType.flatten
239
- }
240
- nodeContextMenuController.flattenNode()
241
-
242
- expect(storeService.getState().fileSettings.blacklist).toContainEqual(expected)
243
- })
244
- })
245
-
246
- describe("showNode", () => {
247
- it("should add flattened blacklistItem", () => {
248
- nodeContextMenuController["_viewModel"].codeMapNode = VALID_NODE_WITH_PATH.children[1]
249
- const expected = {
250
- path: "/root/Parent Leaf",
251
- type: BlacklistType.flatten
252
- }
253
- storeService.dispatch(addBlacklistItem(expected))
254
-
255
- nodeContextMenuController.showFlattenedNode()
256
-
257
- expect(storeService.getState().fileSettings.blacklist).not.toContain(expected)
258
- })
259
- })
260
-
261
- describe("excludeNode", () => {
262
- beforeEach(() => {
263
- nodeContextMenuController["_viewModel"].codeMapNode = VALID_NODE_WITH_PATH.children[1]
264
- })
265
-
266
- it("should add exclude blacklistItem", () => {
267
- blacklistService.resultsInEmptyMap = jest.fn(() => false)
268
- const expected = { nodeType: "Folder", path: "/root/Parent Leaf", type: BlacklistType.exclude }
269
-
270
- nodeContextMenuController.excludeNode()
271
-
272
- expect(storeService.getState().fileSettings.blacklist).toContainEqual(expected)
273
- })
274
-
275
- it("should display error dialog when no files are left", () => {
276
- blacklistService.resultsInEmptyMap = jest.fn(() => true)
277
- dialogService.showErrorDialog = jest.fn()
278
-
279
- nodeContextMenuController.excludeNode()
280
-
281
- expect(dialogService.showErrorDialog).toBeCalled()
282
- })
283
-
284
- it("should prevent duplicate blacklist object regarding issue #2419", () => {
285
- blacklistService.resultsInEmptyMap = jest.fn(() => false)
286
-
287
- nodeContextMenuController.excludeNode()
288
- nodeContextMenuController.excludeNode()
289
-
290
- expect(storeService.getState().fileSettings.blacklist.length).toEqual(1)
291
- })
292
- })
293
-
294
- describe("nodeIsFolder", () => {
295
- it("should return true, if contextMenuBuilding is a folder", () => {
296
- nodeContextMenuController["_viewModel"].codeMapNode = VALID_NODE_WITH_PATH
297
- const result = nodeContextMenuController.nodeIsFolder()
298
-
299
- expect(result).toBeTruthy()
300
- })
301
-
302
- it("should return false, if contextMenuBuilding is null", () => {
303
- nodeContextMenuController["_viewModel"].codeMapNode = null
304
- const result = nodeContextMenuController.nodeIsFolder()
305
-
306
- expect(result).toBeFalsy()
307
- })
308
-
309
- it("should return false, if contextMenuBuilding is undefined", () => {
310
- nodeContextMenuController["_viewModel"].codeMapNode = undefined
311
- const result = nodeContextMenuController.nodeIsFolder()
312
-
313
- expect(result).toBeFalsy()
314
- })
315
-
316
- it("should return false, if contextMenuBuilding has no children property", () => {
317
- nodeContextMenuController["_viewModel"].codeMapNode = VALID_NODE_WITH_PATH.children[0]
318
- const result = nodeContextMenuController.nodeIsFolder()
319
-
320
- expect(result).toBeFalsy()
321
- })
322
-
323
- it("should return false, if contextMenuBuilding has children property but no children", () => {
324
- const VALID_NODE_WITHOUT_CHILDREN = VALID_NODE_WITH_PATH
325
- VALID_NODE_WITHOUT_CHILDREN.children[0].children = []
326
-
327
- nodeContextMenuController["_viewModel"].codeMapNode = VALID_NODE_WITHOUT_CHILDREN[0]
328
- const result = nodeContextMenuController.nodeIsFolder()
329
-
330
- expect(result).toBeFalsy()
331
- })
332
- })
333
-
334
- describe("onBodyLeftClickHideNodeContextMenu", () => {
335
- it("should not hide if a click on color-picker tricker occurs", () => {
336
- const broadcastHideEventSpy = jest.spyOn(nodeContextMenuController, "hideNodeContextMenu")
337
- const mockedMouseEvent: any = {
338
- composedPath: () => [{ nodeName: "CC-COLOR-PICKER" }]
339
- }
340
- nodeContextMenuController.onBodyLeftClickHideNodeContextMenu(mockedMouseEvent)
341
-
342
- expect(broadcastHideEventSpy).not.toHaveBeenCalled()
343
- })
344
-
345
- it("should not hide if a click within color-picker occurs", () => {
346
- const broadcastHideEventSpy = jest.spyOn(nodeContextMenuController, "hideNodeContextMenu")
347
- const mockedMouseEvent: any = {
348
- composedPath: () => [{ nodeName: "COLOR-CHROME" }]
349
- }
350
- nodeContextMenuController.onBodyLeftClickHideNodeContextMenu(mockedMouseEvent)
351
-
352
- expect(broadcastHideEventSpy).not.toHaveBeenCalled()
353
- })
354
-
355
- it("should hide if clicked somewhere but not within the color-picker", () => {
356
- const broadcastHideEventSpy = jest.spyOn(nodeContextMenuController, "hideNodeContextMenu")
357
- const mockedMouseEvent: any = {
358
- composedPath: () => [{ nodeName: "DIV" }]
359
- }
360
- nodeContextMenuController.onBodyLeftClickHideNodeContextMenu(mockedMouseEvent)
361
-
362
- expect(broadcastHideEventSpy).toHaveBeenCalled()
363
- })
364
- })
365
- })