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

zehnder pushed a commit to branch 
3388-adapter-deletion-does-not-clean-up-asset-links
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to 
refs/heads/3388-adapter-deletion-does-not-clean-up-asset-links by this push:
     new eb2ef73b73 fix(#3388): Refactor asset link test
eb2ef73b73 is described below

commit eb2ef73b73b81b6d0b1697f8df295dbdf8a94199
Author: Philipp Zehnder <[email protected]>
AuthorDate: Mon Dec 23 10:10:41 2024 +0100

    fix(#3388): Refactor asset link test
---
 ui/cypress/support/utils/asset/AssetBtns.ts        | 65 ++++++++++++++++++++++
 ui/cypress/support/utils/asset/AssetUtils.ts       | 36 ++++++++++++
 .../tests/assetManagement/createAsset.spec.ts      | 62 ---------------------
 .../assetManagement/generalAssetTest.smoke.spec.ts | 54 ++++++++++++++++++
 .../edit-asset/asset-details.component.html        |  4 +-
 .../manage-asset-links-dialog.component.html       | 12 ++--
 6 files changed, 166 insertions(+), 67 deletions(-)

diff --git a/ui/cypress/support/utils/asset/AssetBtns.ts 
b/ui/cypress/support/utils/asset/AssetBtns.ts
new file mode 100644
index 0000000000..5589c2d7d6
--- /dev/null
+++ b/ui/cypress/support/utils/asset/AssetBtns.ts
@@ -0,0 +1,65 @@
+/*
+ *  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.
+ *
+ */
+
+export class AssetBtns {
+    public static createAssetBtn() {
+        return cy.dataCy('create-new-asset-button', { timeout: 10000 });
+    }
+
+    public static assetNameInput() {
+        return cy.dataCy('asset-name', { timeout: 10000 });
+    }
+
+    public static saveAssetBtn() {
+        return cy.dataCy('save-asset', { timeout: 10000 });
+    }
+
+    public static basicTab() {
+        return cy.dataCy('basic-tab', { timeout: 10000 });
+    }
+
+    public static assetLinksTab() {
+        return cy.dataCy('asset-links-tab', { timeout: 10000 });
+    }
+
+    public static manageLinksBtn() {
+        return cy.dataCy('assets-manage-links-button', { timeout: 10000 });
+    }
+
+    public static adapterCheckbox(adapterName: string) {
+        return cy.dataCy('select-adapters-checkbox-' + adapterName, {
+            timeout: 10000,
+        });
+    }
+
+    public static dataStreamCheckbox(adapterName: string) {
+        return cy.dataCy('select-data-stream-checkbox-' + adapterName, {
+            timeout: 10000,
+        });
+    }
+
+    public static updateAssetLinksBtn() {
+        return cy.dataCy('assets-update-links-button', { timeout: 10000 });
+    }
+
+    public static goBackToOverviewBtn() {
+        return cy.dataCy('save-data-explorer-go-back-to-overview', {
+            timeout: 10000,
+        });
+    }
+}
diff --git a/ui/cypress/support/utils/asset/AssetUtils.ts 
b/ui/cypress/support/utils/asset/AssetUtils.ts
index 1df1f6907e..a6d008282f 100644
--- a/ui/cypress/support/utils/asset/AssetUtils.ts
+++ b/ui/cypress/support/utils/asset/AssetUtils.ts
@@ -16,8 +16,44 @@
  *
  */
 
+import { AssetBtns } from './AssetBtns';
+
 export class AssetUtils {
     public static goToAssets() {
         cy.visit('#/assets/overview');
     }
+
+    public static goBackToOverview() {
+        AssetBtns.goBackToOverviewBtn().click();
+    }
+
+    public static addNewAsset(assetName: string) {
+        AssetBtns.createAssetBtn().click();
+        AssetBtns.assetNameInput().clear();
+        AssetBtns.assetNameInput().type(assetName);
+        AssetBtns.saveAssetBtn().click();
+    }
+
+    public static openManageAssetLinks() {
+        AssetBtns.manageLinksBtn().should('be.enabled');
+        AssetBtns.manageLinksBtn().click();
+    }
+
+    public static selectAdapterAssetLink(adapterName: string) {
+        AssetBtns.adapterCheckbox(adapterName).click();
+    }
+
+    public static selectDataStreamAssetLink(adapterName: string) {
+        AssetBtns.dataStreamCheckbox(adapterName).click();
+    }
+
+    public static checkAmountOfAssets(amount: number) {
+        cy.dataCy('assets-table').should('have.length', amount);
+    }
+
+    public static checkAmountOfLinkedResources(amount: number) {
+        cy.dataCy('linked-resources-list')
+            .children()
+            .should('have.length', amount);
+    }
 }
diff --git a/ui/cypress/tests/assetManagement/createAsset.spec.ts 
b/ui/cypress/tests/assetManagement/createAsset.spec.ts
deleted file mode 100644
index 6aa726636d..0000000000
--- a/ui/cypress/tests/assetManagement/createAsset.spec.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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 { AdapterBuilder } from '../../support/builder/AdapterBuilder';
-import { ConnectUtils } from '../../support/utils/connect/ConnectUtils';
-import { AssetUtils } from '../../support/utils/asset/AssetUtils';
-import { DashboardUtils } from '../../support/utils/DashboardUtils';
-import { ConfigurationUtils } from 
'../../support/utils/configuration/ConfigurationUtils';
-
-describe('Creates a new adapter, add to assets and export assets', () => {
-    beforeEach('Setup Test', () => {
-        cy.initStreamPipesTest();
-        const adapterInput = AdapterBuilder.create('Machine_Data_Simulator')
-            .setName('Machine Data Simulator Test')
-            .addInput('input', 'wait-time-ms', '1000')
-            .setStartAdapter(true)
-            .build();
-
-        ConnectUtils.testAdapter(adapterInput);
-    });
-
-    it('Perform Test', () => {
-        // Create new asset from adapters
-        AssetUtils.goToAssets();
-        cy.dataCy('create-new-asset-button').click();
-        cy.dataCy('asset-name').clear();
-        cy.dataCy('asset-name').type('Test asset');
-        cy.dataCy('save-asset').click();
-        cy.get('.mdc-tab__text-label').contains('Asset 
Links').parent().click();
-        cy.dataCy('assets-manage-links-button', { timeout: 5000 }).should(
-            'be.enabled',
-        );
-        cy.dataCy('assets-manage-links-button').click();
-        cy.dataCy('manage-assets-select-adapters-checkbox').click();
-        cy.dataCy('manage-assets-select-data-sources-checkbox').click();
-        cy.dataCy('assets-update-links-button').click();
-
-        cy.dataCy('linked-resources-list').children().should('have.length', 2);
-        cy.dataCy('save-asset-button').click();
-        cy.dataCy('save-data-explorer-go-back-to-overview').click();
-
-        // Leave and navigate back to Assets
-        DashboardUtils.goToDashboard();
-        AssetUtils.goToAssets();
-        cy.dataCy('assets-table').should('have.length', 1);
-    });
-});
diff --git a/ui/cypress/tests/assetManagement/generalAssetTest.smoke.spec.ts 
b/ui/cypress/tests/assetManagement/generalAssetTest.smoke.spec.ts
new file mode 100644
index 0000000000..eef277ea2f
--- /dev/null
+++ b/ui/cypress/tests/assetManagement/generalAssetTest.smoke.spec.ts
@@ -0,0 +1,54 @@
+/*
+ * 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 { AssetUtils } from '../../support/utils/asset/AssetUtils';
+import { DashboardUtils } from '../../support/utils/DashboardUtils';
+import { AssetBtns } from '../../support/utils/asset/AssetBtns';
+
+describe('Creates a new adapter, add to assets', () => {
+    const adapterName = 'Machine_Data_Simulator';
+
+    beforeEach('Setup Test', () => {
+        cy.initStreamPipesTest();
+        ConnectUtils.addMachineDataSimulator(adapterName);
+    });
+
+    it('Perform Test', () => {
+        // Create new asset from adapters
+        AssetUtils.goToAssets();
+
+        AssetUtils.addNewAsset('Test Asset');
+
+        AssetBtns.assetLinksTab().click();
+        AssetUtils.openManageAssetLinks();
+
+        AssetUtils.selectAdapterAssetLink(adapterName);
+        AssetUtils.selectDataStreamAssetLink(adapterName);
+        AssetBtns.updateAssetLinksBtn().click();
+
+        AssetUtils.checkAmountOfLinkedResources(2);
+        AssetBtns.saveAssetBtn().click();
+        AssetUtils.goBackToOverview();
+
+        // // Leave and navigate back to Assets
+        DashboardUtils.goToDashboard();
+        AssetUtils.goToAssets();
+        AssetUtils.checkAmountOfAssets(1);
+    });
+});
diff --git 
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details.component.html
 
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details.component.html
index b6f2d28aa7..278f9bfbc6 100644
--- 
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details.component.html
+++ 
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details.component.html
@@ -40,7 +40,7 @@
                     <button
                         mat-button
                         mat-raised-button
-                        data-cy="save-asset-button"
+                        data-cy="save-asset"
                         color="accent"
                         (click)="saveAsset()"
                     >
@@ -56,12 +56,14 @@
                     <nav mat-tab-nav-bar color="accent">
                         <a
                             mat-tab-link
+                            data-cy="basic-tab"
                             [active]="activeTab === 'basic'"
                             (click)="activeTab = 'basic'"
                             >Basics</a
                         >
                         <a
                             mat-tab-link
+                            data-cy="asset-links-tab"
                             [active]="activeTab === 'asset-links'"
                             (click)="activeTab = 'asset-links'"
                             >Asset Links</a
diff --git 
a/ui/src/app/assets/dialog/manage-asset-links/manage-asset-links-dialog.component.html
 
b/ui/src/app/assets/dialog/manage-asset-links/manage-asset-links-dialog.component.html
index c7af829a91..5e68673fb1 100644
--- 
a/ui/src/app/assets/dialog/manage-asset-links/manage-asset-links-dialog.component.html
+++ 
b/ui/src/app/assets/dialog/manage-asset-links/manage-asset-links-dialog.component.html
@@ -64,7 +64,9 @@
                     <mat-checkbox
                         color="accent"
                         [checked]="linkSelected(element.elementId)"
-                        data-cy="manage-assets-select-adapters-checkbox"
+                        [attr.data-cy]="
+                            'select-adapters-checkbox-' + element.name
+                        "
                         (change)="
                             selectLink(
                                 $event.checked,
@@ -228,7 +230,9 @@
                     <mat-checkbox
                         color="accent"
                         [checked]="linkSelected(source.elementId)"
-                        data-cy="manage-assets-select-data-sources-checkbox"
+                        [attr.data-cy]="
+                            'select-data-stream-checkbox-' + source.name
+                        "
                         (change)="
                             selectLink(
                                 $event.checked,
@@ -394,8 +398,8 @@
                                 'pipeline'
                             )
                         "
-                        >{{ pipeline.name }}</mat-checkbox
-                    >
+                        >{{ pipeline.name }}
+                    </mat-checkbox>
                 </div>
             </div>
         </div>

Reply via email to