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 7a92df5edb Minor code improvements two e2e tests (#3415)
7a92df5edb is described below
commit 7a92df5edb1870fff1fb480cb765ba9fe15556ca
Author: Philipp Zehnder <[email protected]>
AuthorDate: Mon Jan 13 08:50:34 2025 +0100
Minor code improvements two e2e tests (#3415)
* refactor: Update general.spec.ts
* refactor: Update labels.spec.ts
---
ui/cypress/support/utils/UserUtils.ts | 6 +++-
.../utils/configuration/ConfigurationBtns.ts | 34 ++++++++++++++++++++
.../utils/configuration/ConfigurationUtils.ts | 24 ++++++++++++++
.../apiDocumentation.smoke.spec.ts | 4 ++-
.../tests/configuration/labels/general.spec.ts | 37 ++++++++++++++--------
.../tests/configuration/labels/labels.spec.ts | 20 +++++-------
ui/cypress/tests/login/login.smoke.spec.ts | 2 +-
7 files changed, 99 insertions(+), 28 deletions(-)
diff --git a/ui/cypress/support/utils/UserUtils.ts
b/ui/cypress/support/utils/UserUtils.ts
index 6498976d2c..26802e32ea 100644
--- a/ui/cypress/support/utils/UserUtils.ts
+++ b/ui/cypress/support/utils/UserUtils.ts
@@ -36,6 +36,10 @@ export class UserUtils {
.addRole(UserRole.ROLE_CONNECT_ADMIN)
.build();
+ public static goToLogin() {
+ cy.visit('#/login');
+ }
+
public static goToUserConfiguration() {
cy.visit('#/configuration/security');
}
@@ -83,7 +87,7 @@ export class UserUtils {
public static switchUser(user: User) {
cy.logout();
- cy.visit('#/login');
+ UserUtils.goToLogin();
cy.dataCy('login-email').type(user.email);
cy.dataCy('login-password').type(user.password);
cy.dataCy('login-button').click();
diff --git a/ui/cypress/support/utils/configuration/ConfigurationBtns.ts
b/ui/cypress/support/utils/configuration/ConfigurationBtns.ts
new file mode 100644
index 0000000000..e556425409
--- /dev/null
+++ b/ui/cypress/support/utils/configuration/ConfigurationBtns.ts
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ */
+export class ConfigurationBtns {
+ public static generalConfigAppNameInput() {
+ return cy.dataCy('general-config-app-name');
+ }
+
+ public static generalConfigHostnameInput() {
+ return cy.dataCy('general-config-hostname');
+ }
+
+ public static generalConfigPortInput() {
+ return cy.dataCy('general-config-port');
+ }
+
+ public static generalConfigSaveBtn() {
+ return cy.dataCy('sp-element-general-config-save');
+ }
+}
diff --git a/ui/cypress/support/utils/configuration/ConfigurationUtils.ts
b/ui/cypress/support/utils/configuration/ConfigurationUtils.ts
index f8148033e5..62a0ad65e3 100644
--- a/ui/cypress/support/utils/configuration/ConfigurationUtils.ts
+++ b/ui/cypress/support/utils/configuration/ConfigurationUtils.ts
@@ -28,4 +28,28 @@ export class ConfigurationUtils {
public static goToGeneralConfiguration() {
cy.visit('#/configuration/general');
}
+
+ public static goToLabelConfiguration() {
+ cy.visit('#/configuration/labels');
+ }
+
+ public static addNewLabel(name: string, description: string) {
+ cy.dataCy('new-label-button').click();
+ cy.dataCy('label-name').type(name);
+ cy.dataCy('label-description').type(description);
+ cy.dataCy('save-label-button').click();
+ }
+
+ public static checkLabel(labelName: string) {
+ cy.dataCy('available-labels-list').should('have.length', 1);
+ cy.dataCy('label-text').should($el => {
+ const text = $el.text().trim();
+ expect(text).to.equal(labelName);
+ });
+ }
+
+ public static deleteLabel() {
+ cy.dataCy('delete-label-button').click();
+ cy.dataCy('available-labels-list').should('have.length', 0);
+ }
}
diff --git a/ui/cypress/tests/apiDocumentation/apiDocumentation.smoke.spec.ts
b/ui/cypress/tests/apiDocumentation/apiDocumentation.smoke.spec.ts
index 7ab8372ef7..b36775afeb 100644
--- a/ui/cypress/tests/apiDocumentation/apiDocumentation.smoke.spec.ts
+++ b/ui/cypress/tests/apiDocumentation/apiDocumentation.smoke.spec.ts
@@ -16,9 +16,11 @@
*
*/
+import { UserUtils } from '../../support/utils/UserUtils';
+
describe('Open API Documentation from Login Page', () => {
it('Perform Test', () => {
- cy.visit('#/login');
+ UserUtils.goToLogin();
cy.dataCy('view-api-docs-link').click();
cy.get('h2').contains('Apache StreamPipes API');
cy.get('.servers')
diff --git a/ui/cypress/tests/configuration/labels/general.spec.ts
b/ui/cypress/tests/configuration/labels/general.spec.ts
index 46162c7080..af67d11f13 100644
--- a/ui/cypress/tests/configuration/labels/general.spec.ts
+++ b/ui/cypress/tests/configuration/labels/general.spec.ts
@@ -16,28 +16,39 @@
*
*/
+import { ConfigurationUtils } from
'../../../support/utils/configuration/ConfigurationUtils';
+import { DashboardUtils } from '../../../support/utils/DashboardUtils';
+import { ConfigurationBtns } from
'../../../support/utils/configuration/ConfigurationBtns';
+
describe('Change basic settings', () => {
beforeEach('Setup Test', () => {
cy.initStreamPipesTest();
});
it('Perform Test', () => {
- cy.visit('#/configuration/general');
+ ConfigurationUtils.goToGeneralConfiguration();
+ const appName = 'TEST APP';
+ const hostname = 'testHost';
+ const port = '123';
// Rename app, change localhost and port
- cy.dataCy('general-config-app-name').clear();
- cy.dataCy('general-config-app-name').type('TEST APP');
- cy.dataCy('general-config-hostname').clear();
- cy.dataCy('general-config-hostname').type('testhost');
- cy.dataCy('general-config-port').clear();
- cy.dataCy('general-config-port').type('123');
- cy.dataCy('sp-element-general-config-save').click();
+ ConfigurationBtns.generalConfigAppNameInput().clear().type(appName);
+ ConfigurationBtns.generalConfigHostnameInput().clear().type(hostname);
+ ConfigurationBtns.generalConfigPortInput().clear().type(port);
+ ConfigurationBtns.generalConfigSaveBtn().click();
// Leave, Re-visit configuration and check values
- cy.visit('#/dashboard');
- cy.visit('#/configuration/general');
- cy.dataCy('general-config-app-name').should('have.value', 'TEST APP');
- cy.dataCy('general-config-hostname').should('have.value', 'testhost');
- cy.dataCy('general-config-port').should('have.value', '123');
+ DashboardUtils.goToDashboard();
+
+ ConfigurationUtils.goToGeneralConfiguration();
+ ConfigurationBtns.generalConfigAppNameInput().should(
+ 'have.value',
+ appName,
+ );
+ ConfigurationBtns.generalConfigHostnameInput().should(
+ 'have.value',
+ hostname,
+ );
+ ConfigurationBtns.generalConfigPortInput().should('have.value', port);
});
});
diff --git a/ui/cypress/tests/configuration/labels/labels.spec.ts
b/ui/cypress/tests/configuration/labels/labels.spec.ts
index 703085ef7e..aececff1ac 100644
--- a/ui/cypress/tests/configuration/labels/labels.spec.ts
+++ b/ui/cypress/tests/configuration/labels/labels.spec.ts
@@ -16,26 +16,22 @@
*
*/
+import { ConfigurationUtils } from
'../../../support/utils/configuration/ConfigurationUtils';
+
describe('Add and Delete Label', () => {
beforeEach('Setup Test', () => {
cy.initStreamPipesTest();
});
it('Perform Test', () => {
- cy.visit('#/configuration/labels');
+ const labelName = 'test';
+
+ ConfigurationUtils.goToLabelConfiguration();
- // Add new label
- cy.dataCy('new-label-button').click();
- cy.dataCy('label-name').type('test');
- cy.dataCy('label-description').type('test test');
- cy.dataCy('save-label-button').click();
+ ConfigurationUtils.addNewLabel(labelName, 'test test');
- // Check label
- cy.dataCy('available-labels-list').should('have.length', 1);
- cy.dataCy('label-text').should('have.text', ' test\n');
+ ConfigurationUtils.checkLabel(labelName);
- // Delete label
- cy.dataCy('delete-label-button').click();
- cy.dataCy('available-labels-list').should('have.length', 0);
+ ConfigurationUtils.deleteLabel();
});
});
diff --git a/ui/cypress/tests/login/login.smoke.spec.ts
b/ui/cypress/tests/login/login.smoke.spec.ts
index 1af5e1832c..aa83ce1a94 100644
--- a/ui/cypress/tests/login/login.smoke.spec.ts
+++ b/ui/cypress/tests/login/login.smoke.spec.ts
@@ -20,7 +20,7 @@ import { UserUtils } from '../../support/utils/UserUtils';
describe('Login and logout of StreamPipes', () => {
it('Perform Test', () => {
- cy.visit('#/login');
+ UserUtils.goToLogin();
cy.dataCy('login-email').type(UserUtils.adminUser.email);
cy.dataCy('login-password').type(UserUtils.adminUser.password);
cy.dataCy('login-button').click();