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

dominikriemer pushed a commit to branch fix-flaky-dataset-test
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit c9e65aaa885b2a4afa55c8173dec541492fa0572
Author: Dominik Riemer <[email protected]>
AuthorDate: Mon Jun 22 23:00:09 2026 +0200

    fix: Flaky cypress asset filter and dataset test
---
 ui/cypress/support/utils/asset/AssetUtils.ts       | 55 ++++++++++++++++++++++
 ui/cypress/support/utils/chart/ChartUtils.ts       | 14 +++++-
 .../tests/assetManagement/assetFilterTest.spec.ts  |  1 +
 ui/cypress/tests/chart/timeOrderDataView.spec.ts   |  2 +-
 4 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/ui/cypress/support/utils/asset/AssetUtils.ts 
b/ui/cypress/support/utils/asset/AssetUtils.ts
index 6f794c741f..2b6918a6ff 100644
--- a/ui/cypress/support/utils/asset/AssetUtils.ts
+++ b/ui/cypress/support/utils/asset/AssetUtils.ts
@@ -25,6 +25,61 @@ import { AssetBuilder } from '../../builder/AssetBuilder';
 import { PermissionUtils } from '../user/PermissionUtils';
 
 export class AssetUtils {
+    public static waitForAssets(
+        assetNames: string[],
+        attemptsRemaining: number = 40,
+    ): Cypress.Chainable<void> {
+        return cy.then(() => {
+            const token = window.localStorage.getItem('auth-token');
+
+            if (!token) {
+                throw new Error(
+                    'Waiting for assets requires an auth token. Call 
cy.login() first.',
+                );
+            }
+
+            return cy
+                .request<{ assetName: string }[]>({
+                    method: 'GET',
+                    url: '/streampipes-backend/api/v2/assets',
+                    headers: {
+                        Authorization: `Bearer ${token}`,
+                    },
+                })
+                .then(response => {
+                    const availableAssetNames = response.body.map(
+                        asset => asset.assetName,
+                    );
+                    const allAssetsAvailable = assetNames.every(assetName =>
+                        availableAssetNames.includes(assetName),
+                    );
+
+                    if (allAssetsAvailable) {
+                        return;
+                    }
+
+                    if (attemptsRemaining === 0) {
+                        const missingAssetNames = assetNames.filter(
+                            assetName =>
+                                !availableAssetNames.includes(assetName),
+                        );
+                        throw new Error(
+                            `Assets did not become available: 
${missingAssetNames.join(', ')}`,
+                        );
+                    }
+
+                    return cy
+                        .wait(250, { log: false })
+                        .then(() =>
+                            this.waitForAssets(
+                                assetNames,
+                                attemptsRemaining - 1,
+                            ),
+                        );
+                });
+        });
+    }
+
     public static goToAssets() {
         cy.visit('#/assets/overview');
         cy.dataCy('asset-title').should('be.visible');
diff --git a/ui/cypress/support/utils/chart/ChartUtils.ts 
b/ui/cypress/support/utils/chart/ChartUtils.ts
index e3cf9567b7..3b889949e0 100644
--- a/ui/cypress/support/utils/chart/ChartUtils.ts
+++ b/ui/cypress/support/utils/chart/ChartUtils.ts
@@ -29,8 +29,20 @@ import { ConnectBtns } from '../connect/ConnectBtns';
 export class ChartUtils {
     public static ADAPTER_NAME = 'datalake_configuration';
 
-    public static goToDatalake() {
+    public static goToDatalake(discardUnsavedChanges: boolean = true) {
         cy.visit('#/chart');
+        if (!discardUnsavedChanges) {
+            return;
+        }
+        cy.location('hash', { timeout: 10000 }).then(hash => {
+            if (hash.startsWith('#/chart/')) {
+                SharedBtns.confirmDialogCancelBtn()
+                    .should('be.visible')
+                    .click();
+            }
+        });
+        cy.location('hash', { timeout: 10000 }).should('eq', '#/chart');
+        cy.get('sp-chart-overview', { timeout: 10000 }).should('be.visible');
     }
 
     public static goToDashboard() {
diff --git a/ui/cypress/tests/assetManagement/assetFilterTest.spec.ts 
b/ui/cypress/tests/assetManagement/assetFilterTest.spec.ts
index 0a2870c5fc..2d37fb608b 100644
--- a/ui/cypress/tests/assetManagement/assetFilterTest.spec.ts
+++ b/ui/cypress/tests/assetManagement/assetFilterTest.spec.ts
@@ -44,6 +44,7 @@ describe('Test asset filters', () => {
     beforeEach('Setup Test', () => {
         cy.initStreamPipesTest();
         cy.importAssetResources();
+        AssetUtils.waitForAssets(['asset-1_0', 'asset-2_0', 'asset-3_0']);
         // This is currently required because the assets are only loaded on 
page load
         cy.reload();
     });
diff --git a/ui/cypress/tests/chart/timeOrderDataView.spec.ts 
b/ui/cypress/tests/chart/timeOrderDataView.spec.ts
index fb6bd2734b..1881d51c4e 100644
--- a/ui/cypress/tests/chart/timeOrderDataView.spec.ts
+++ b/ui/cypress/tests/chart/timeOrderDataView.spec.ts
@@ -74,7 +74,7 @@ describe('Test Time Order in Charts', () => {
         });
 
         // Check if dialog window is showing after applying changes to time 
settings
-        ChartUtils.goToDatalake();
+        ChartUtils.goToDatalake(false);
         ChartUtils.checkIfConfirmationDialogIsShowing();
     });
 });

Reply via email to