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

zehnder pushed a commit to branch 3933-test-editadaptervaluesandfields-fails
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to 
refs/heads/3933-test-editadaptervaluesandfields-fails by this push:
     new 47215d3bc2 fix(#3933): Refactor editAdapterValuesAndFields test
47215d3bc2 is described below

commit 47215d3bc2f37e3a469e419f24162fe7d10c6896
Author: Philipp Zehnder <[email protected]>
AuthorDate: Mon Nov 17 14:34:51 2025 +0100

    fix(#3933): Refactor editAdapterValuesAndFields test
---
 ui/cypress/support/utils/connect/ConnectBtns.ts    |  16 +++
 .../utils/connect/ConnectEventSchemaUtils.ts       |  19 +++-
 ui/cypress/support/utils/connect/ConnectUtils.ts   |   1 -
 .../connect/editAdapterValuesAndFields.spec.ts     | 117 ++++++++++-----------
 .../edit-schema-transformation.component.html      |   4 +-
 5 files changed, 88 insertions(+), 69 deletions(-)

diff --git a/ui/cypress/support/utils/connect/ConnectBtns.ts 
b/ui/cypress/support/utils/connect/ConnectBtns.ts
index 0b0bb06671..7f9c75565c 100644
--- a/ui/cypress/support/utils/connect/ConnectBtns.ts
+++ b/ui/cypress/support/utils/connect/ConnectBtns.ts
@@ -165,6 +165,16 @@ export class ConnectBtns {
             .click();
     }
 
+    public static connectSchemaCorrectionValueInput() {
+        return cy.dataCy('connect-schema-correction-value', { timeout: 10000 
});
+    }
+
+    public static connectSchemaCorrectionOperatorInput() {
+        return cy.dataCy('connect-schema-correction-operator', {
+            timeout: 10000,
+        });
+    }
+
     public static timestampStringRegex() {
         return cy.dataCy('connect-timestamp-string-regex', { timeout: 10000 });
     }
@@ -185,6 +195,12 @@ export class ConnectBtns {
         return cy.dataCy('sp-event-schema-next-button');
     }
 
+    public static semanticTypeInput() {
+        return cy.dataCy('semantic-type', {
+            timeout: 10000,
+        });
+    }
+
     // ========================================================================
 
     // =====================  Format configurations  ==========================
diff --git a/ui/cypress/support/utils/connect/ConnectEventSchemaUtils.ts 
b/ui/cypress/support/utils/connect/ConnectEventSchemaUtils.ts
index b080a1bf42..001b1316ba 100644
--- a/ui/cypress/support/utils/connect/ConnectEventSchemaUtils.ts
+++ b/ui/cypress/support/utils/connect/ConnectEventSchemaUtils.ts
@@ -114,8 +114,8 @@ export class ConnectEventSchemaUtils {
     public static numberTransformation(propertyName: string, value: string) {
         ConnectEventSchemaUtils.clickEditProperty(propertyName);
         // cy.wait(1000);
-        cy.dataCy('connect-schema-correction-value').type(value);
-        cy.dataCy('connect-schema-correction-operator')
+        ConnectBtns.connectSchemaCorrectionValueInput().type(value);
+        ConnectBtns.connectSchemaCorrectionOperatorInput()
             .click()
             .get('mat-option')
             .contains('Multiply')
@@ -125,7 +125,7 @@ export class ConnectEventSchemaUtils {
         cy.dataCy('edit-' + propertyName.toLowerCase(), {
             timeout: 10000,
         }).click({ force: true });
-        cy.dataCy('connect-schema-correction-value', { timeout: 10000 
}).should(
+        ConnectBtns.connectSchemaCorrectionValueInput().should(
             'have.value',
             value,
         );
@@ -257,6 +257,12 @@ export class ConnectEventSchemaUtils {
         ConnectBtns.saveEditProperty().click();
     }
 
+    public static changeSemanticType(propertyName: string, value: string) {
+        ConnectEventSchemaUtils.clickEditProperty(propertyName);
+        ConnectBtns.semanticTypeInput().clear().type(value);
+        ConnectBtns.saveEditProperty().click();
+    }
+
     private static checkIfWarningIsShown(warningIsShown: boolean) {
         if (warningIsShown) {
             cy.dataCy('warning-change-data-type').should('be.visible');
@@ -285,11 +291,14 @@ export class ConnectEventSchemaUtils {
         cy.dataCy('sp-event-schema-next-button').click();
     }
 
-    public static clickEditProperty(propertyName: string) {
+    public static clickEditProperty(propertyName: string, validation = true) {
         cy.dataCy(`edit-${ConnectEventSchemaUtils.escape(propertyName)}`, {
             timeout: 10000,
         }).click();
-        ConnectEventSchemaUtils.validateRuntimeName(propertyName);
+
+        if (validation) {
+            ConnectEventSchemaUtils.validateRuntimeName(propertyName);
+        }
     }
 
     public static regexValueInput() {
diff --git a/ui/cypress/support/utils/connect/ConnectUtils.ts 
b/ui/cypress/support/utils/connect/ConnectUtils.ts
index ecc10d4f80..4c2f556905 100644
--- a/ui/cypress/support/utils/connect/ConnectUtils.ts
+++ b/ui/cypress/support/utils/connect/ConnectUtils.ts
@@ -291,7 +291,6 @@ export class ConnectUtils {
         });
     }
 
-    // Close adapter preview
     public static closeAdapterPreview() {
         cy.get('button').contains('Close').parent().click();
     }
diff --git a/ui/cypress/tests/connect/editAdapterValuesAndFields.spec.ts 
b/ui/cypress/tests/connect/editAdapterValuesAndFields.spec.ts
index 9def245019..d4eafc18f8 100644
--- a/ui/cypress/tests/connect/editAdapterValuesAndFields.spec.ts
+++ b/ui/cypress/tests/connect/editAdapterValuesAndFields.spec.ts
@@ -22,113 +22,110 @@ import { AdapterBuilder } from 
'../../support/builder/AdapterBuilder';
 import { ConnectEventSchemaUtils } from 
'../../support/utils/connect/ConnectEventSchemaUtils';
 
 describe('Test Edit Adapter', () => {
+    const adapterName = 'Test Adapter';
+
     beforeEach('Setup Test', () => {
         cy.initStreamPipesTest();
     });
 
-    it('Test configuration of adapter fields ', () => {
-        // Set up new adapter
-        const builder = AdapterBuilder.create('Machine_Data_Simulator')
-            .setName('Machine_Data_Simulator')
-            .addInput('input', 'wait-time-ms', '1000');
-        const configuration = builder.build();
-        ConnectUtils.goToConnect();
-        ConnectUtils.goToNewAdapterPage();
-        ConnectUtils.selectAdapter(configuration.adapterType);
-        ConnectBtns.adapterSettingsNextBtn().click();
+    it('Edit and persist adapter schema and reconfigure adapter', () => {
+        createAdapterWithSchemaEdits();
+
+        validateSavedAdapterEdits();
+
+        reconfigureAdapterToUsePressureSensorInsteadOfFlowRate();
+    });
+
+    function createAdapterWithSchemaEdits() {
+        const adapterInput = AdapterBuilder.create('Machine_Data_Simulator')
+            .setName(adapterName)
+            .addInput('input', 'wait-time-ms', '1000')
+            .build();
+
+        ConnectUtils.createAdapterUntilEventSchemaConfiguration(adapterInput);
 
         // Add new property and edit field
-        cy.dataCy('connect-add-static-property').click();
-        cy.dataCy('connect-add-field-name').type('test-property-1');
-        cy.dataCy('connect-add-field-name-button').click();
-        cy.dataCy('edit-density').click();
-        // Change runtime name
-        ConnectBtns.runtimeNameInput().clear().type('test-density');
-        // Change field semantic type
-        cy.get('[id="domainproperty"]')
-            .clear()
-            .type('http://schema.org/Numbers');
-        // Change field data type
-        ConnectBtns.changeRuntimeType()
-            .click()
-            .get('mat-option')
-            .contains('Double')
-            .click();
-        // Provide correction value and operator
-        cy.dataCy('connect-schema-correction-value').type('2');
-        cy.dataCy('connect-schema-correction-operator')
-            .click()
-            .get('mat-option')
-            .contains('Multiply')
-            .click();
-        ConnectBtns.saveEditProperty().click();
-        cy.dataCy('sp-event-schema-next-button').click();
+        ConnectEventSchemaUtils.addStaticProperty(
+            'test-property-1',
+            'static-value-1',
+        );
 
-        // Fill in adapter name and close view
-        cy.dataCy('sp-adapter-name').type('Test Adapter');
-        cy.dataCy('adapter-settings-start-adapter-btn').click();
-        ConnectUtils.closeAdapterPreview();
+        // Edit property density
+        const propertyName = 'density';
+        ConnectEventSchemaUtils.changePropertyDataType(propertyName, 'Double');
+        ConnectEventSchemaUtils.numberTransformation(propertyName, '2');
+        ConnectEventSchemaUtils.changeSemanticType(
+            propertyName,
+            'http://schema.org/Numbers',
+        );
+        ConnectEventSchemaUtils.renameProperty(propertyName, 'test-density');
+
+        ConnectUtils.finishEventSchemaConfiguration();
 
+        ConnectUtils.startAdapter(adapterInput);
+    }
+
+    function validateSavedAdapterEdits() {
         // Edit adapter and check if given values and added property still 
provided
-        ConnectBtns.openActionsMenu('Test Adapter');
+        ConnectBtns.openActionsMenu(adapterName);
         ConnectBtns.editAdapter().should('not.be.disabled');
         ConnectBtns.editAdapter().click();
         ConnectBtns.adapterSettingsNextBtn().click();
-        cy.dataCy('edit-density').click();
+        ConnectEventSchemaUtils.clickEditProperty('density', false);
+        // cy.dataCy('edit-density').click();
         ConnectEventSchemaUtils.validateRuntimeName('test-density');
 
-        cy.get('[id="domainproperty"]').should(
+        ConnectBtns.semanticTypeInput().should(
             'have.value',
             'http://schema.org/Numbers',
         );
         ConnectBtns.changeRuntimeType().should('include.text', 'Double');
-        cy.dataCy('connect-schema-correction-value').should('have.value', '2');
-        cy.dataCy('connect-schema-correction-operator').should(
+        ConnectBtns.connectSchemaCorrectionValueInput().should(
+            'have.value',
+            '2',
+        );
+        ConnectBtns.connectSchemaCorrectionOperatorInput().should(
             'include.text',
             'Multiply',
         );
 
-        // Delete inserted values in edit field
-        ConnectBtns.runtimeNameInput().clear().type('test-density');
-        cy.get('[id="domainproperty"]')
-            .clear()
-            .type('http://schema.org/Numbers');
-
         ConnectBtns.changeRuntimeType()
             .click()
             .get('mat-option')
             .contains('Float')
             .click();
-        cy.dataCy('connect-schema-correction-value').clear();
+        ConnectBtns.connectSchemaCorrectionValueInput().clear();
         ConnectBtns.saveEditProperty().click();
         ConnectEventSchemaUtils.schemaPreviewResultEvent().should(
             'include.text',
             'test-property-1',
         );
 
-        ConnectBtns.schemaNextBtn().click();
-        ConnectBtns.storeEditAdapter().click();
-        ConnectUtils.closeAdapterPreview();
+        storeAndCloseAdapterPreview();
+    }
 
+    function reconfigureAdapterToUsePressureSensorInsteadOfFlowRate() {
         // Configure adapter with pressure instead of flowrate
-        ConnectBtns.openActionsMenu('Test Adapter');
+        ConnectBtns.openActionsMenu(adapterName);
         ConnectBtns.editAdapter().click();
 
-        const newUserConfiguration = AdapterBuilder.create(
-            'Machine_Data_Simulator',
-        )
+        const adapterInput = AdapterBuilder.create('Machine_Data_Simulator')
             .addInput('input', 'wait-time-ms', '2000')
             .addInput('radio', 'selected', 'simulator-option-pressure')
             .build();
-        ConnectUtils.configureAdapter(newUserConfiguration);
+        ConnectUtils.configureAdapter(adapterInput);
 
         ConnectEventSchemaUtils.schemaPreviewResultEvent().should(
             'include.text',
             'test-property-1',
         );
 
+        storeAndCloseAdapterPreview();
+    }
+
+    function storeAndCloseAdapterPreview() {
         ConnectBtns.schemaNextBtn().click();
         ConnectBtns.storeEditAdapter().click();
         ConnectUtils.closeAdapterPreview();
-    });
+    }
 });
diff --git 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-schema-transformation.component.html
 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-schema-transformation.component.html
index 69d03df290..0e3f225422 100644
--- 
a/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-schema-transformation.component.html
+++ 
b/ui/src/app/connect/dialog/edit-event-property/components/edit-schema-transformation/edit-schema-transformation.component.html
@@ -65,9 +65,7 @@
                         <input
                             matInput
                             placeholder="Semantic Type"
-                            class="dmainProperty"
-                            name="domainproperty"
-                            id="domainproperty"
+                            data-cy="semantic-type"
                             [(ngModel)]="cachedProperty.semanticType"
                             [matAutocomplete]="st"
                             [disabled]="isTimestampProperty"

Reply via email to