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

zehnder pushed a commit to branch 2577-pipeline-element-templates-do-not-work
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to 
refs/heads/2577-pipeline-element-templates-do-not-work by this push:
     new ac3f191551 test(#2577): Add cypress test for connect configuration 
templates
ac3f191551 is described below

commit ac3f19155126edec0ed2d9c900e70228e1717e8b
Author: Philipp Zehnder <[email protected]>
AuthorDate: Mon Mar 18 15:25:19 2024 +0100

    test(#2577): Add cypress test for connect configuration templates
---
 .../adapter/connectConfigurationTemplate.spec.ts   | 74 ++++++++++++++++++++++
 .../adapter-settings.component.html                |  3 +
 .../adapter-template-dialog.component.html         |  1 +
 ...pipeline-element-template-config.component.html |  3 +
 4 files changed, 81 insertions(+)

diff --git a/ui/cypress/tests/adapter/connectConfigurationTemplate.spec.ts 
b/ui/cypress/tests/adapter/connectConfigurationTemplate.spec.ts
new file mode 100644
index 0000000000..c8eb5a9493
--- /dev/null
+++ b/ui/cypress/tests/adapter/connectConfigurationTemplate.spec.ts
@@ -0,0 +1,74 @@
+/*
+ *  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.
+ *
+ */
+
+import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
+import { StaticPropertyUtils } from '../../support/utils/StaticPropertyUtils';
+import { AdapterBuilder } from '../../support/builder/AdapterBuilder';
+
+describe('Test Edit Adapter', () => {
+    beforeEach('Setup Test', () => {
+        // To set up test add a stream adapter that can be configured
+        cy.initStreamPipesTest();
+        ConnectUtils.goToConnect();
+        ConnectUtils.goToNewAdapterPage();
+    });
+
+    it('Successfully edit adapter', () => {
+        const WAIT_TIME_MS = 'wait-time-ms';
+        const SIMULATOR_OPTION_PRESSURE = 'simulator-option-pressure';
+        const TEMPLATE_NAME = 'Test Template';
+
+        // configure adapter template
+        const adapterTemplateInput = AdapterBuilder.create(
+            'Machine_Data_Simulator',
+        )
+            .addInput('input', WAIT_TIME_MS, '3000')
+            .addInput('radio', 'selected', SIMULATOR_OPTION_PRESSURE)
+            .build();
+        ConnectUtils.selectAdapter(adapterTemplateInput.adapterType);
+        StaticPropertyUtils.input(adapterTemplateInput.adapterConfiguration);
+
+        // store adapter template
+        cy.dataCy('connect-use-template').should('not.exist');
+        cy.dataCy('store-config-as-template').click();
+        cy.dataCy('template-name').type(TEMPLATE_NAME);
+        cy.dataCy('template-description').type('Test Description');
+        cy.dataCy('create-template').click();
+        cy.dataCy('connect-new-adapter-cancel').click();
+
+        // Reload template configuration
+        ConnectUtils.goToNewAdapterPage();
+        ConnectUtils.selectAdapter(adapterTemplateInput.adapterType);
+        cy.dataCy('connect-use-template').should('exist');
+        cy.dataCy('connect-use-template').click({ force: true });
+        cy.get('mat-option').contains('Test Template').click();
+
+        // validate that the template values are selected
+        cy.dataCy(WAIT_TIME_MS).should('have.value', '3000');
+        cy.dataCy('selected-' + SIMULATOR_OPTION_PRESSURE).should(
+            'have.class',
+            'mat-mdc-radio-checked',
+        );
+
+        // Delete the template
+        cy.dataCy('store-config-as-template').click();
+        cy.dataCy('delete-pipeline-element-template').should('have.length', 1);
+        cy.dataCy('delete-pipeline-element-template').click();
+        cy.dataCy('delete-pipeline-element-template').should('have.length', 0);
+    });
+});
diff --git 
a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
 
b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
index 0be1a6d607..7fa0308abd 100644
--- 
a/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
+++ 
b/ui/src/app/connect/components/adapter-configuration/adapter-settings/adapter-settings.component.html
@@ -41,6 +41,7 @@
                             <mat-select
                                 (selectionChange)="loadTemplate($event)"
                                 [(value)]="selectedTemplate"
+                                data-cy="connect-use-template"
                             >
                                 <mat-option>--</mat-option>
                                 <mat-option
@@ -69,6 +70,7 @@
             mat-raised-button
             style="margin-right: 10px"
             (click)="removeSelection()"
+            data-cy="connect-new-adapter-cancel"
         >
             Cancel
         </button>
@@ -76,6 +78,7 @@
             mat-button
             mat-raised-button
             class="mat-basic"
+            data-cy="store-config-as-template"
             (click)="openTemplateDialog()"
         >
             Store config as template
diff --git 
a/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
 
b/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
index ecaf92147e..6c81d0a7b3 100644
--- 
a/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
+++ 
b/ui/src/app/connect/dialog/adapter-template/adapter-template-dialog.component.html
@@ -36,6 +36,7 @@
             color="accent"
             (click)="saveTemplate()"
             style="margin-right: 10px"
+            data-cy="create-template"
         >
             Create template
         </button>
diff --git 
a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
 
b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
index 5ad61fb329..65c18d5129 100644
--- 
a/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
+++ 
b/ui/src/app/core-ui/pipeline-element-template-config/pipeline-element-template-config.component.html
@@ -27,6 +27,7 @@
                 name="templateName"
                 class="sp"
                 required
+                data-cy="template-name"
             />
         </mat-form-field>
         <mat-form-field fxFlex color="accent">
@@ -37,6 +38,7 @@
                 name="templateDescription"
                 class="sp"
                 required
+                data-cy="template-description"
             />
         </mat-form-field>
         <mat-divider class="divider"></mat-divider>
@@ -85,6 +87,7 @@
                         mat-icon-button
                         color="accent"
                         (click)="deleteTemplate(template._id)"
+                        data-cy="delete-pipeline-element-template"
                     >
                         <mat-icon>delete</mat-icon>
                     </button>

Reply via email to