You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by "IsaakKrut (via GitHub)" <gi...@apache.org> on 2024/03/08 16:18:16 UTC

[PR] #2442 fixed data explorer time range buttons

IsaakKrut opened a new pull request, #2521:
URL: https://github.com/apache/streampipes/pull/2521

   Fixes #2442 
   
   PR introduces (a) breaking change(s): no
   
   PR introduces (a) deprecation(s): no
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] #2442 fixed data explorer time range buttons

Posted by "IsaakKrut (via GitHub)" <gi...@apache.org>.
IsaakKrut commented on PR #2521:
URL: https://github.com/apache/streampipes/pull/2521#issuecomment-1989417594

   Hi @tenthe,
   
   Updated the test with your suggestions and fixed a daylight savings related issue. 
   
   Regarding invoke method. What it does is it invokes a function specified in the first parameter on an object yielded before it in the chain. In this case, it's an attr() function that gets the attribute's value based on the second parameter which is attributeName
   
   This is the html element:
   `<sp-date-input data-cy="time-range-to" _nghost-ng-c1192185161="" ng-reflect-date="Mon Mar 11 2024 16:23:16 GMT-0"><input _ngcontent-ng-c1192185161="" type="datetime-local" step="1" class="sp-date-input"></sp-date-input>`
   
   So the current date selection is stored in the "ng-reflect-date" attribute. I added a couple of comments, let me know if I can do anything else to make it easier to read


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] #2442 fixed data explorer time range buttons

Posted by "IsaakKrut (via GitHub)" <gi...@apache.org>.
IsaakKrut commented on PR #2521:
URL: https://github.com/apache/streampipes/pull/2521#issuecomment-1987058875

   Is there a reason why 1 month offset was 60*24*30 + 600 minutes? Updated it to be exactly 30 days


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] #2442 fixed data explorer time range buttons

Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti merged PR #2521:
URL: https://github.com/apache/streampipes/pull/2521


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] #2442 fixed data explorer time range buttons

Posted by "tenthe (via GitHub)" <gi...@apache.org>.
tenthe commented on code in PR #2521:
URL: https://github.com/apache/streampipes/pull/2521#discussion_r1519447659


##########
ui/cypress/tests/datalake/timeRangeSelectors.spec.ts:
##########
@@ -0,0 +1,137 @@
+/*
+ * 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 { DataLakeUtils } from '../../support/utils/datalake/DataLakeUtils';
+
+describe('Test Time Range Selectors in Data Explorer', () => {
+    const periods = [
+        '15_min',
+        '1_hour',
+        '1_day',
+        '1_week',
+        '1_month',
+        '1_year',
+    ];
+
+    const dateAttribute = 'ng-reflect-date';
+    const timeRangeFrom = 'time-range-from';
+    const timeRangeTo = 'time-range-to';
+
+    before('Setup Tests', () => {
+        cy.initStreamPipesTest();
+        DataLakeUtils.loadDataIntoDataLake('datalake/sample.csv', false);
+        DataLakeUtils.goToDatalake();
+        DataLakeUtils.createAndEditDataView('TestView');
+    });
+
+    it('Perform Test', () => {
+        periods.forEach(period => {
+            cy.log('Testing period: ' + period);
+            cy.dataCy(period).click();
+            cy.dataCy(timeRangeTo)
+                .invoke('attr', dateAttribute)
+                .then(initialEndDateString => {
+                    cy.dataCy(timeRangeFrom)
+                        .invoke('attr', dateAttribute)
+                        .then(initialStartDateString => {
+                            const initialStartDate = new Date(
+                                Date.parse(initialStartDateString),
+                            );
+                            const initialEndDate = new Date(
+                                Date.parse(initialEndDateString),
+                            );
+
+                            cy.wrap(initialStartDate).should(
+                                'deep.eq',
+                                getExpectedStartDate(initialEndDate, period),
+                            );
+
+                            cy.dataCy('decrease-time-button').click({
+                                force: true,
+                            });
+                            cy.dataCy(timeRangeTo)
+                                .invoke('attr', dateAttribute)
+                                .then(updatedEndDateString => {
+                                    cy.dataCy(timeRangeFrom)
+                                        .invoke('attr', dateAttribute)
+                                        .then(updatedStartDateString => {
+                                            const updatedStartDate = new Date(
+                                                Date.parse(
+                                                    updatedStartDateString,
+                                                ),
+                                            );
+                                            const updatedEndDate = new Date(
+                                                Date.parse(
+                                                    updatedEndDateString,
+                                                ),
+                                            );
+
+                                            cy.wrap(updatedStartDate).should(
+                                                'deep.eq',
+                                                getExpectedStartDate(
+                                                    updatedEndDate,
+                                                    period,
+                                                ),
+                                            );
+                                            cy.wrap(updatedEndDate).should(
+                                                'deep.eq',
+                                                initialStartDate,
+                                            );
+                                        });
+                                });
+
+                            cy.dataCy('increase-time-button').click({
+                                force: true,
+                            });
+                            cy.dataCy(timeRangeFrom)
+                                .invoke('attr', dateAttribute)
+                                .should('eq', initialStartDateString);
+                            cy.dataCy(timeRangeTo)
+                                .invoke('attr', dateAttribute)
+                                .should('eq', initialEndDateString);
+                        });
+                });
+        });
+    });
+});
+
+function getExpectedStartDate(endDate: Date, period: string): Date {
+    let startDate = new Date(endDate);

Review Comment:
   ```suggestion
       const startDate = new Date(endDate);
   ```



##########
ui/cypress/tests/datalake/timeRangeSelectors.spec.ts:
##########
@@ -0,0 +1,137 @@
+/*
+ * 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 { DataLakeUtils } from '../../support/utils/datalake/DataLakeUtils';
+
+describe('Test Time Range Selectors in Data Explorer', () => {
+    const periods = [

Review Comment:
   You could use a list of objects here instead of a list of stings, then you can remove the switch block in `getExpectedStartDate`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] #2442 fixed data explorer time range buttons

Posted by "tenthe (via GitHub)" <gi...@apache.org>.
tenthe commented on PR #2521:
URL: https://github.com/apache/streampipes/pull/2521#issuecomment-1991068593

   Hi @IsaakKrut,
   
   thank you very much for the explanation and the feedback.
   I think it's great that you provide an e2e test for this functionality.
   
   Cheers,
   Philipp


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org