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

zehnder pushed a commit to branch rel/0.92.0
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/rel/0.92.0 by this push:
     new fec887145 [hotfix] Add proper time selection to another cypress test 
(#1641)
fec887145 is described below

commit fec887145161189d2eb430825680b39ac7e82cc7
Author: Dominik Riemer <[email protected]>
AuthorDate: Tue May 30 21:49:20 2023 +0200

    [hotfix] Add proper time selection to another cypress test (#1641)
---
 ui/cypress/support/utils/datalake/DataLakeUtils.ts | 40 ++++++++++++++++++----
 ui/cypress/tests/datalake/widgets/table.ts         |  2 +-
 2 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/ui/cypress/support/utils/datalake/DataLakeUtils.ts 
b/ui/cypress/support/utils/datalake/DataLakeUtils.ts
index 1dbf1ce89..bd74f5c6a 100644
--- a/ui/cypress/support/utils/datalake/DataLakeUtils.ts
+++ b/ui/cypress/support/utils/datalake/DataLakeUtils.ts
@@ -84,9 +84,10 @@ export class DataLakeUtils {
     ) {
         DataLakeUtils.goToDatalake();
         DataLakeUtils.createAndEditDataView(dataViewName);
+
         DataLakeUtils.selectTimeRange(
-            new Date(2020, 10, 20, 22, 44),
-            new Date(2021, 10, 20, 22, 44),
+            new Date(2015, 10, 20, 22, 44),
+            DataLakeUtils.getFutureDate(),
         );
         // DataLakeUtils.addNewWidget();
         DataLakeUtils.selectDataSet(dataSet);
@@ -304,9 +305,36 @@ export class DataLakeUtils {
     }
 
     public static selectTimeRange(from: Date, to: Date) {
-        cy.dataCy('1_year').click();
-        // TODO fix time range selection
-        // DataLakeUtils.setTimeInput('time-range-from', from);
-        // DataLakeUtils.setTimeInput('time-range-to', to);
+        DataLakeUtils.setTimeInput('time-range-from', from);
+        DataLakeUtils.clickSetTime();
+        DataLakeUtils.setTimeInput('time-range-to', to);
+        DataLakeUtils.clickSetTime();
+    }
+
+    public static setTimeInput(field: string, date: Date) {
+        cy.dataCy(field)
+            .clear({ force: true })
+            .type(DataLakeUtils.makeTimeString(date), { force: true });
+    }
+
+    public static clickSetTime() {
+        cy.get('.owl-dt-container-buttons > button:nth-child(2)').click();
+    }
+
+    public static makeTimeString(date: Date) {
+        return date.toLocaleString('en-US', {
+            month: 'numeric',
+            day: 'numeric',
+            year: 'numeric',
+            hour: 'numeric',
+            minute: 'numeric',
+        });
+    }
+
+    public static getFutureDate() {
+        const currentDate = new Date();
+        currentDate.setMonth(currentDate.getMonth() + 1);
+
+        return currentDate;
     }
 }
diff --git a/ui/cypress/tests/datalake/widgets/table.ts 
b/ui/cypress/tests/datalake/widgets/table.ts
index b567f4e54..12ab68ded 100644
--- a/ui/cypress/tests/datalake/widgets/table.ts
+++ b/ui/cypress/tests/datalake/widgets/table.ts
@@ -46,7 +46,7 @@ describe('Test Table View in Data Explorer', () => {
 
         DataLakeUtils.selectTimeRange(
             new Date(2020, 10, 20, 22, 44),
-            new Date(2021, 10, 20, 22, 44),
+            DataLakeUtils.getFutureDate(),
         );
 
         cy.dataCy('data-explorer-table-row', { timeout: 10000 }).should(

Reply via email to