From 8bb9168c0e6e7e1770e1b9d1291978d75bd00890 Mon Sep 17 00:00:00 2001 From: Marcelfrueh <78954450+Marcelfrueh@users.noreply.github.com> Date: Sat, 11 Nov 2023 08:35:05 +0100 Subject: [PATCH] Add new test for editing dashboard (#2142) * add new test for editing dashboard * Add new edit-dashboard-test --- .../tests/dashboard/editDashboardTest.spec.ts | 73 +++++++++++++++++++ .../dashboard-overview.component.html | 1 + .../widget/dashboard-widget.component.html | 7 +- .../add-visualization-dialog.component.html | 1 + 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 ui/cypress/tests/dashboard/editDashboardTest.spec.ts diff --git a/ui/cypress/tests/dashboard/editDashboardTest.spec.ts b/ui/cypress/tests/dashboard/editDashboardTest.spec.ts new file mode 100644 index 0000000000..194af94af7 --- /dev/null +++ b/ui/cypress/tests/dashboard/editDashboardTest.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 { ConnectUtils } from '../../support/utils/connect/ConnectUtils'; +import { DashboardUtils } from '../../support/utils/DashboardUtils'; + +describe('Test edit dashboard', () => { + beforeEach('Setup Test', () => { + cy.initStreamPipesTest(); + ConnectUtils.addMachineDataSimulator('simulator', true); + }); + + it('Perform Test', () => { + DashboardUtils.goToDashboard(); + + // Add new dashboard + const dashboardName = 'testDashboard'; + DashboardUtils.addAndEditDashboard(dashboardName); + DashboardUtils.addWidget('Persist_simulator', 'raw'); + cy.dataCy('save-data-explorer-go-back-to-overview').click(); + cy.dataCy('confirm-delete').click(); + + // Change dashboard name + cy.dataCy('change-dashboard-settings-button').click(); + cy.dataCy('dashboard-name-input') + .clear() + .type(dashboardName + 'New') + .wait(1000); + cy.dataCy('dashboard-save-btn').should('not.be.disabled'); + cy.dataCy('dashboard-save-btn').click(); + + // Verify that new dashboard was renamed correctly + cy.contains('testDashboardNew').should('exist'); + + // Edit dashboard and change widget to line chart + cy.dataCy('edit-dashboard-testDashboardNew').click().wait(1000); + cy.dataCy('widget-settings-button').click(); + cy.dataCy('edit-widget-back-btn').click(); + cy.dataCy('dashboard-select-widget-line').click(); + cy.dataCy('min-y-axis-key').type('40'); + cy.dataCy('max-y-axis-key').type('50'); + cy.dataCy('dashboard-new-widget-next-btn').should('not.be.disabled'); + cy.dataCy('dashboard-new-widget-next-btn').click(); + + // Verify that new dashboard displays correct chart + cy.get('g').should('have.class', 'line-chart chart'); + + // Add second chart, single value chart + DashboardUtils.addWidget('Persist_simulator', 'number'); + + // Go back and check if two newly added charts are displayed correctly in standalone dashboard + cy.dataCy('save-data-explorer-go-back-to-overview').click(); + cy.dataCy('confirm-delete').click(); + cy.dataCy('show-dashboard-testDashboardNew').click(); + cy.get('g').should('have.class', 'line-chart chart'); + cy.get('div').should('have.class', 'circleNumber'); + }); +}); diff --git a/ui/src/app/dashboard/components/overview/dashboard-overview.component.html b/ui/src/app/dashboard/components/overview/dashboard-overview.component.html index 4538f38b86..d5a2f05918 100644 --- a/ui/src/app/dashboard/components/overview/dashboard-overview.component.html +++ b/ui/src/app/dashboard/components/overview/dashboard-overview.component.html @@ -147,6 +147,7 @@ (click)=" openEditDashboardDialog(element) " + data-cy="change-dashboard-settings-button" > settings