This is an automated email from the ASF dual-hosted git repository. zehnder pushed a commit to branch hotfix-minor-test-improvements in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 82a586a9b840a88c9a47f19743f068d1fc6d4345 Author: Philipp Zehnder <[email protected]> AuthorDate: Thu Jan 9 17:55:54 2025 +0100 refactor: Update general.spec.ts --- ui/cypress/support/utils/UserUtils.ts | 6 +++- .../utils/configuration/ConfigurationBtns.ts | 34 ++++++++++++++++++++ .../apiDocumentation.smoke.spec.ts | 4 ++- .../tests/configuration/labels/general.spec.ts | 37 ++++++++++++++-------- ui/cypress/tests/login/login.smoke.spec.ts | 2 +- 5 files changed, 67 insertions(+), 16 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/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/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();
