This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch 3112-opc-ua-multi-node-selection-editor
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/3112-opc-ua-multi-node-selection-editor by this push:
new af4ae1ff5c feat(#3112):Ensure switch between Tree and text view works
as expected
af4ae1ff5c is described below
commit af4ae1ff5c0071a61465234f157d84df33183d0b
Author: Philipp Zehnder <[email protected]>
AuthorDate: Tue Aug 13 11:02:07 2024 +0200
feat(#3112):Ensure switch between Tree and text view works as expected
---
.../utils/userInput/TreeStaticPropertyUtils.ts | 43 +++++++++++++++++++++-
.../connect/opcua/opcAdapterConfiguration.spec.ts | 20 ++++++++++
...atic-runtime-resolvable-tree-input.component.ts | 4 ++
.../static-tree-input-button-menu.component.html | 2 +
.../static-tree-input-text-editor.component.ts | 9 ++++-
5 files changed, 74 insertions(+), 4 deletions(-)
diff --git a/ui/cypress/support/utils/userInput/TreeStaticPropertyUtils.ts
b/ui/cypress/support/utils/userInput/TreeStaticPropertyUtils.ts
index b632426fc7..ee98177d66 100644
--- a/ui/cypress/support/utils/userInput/TreeStaticPropertyUtils.ts
+++ b/ui/cypress/support/utils/userInput/TreeStaticPropertyUtils.ts
@@ -40,6 +40,13 @@ export class TreeStaticPropertyUtils {
cy.dataCy('opc-ua-editor-mode-text').click();
}
+ /**
+ * Opens the tree editor
+ */
+ public static switchToTreeEditor() {
+ cy.dataCy('opc-ua-editor-mode-tree').click();
+ }
+
/**
* Appends the @param text to the text editor
*/
@@ -47,6 +54,16 @@ export class TreeStaticPropertyUtils {
cy.dataCy('static-tree-input-text-editor').type(text);
}
+ /**
+ * Returns the content of the text editor
+ */
+ public static getTextInTextEditor() {
+ return cy
+ .dataCy('static-tree-input-text-editor')
+ .find('.CodeMirror-line')
+ .invoke('text');
+ }
+
/**
* Selects the @param treeNode in the tree view. If the tree node has
* children, it will expand the tree node and recursivly navigate through
@@ -56,12 +73,12 @@ export class TreeStaticPropertyUtils {
if (!treeNode.isTextConfig) {
// configure tree node
if (treeNode.children && treeNode.children.length > 0) {
- cy.dataCy('expand-' + treeNode.name).click();
+ TreeStaticPropertyUtils.expandNode(treeNode.name);
treeNode.children.forEach(child => {
this.selectTreeNode(child);
});
} else {
- cy.dataCy('select-' + treeNode.name).click();
+ TreeStaticPropertyUtils.selectNode(treeNode.name);
}
} else {
TreeStaticPropertyUtils.switchToTextEditor();
@@ -69,6 +86,20 @@ export class TreeStaticPropertyUtils {
}
}
+ /**
+ * Expand the node with @param treeNodeName in the tree view
+ */
+ public static expandNode(treeNodeName: string) {
+ cy.dataCy('expand-' + treeNodeName).click();
+ }
+
+ /**
+ * Select the node with @param treeNodeName in the tree view
+ */
+ public static selectNode(treeNodeName: string) {
+ cy.dataCy('select-' + treeNodeName).click();
+ }
+
/**
* Removes the selected node with the identifier @param nodeIdentifier.
* dataCy could not be used because often special characters are used in
@@ -89,6 +120,14 @@ export class TreeStaticPropertyUtils {
);
}
+ /**
+ * Validates that the amount of nodes shown in the browse tab are equal
+ * to @param expectedAmount.
+ */
+ public static validateAmountOfShownBrowseNodes(expectedAmount: number) {
+ cy.dataCy('expand-', {}, true).should('have.length', expectedAmount);
+ }
+
/**
* Validates the number of node details metadata rows displayed.
*/
diff --git a/ui/cypress/tests/connect/opcua/opcAdapterConfiguration.spec.ts
b/ui/cypress/tests/connect/opcua/opcAdapterConfiguration.spec.ts
index a4786842cd..d6578b247e 100644
--- a/ui/cypress/tests/connect/opcua/opcAdapterConfiguration.spec.ts
+++ b/ui/cypress/tests/connect/opcua/opcAdapterConfiguration.spec.ts
@@ -102,6 +102,26 @@ describe('Test OPC-UA Adapter Configuration', () => {
TreeStaticPropertyUtils.textEditor().should('be.visible');
TreeStaticPropertyUtils.typeInTextEditor('ns=3;s=StepUp');
+
+ // Go back to tree editor and validate nodes are selected and browse
editor works
+ TreeStaticPropertyUtils.switchToTreeEditor();
+ TreeStaticPropertyUtils.validateAmountOfSelectedNodes(1);
+ TreeStaticPropertyUtils.validateAmountOfShownBrowseNodes(3);
+
+ // Check if node is selected
+ TreeStaticPropertyUtils.expandNode('Objects');
+ TreeStaticPropertyUtils.expandNode('OpcPlc');
+ TreeStaticPropertyUtils.expandNode('Telemetry');
+ TreeStaticPropertyUtils.expandNode('Basic');
+ TreeStaticPropertyUtils.checkThatNodeIsSelectedInTree('StepUp');
+ TreeStaticPropertyUtils.selectNode('AlternatingBoolean');
+
+ // Go back tree view and validate that the node is still selected
+ TreeStaticPropertyUtils.switchToTextEditor();
+ TreeStaticPropertyUtils.getTextInTextEditor().should(
+ 'equal',
+ 'ns=3;s=StepUp' + 'ns=3;s=AlternatingBoolean',
+ );
});
});
diff --git
a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-runtime-resolvable-tree-input.component.ts
b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-runtime-resolvable-tree-input.component.ts
index bd539c8fe2..80dce0944c 100644
---
a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-runtime-resolvable-tree-input.component.ts
+++
b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-runtime-resolvable-tree-input.component.ts
@@ -155,5 +155,9 @@ export class StaticRuntimeResolvableTreeInputComponent
changeEditorMode(mode: 'tree' | 'text') {
this.editorMode = mode;
+
+ if (mode === 'tree') {
+ this.reload();
+ }
}
}
diff --git
a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-button-menu/static-tree-input-button-menu.component.html
b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-button-menu/static-tree-input-button-menu.component.html
index dc4244aafc..447eb449b5 100644
---
a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-button-menu/static-tree-input-button-menu.component.html
+++
b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-button-menu/static-tree-input-button-menu.component.html
@@ -23,6 +23,7 @@
class="small-button"
(click)="onResetOptionsAndReload()"
style="margin-right: 10px"
+ *ngIf="editorMode === 'tree'"
[disabled]="!showOptions"
data-cy="clear-tree-node-selection"
>
@@ -34,6 +35,7 @@
class="small-button"
(click)="onReload()"
style="margin-right: 10px"
+ *ngIf="editorMode === 'tree'"
[disabled]="!showOptions"
>
<span>Reload</span>
diff --git
a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-text-editor/static-tree-input-text-editor.component.ts
b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-text-editor/static-tree-input-text-editor.component.ts
index 1651519ff8..5ade0ab7b3 100644
---
a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-text-editor/static-tree-input-text-editor.component.ts
+++
b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input-text-editor/static-tree-input-text-editor.component.ts
@@ -16,7 +16,7 @@
*
*/
-import { Component, EventEmitter, Input, Output } from '@angular/core';
+import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { RuntimeResolvableTreeInputStaticProperty } from
'@streampipes/platform-services';
@@ -25,7 +25,7 @@ import { RuntimeResolvableTreeInputStaticProperty } from
'@streampipes/platform-
selector: 'sp-static-tree-input-text-editor',
templateUrl: './static-tree-input-text-editor.component.html',
})
-export class StaticTreeInputTextEditorComponent {
+export class StaticTreeInputTextEditorComponent implements OnInit {
@Input()
staticProperty: RuntimeResolvableTreeInputStaticProperty;
@@ -54,6 +54,11 @@ export class StaticTreeInputTextEditorComponent {
});
}
+ ngOnInit() {
+ this.textEditor =
+ this.staticProperty.selectedNodesInternalNames.join('\n');
+ }
+
onTextEditorChange(value: string): void {
this.textChangeSubject.next(value);
}