tenthe commented on code in PR #3111: URL: https://github.com/apache/streampipes/pull/3111#discussion_r1709185478
########## ui/cypress/tests/datalake/timeOrderDataView.spec.ts: ########## @@ -0,0 +1,73 @@ +/* + * 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 Order in Data Explorer', () => { + beforeEach('Setup Test', () => { + cy.initStreamPipesTest(); + DataLakeUtils.loadDataIntoDataLake('datalake/sample.csv', false); + DataLakeUtils.goToDatalake(); + DataLakeUtils.createAndEditDataView('TestView'); + }); + + it('Perform Test with ascending and descending order', () => { + const startDate = new Date(1653871499055); + const endDate = new Date(1653871608093); + + DataLakeUtils.clickOrderBy('descending'); + + DataLakeUtils.openVisualizationConfig(); + DataLakeUtils.selectVisualizationType('Table'); + DataLakeUtils.selectTimeRange(startDate, endDate); + cy.wait(1000); + + cy.get('table.mat-mdc-table tbody tr td').then($cells => { + const strings = $cells.map((index, cell) => cell.innerText).get(); + + // Check for date strings if order is descending + const dateStrings = strings.filter((_, index) => index % 4 === 0); + const dates = dateStrings.map(dateStr => new Date(dateStr)); + const timestamps = dates.map(date => date.getTime()); + for (let i = 0; i < timestamps.length - 1; i++) { + expect(timestamps[i]).to.be.at.least(timestamps[i + 1]); + } + }); + + // Save and leave view, edit view again and check ascending order + cy.dataCy('save-data-view-btn').click(); + cy.dataCy('edit-data-view-NewWidget').click(); + DataLakeUtils.clickOrderBy('ascending'); + DataLakeUtils.openVisualizationConfig(); + DataLakeUtils.selectVisualizationType('Table'); + DataLakeUtils.selectTimeRange(startDate, endDate); + cy.wait(1000); + + cy.get('table.mat-mdc-table tbody tr td').then($cells => { Review Comment: Maybe this can be replaced with ` cy.dataCy('data-explorer-table-row-timestamp')`, you can have a look at `table.spec.ts` ########## ui/cypress/tests/datalake/timeOrderDataView.spec.ts: ########## @@ -0,0 +1,73 @@ +/* + * 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 Order in Data Explorer', () => { + beforeEach('Setup Test', () => { + cy.initStreamPipesTest(); + DataLakeUtils.loadDataIntoDataLake('datalake/sample.csv', false); + DataLakeUtils.goToDatalake(); + DataLakeUtils.createAndEditDataView('TestView'); + }); + + it('Perform Test with ascending and descending order', () => { + const startDate = new Date(1653871499055); + const endDate = new Date(1653871608093); + + DataLakeUtils.clickOrderBy('descending'); + + DataLakeUtils.openVisualizationConfig(); + DataLakeUtils.selectVisualizationType('Table'); + DataLakeUtils.selectTimeRange(startDate, endDate); + cy.wait(1000); + + cy.get('table.mat-mdc-table tbody tr td').then($cells => { + const strings = $cells.map((index, cell) => cell.innerText).get(); + + // Check for date strings if order is descending + const dateStrings = strings.filter((_, index) => index % 4 === 0); + const dates = dateStrings.map(dateStr => new Date(dateStr)); + const timestamps = dates.map(date => date.getTime()); + for (let i = 0; i < timestamps.length - 1; i++) { + expect(timestamps[i]).to.be.at.least(timestamps[i + 1]); + } + }); + + // Save and leave view, edit view again and check ascending order + cy.dataCy('save-data-view-btn').click(); Review Comment: You can think about putting the buttons in DataLakeBtns -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
