Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor code improvements two e2e tests #3415

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ui/cypress/support/utils/UserUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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();
Expand Down
34 changes: 34 additions & 0 deletions ui/cypress/support/utils/configuration/ConfigurationBtns.ts
Original file line number Diff line number Diff line change
@@ -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');
}
}
24 changes: 24 additions & 0 deletions ui/cypress/support/utils/configuration/ConfigurationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
37 changes: 24 additions & 13 deletions ui/cypress/tests/configuration/labels/general.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
20 changes: 8 additions & 12 deletions ui/cypress/tests/configuration/labels/labels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
2 changes: 1 addition & 1 deletion ui/cypress/tests/login/login.smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading