This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new 4b019a8f8 Add new test for widgets (#2226)
4b019a8f8 is described below
commit 4b019a8f8b63ada7bbe525df211c43b5c1861093
Author: Marcelfrueh <[email protected]>
AuthorDate: Mon Nov 27 14:25:04 2023 +0100
Add new test for widgets (#2226)
---
ui/cypress/support/utils/DashboardUtils.ts | 55 ++++++++++++++-
.../tests/dashboard/dashboardWidgets.spec.ts | 81 ++++++++++++++++++++++
.../widget/dashboard-widget.component.html | 7 +-
3 files changed, 141 insertions(+), 2 deletions(-)
diff --git a/ui/cypress/support/utils/DashboardUtils.ts
b/ui/cypress/support/utils/DashboardUtils.ts
index 04a72a75d..46268b417 100644
--- a/ui/cypress/support/utils/DashboardUtils.ts
+++ b/ui/cypress/support/utils/DashboardUtils.ts
@@ -43,7 +43,11 @@ export class DashboardUtils {
cy.dataCy('edit-dashboard-' + dashboardName).click();
}
- public static addWidget(pipelineName: string, widgetType: string) {
+ public static addWidget(
+ pipelineName: string,
+ widgetType: string,
+ options?,
+ ) {
// Add raw data widget
cy.dataCy('dashboard-add-widget').click();
@@ -52,11 +56,27 @@ export class DashboardUtils {
// Select widget
cy.dataCy('dashboard-select-widget-' + widgetType).click();
+
+ if (widgetType == 'area' || widgetType == 'line') {
+ cy.dataCy('min-y-axis-key').type(options.minYaxis);
+ cy.dataCy('max-y-axis-key').type(options.maxYaxis);
+ } else if (widgetType == 'gauge') {
+ cy.dataCy('min-key').type(options.minYaxis);
+ cy.dataCy('max-key').type(options.maxYaxis);
+ } else if (widgetType == 'status') {
+ cy.dataCy('interval-key').type(options.intervalKey);
+ } else if (widgetType == 'trafficlight') {
+ cy.dataCy('critical-value-key').type(options.criticalValue);
+ cy.dataCy('warning-range').type(options.warningRange);
+ }
+
// optional configure widget
cy.dataCy('dashboard-new-widget-next-btn').click();
// Finish edit mode
cy.dataCy('dashboard-save-edit-mode').click();
+
+ cy.wait(1000);
}
public static validateRawWidgetEvents(amountOfEvents: number) {
@@ -64,4 +84,37 @@ export class DashboardUtils {
.its('length')
.should('be.gte', amountOfEvents);
}
+
+ public static removeWidgetFromDashboard(dashboardName: string) {
+ cy.visit('#/dashboard');
+ cy.dataCy('edit-dashboard-' + dashboardName).click();
+ cy.dataCy('widget-remove-button').click();
+ }
+
+ public static testWidget(
+ widgetType: string,
+ dashboardName: string,
+ options?: {
+ minYaxis?: string;
+ maxYaxis?: string;
+ intervalKey?: string;
+ criticalValue?: string;
+ warningRange?: string;
+ },
+ ) {
+ DashboardUtils.addWidget('Persist_simulator', widgetType, options);
+ if (widgetType == 'status') {
+ cy.get(`sp-dashboard-${widgetType.toLowerCase()}-widget`).should(
+ 'be.visible',
+ );
+ } else if (widgetType == 'trafficlight') {
+ cy.get(`sp-traffic-light-widget`).should('be.visible');
+ } else {
+ cy.get(`sp-${widgetType.toLowerCase()}-widget`).should(
+ 'be.visible',
+ );
+ }
+
+ DashboardUtils.removeWidgetFromDashboard(dashboardName);
+ }
}
diff --git a/ui/cypress/tests/dashboard/dashboardWidgets.spec.ts
b/ui/cypress/tests/dashboard/dashboardWidgets.spec.ts
new file mode 100644
index 000000000..2ef797590
--- /dev/null
+++ b/ui/cypress/tests/dashboard/dashboardWidgets.spec.ts
@@ -0,0 +1,81 @@
+/*
+ * 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 All Widgets', () => {
+ const dashboardName = 'testDashboard';
+
+ beforeEach('Setup Test', () => {
+ cy.initStreamPipesTest();
+ ConnectUtils.addMachineDataSimulator('simulator', true);
+ DashboardUtils.goToDashboard();
+ });
+
+ it('Perform Test', () => {
+ DashboardUtils.addAndEditDashboard(dashboardName);
+
+ // Test area chart
+ DashboardUtils.testWidget('area', dashboardName, {
+ minYaxis: '0',
+ maxYaxis: '50',
+ });
+
+ // Test bar race chart
+ DashboardUtils.testWidget('bar-race', dashboardName);
+
+ // Test gauge widget
+ DashboardUtils.testWidget('gauge', dashboardName, {
+ minYaxis: '0',
+ maxYaxis: '50',
+ });
+
+ // Test html widget
+ DashboardUtils.testWidget('html', dashboardName);
+
+ // Test line widget
+ DashboardUtils.testWidget('line', dashboardName, {
+ minYaxis: '0',
+ maxYaxis: '50',
+ });
+
+ // Test raw widget
+ DashboardUtils.testWidget('raw', dashboardName);
+
+ // Test single value widget
+ DashboardUtils.testWidget('number', dashboardName);
+
+ // Test stacked line chart widget
+ DashboardUtils.testWidget('stacked-line-chart', dashboardName);
+
+ // Test status widget
+ DashboardUtils.testWidget('status', dashboardName, {
+ intervalKey: '5',
+ });
+
+ // Test table widget
+ DashboardUtils.testWidget('table', dashboardName);
+
+ // Test traffic light widget
+ DashboardUtils.testWidget('trafficlight', dashboardName, {
+ warningRange: '5',
+ criticalValue: '5',
+ });
+ });
+});
diff --git
a/ui/src/app/dashboard/components/widget/dashboard-widget.component.html
b/ui/src/app/dashboard/components/widget/dashboard-widget.component.html
index a0ae353dd..9ed91e5b8 100644
--- a/ui/src/app/dashboard/components/widget/dashboard-widget.component.html
+++ b/ui/src/app/dashboard/components/widget/dashboard-widget.component.html
@@ -31,7 +31,12 @@
>
<i class="material-icons">settings</i>
</button>
- <button mat-icon-button color="white" (click)="removeWidget()">
+ <button
+ mat-icon-button
+ color="white"
+ (click)="removeWidget()"
+ data-cy="widget-remove-button"
+ >
<i class="material-icons">clear</i>
</button>
</div>