This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch 
3116-refactor-staticruntimeresolvabletreeinput-into-smaller-subcomponents
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to 
refs/heads/3116-refactor-staticruntimeresolvabletreeinput-into-smaller-subcomponents
 by this push:
     new 15e98385b1 refactor(#3116): Move static property utils
15e98385b1 is described below

commit 15e98385b11a9edda850b21f5008eccaa5ce0818
Author: Philipp Zehnder <[email protected]>
AuthorDate: Fri Aug 9 22:40:43 2024 +0200

    refactor(#3116): Move static property utils
---
 ui/cypress/support/general/dataCy.ts               | 22 +++++++++++++++-------
 ui/cypress/support/utils/PipelineUtils.ts          |  2 +-
 ui/cypress/support/utils/connect/ConnectUtils.ts   |  2 +-
 .../utils/{ => userInput}/StaticPropertyUtils.ts   | 22 ++++++++++++++++++++--
 .../connectConfigurationTemplate.spec.ts           |  2 +-
 .../static-tree-input.component.html               |  4 +++-
 6 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/ui/cypress/support/general/dataCy.ts 
b/ui/cypress/support/general/dataCy.ts
index ff1d54beae..13c5a35f8d 100644
--- a/ui/cypress/support/general/dataCy.ts
+++ b/ui/cypress/support/general/dataCy.ts
@@ -19,15 +19,23 @@
 declare global {
     namespace Cypress {
         interface Chainable {
-            dataCy: typeof dataCy;
+            dataCy: typeof dataCy
         }
     }
 }
 
-export const dataCy = (value: string, config?: any) => {
-    if (config) {
-        return cy.get(`[data-cy=${value}]`, config);
-    } else {
-        return cy.get(`[data-cy=${value}]`);
-    }
+/**
+ * Selects elements based on the `data-cy` attribute.
+ *
+ * @param {string} value - The value of the `data-cy` attribute to match.
+ * @param {object} [config={}] - Optional configuration object for the Cypress 
`get` command.
+ * @param {boolean} [startsWith=false] - If true, selects elements whose 
`data-cy` attribute starts with the given value.
+ * @returns {Cypress.Chainable<JQuery<HTMLElement>>} - A chainable Cypress 
object containing the matched elements.
+ */
+export const dataCy = (
+    value: string,
+    config: any = {},
+    startsWith: boolean = false) => {
+    const selector = startsWith ? `[data-cy^=${value}]` : `[data-cy=${value}]`;
+    return cy.get(selector, config);
 };
diff --git a/ui/cypress/support/utils/PipelineUtils.ts 
b/ui/cypress/support/utils/PipelineUtils.ts
index 846dd478ca..b901e225de 100644
--- a/ui/cypress/support/utils/PipelineUtils.ts
+++ b/ui/cypress/support/utils/PipelineUtils.ts
@@ -17,7 +17,7 @@
  */
 
 import { PipelineInput } from '../model/PipelineInput';
-import { StaticPropertyUtils } from './StaticPropertyUtils';
+import { StaticPropertyUtils } from './userInput/StaticPropertyUtils';
 import { OutputStrategyUtils } from './OutputStrategyUtils';
 import { PipelineElementInput } from '../model/PipelineElementInput';
 
diff --git a/ui/cypress/support/utils/connect/ConnectUtils.ts 
b/ui/cypress/support/utils/connect/ConnectUtils.ts
index ca19602dfb..67556897e9 100644
--- a/ui/cypress/support/utils/connect/ConnectUtils.ts
+++ b/ui/cypress/support/utils/connect/ConnectUtils.ts
@@ -16,7 +16,7 @@
  *
  */
 
-import { StaticPropertyUtils } from '../StaticPropertyUtils';
+import { StaticPropertyUtils } from '../userInput/StaticPropertyUtils';
 import { AdapterInput } from '../../model/AdapterInput';
 import { ConnectEventSchemaUtils } from './ConnectEventSchemaUtils';
 import { DataLakeUtils } from '../datalake/DataLakeUtils';
diff --git a/ui/cypress/support/utils/StaticPropertyUtils.ts 
b/ui/cypress/support/utils/userInput/StaticPropertyUtils.ts
similarity index 78%
rename from ui/cypress/support/utils/StaticPropertyUtils.ts
rename to ui/cypress/support/utils/userInput/StaticPropertyUtils.ts
index 25b2d200e5..d29f1aaeb4 100644
--- a/ui/cypress/support/utils/StaticPropertyUtils.ts
+++ b/ui/cypress/support/utils/userInput/StaticPropertyUtils.ts
@@ -1,3 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -16,8 +34,8 @@
  *
  */
 
-import { UserInput } from '../model/UserInput';
-import { TreeNode } from '../model/TreeNode';
+import { UserInput } from '../../model/UserInput';
+import { TreeNode } from '../../model/TreeNode';
 
 export class StaticPropertyUtils {
     public static input(configs: UserInput[]) {
diff --git 
a/ui/cypress/tests/pipelineElementConfigurationTemplate/connectConfigurationTemplate.spec.ts
 
b/ui/cypress/tests/pipelineElementConfigurationTemplate/connectConfigurationTemplate.spec.ts
index 76eb8d8e56..17b55649a3 100644
--- 
a/ui/cypress/tests/pipelineElementConfigurationTemplate/connectConfigurationTemplate.spec.ts
+++ 
b/ui/cypress/tests/pipelineElementConfigurationTemplate/connectConfigurationTemplate.spec.ts
@@ -17,7 +17,7 @@
  */
 
 import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
-import { StaticPropertyUtils } from '../../support/utils/StaticPropertyUtils';
+import { StaticPropertyUtils } from 
'../../support/utils/userInput/StaticPropertyUtils';
 import { AdapterBuilder } from '../../support/builder/AdapterBuilder';
 import { PipelineElementTemplateUtils } from 
'../../support/utils/PipelineElementTemplateUtils';
 
diff --git 
a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
 
b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
index cc905d4286..ddfc2ba9d7 100644
--- 
a/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
+++ 
b/ui/src/app/core-ui/static-properties/static-runtime-resolvable-tree-input/static-tree-input.component.html
@@ -88,7 +88,7 @@
                                 : 'node'
                         "
                         fxLayoutAlign="start center"
-                    >
+                        [attr.data-cy]="'tree-node-' + node.nodeName"          
          >
                         <i class="material-icons color-primary pr-5">wifi</i>
                         <i
                             class="material-icons pr-5 icon-button"
@@ -239,12 +239,14 @@
                     class="selected-node"
                     fxLayout="row"
                     fxLayoutAlign="start center"
+                    [attr.data-cy]="'selected-node-' + selectedNode"
                 >
                     <span fxFlex>{{ selectedNode }}</span>
                     <div fxLayoutAlign="end center">
                         <button
                             mat-icon-button
                             color="accent"
+                            [attr.data-cy]="'remove-' + selectedNode"
                             (click)="removeSelectedNode(selectedNode)"
                         >
                             <i class="material-icons">remove</i>

Reply via email to