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

#12452 UI - Cypress Test Coverage #14877

Merged
merged 10 commits into from
Jan 26, 2024
106 changes: 106 additions & 0 deletions openmetadata-ui/src/main/resources/ui/cypress/common/EntityUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
*/

import {
DASHBOARD_SERVICE_DETAILS,
DATABASE_DETAILS,
DATABASE_SERVICE_DETAILS,
MESSAGING_SERVICE_DETAILS,
ML_MODEL_SERVICE_DETAILS,
PIPELINE_SERVICE_DETAILS,
SCHEMA_DETAILS,
STORAGE_SERVICE_DETAILS,
} from '../constants/EntityConstant';
import { uuid } from './common';

Expand Down Expand Up @@ -154,6 +159,107 @@ export const generateRandomTable = () => {
return table;
};

export const generateRandomTopic = () => {
const topicName = `cypress-topic-${uuid()}`;
const topicDetails = {
name: topicName,
service: MESSAGING_SERVICE_DETAILS.name,
messageSchema: {
schemaText: `{"type":"object","required":["name","age","club_name"],"properties":{"name":{"type":"object","required":["first_name","last_name"],
"properties":{"first_name":{"type":"string"},"last_name":{"type":"string"}}},"age":{"type":"integer"},"club_name":{"type":"string"}}}`,
schemaType: 'JSON',
schemaFields: [
{
name: 'default',
dataType: 'RECORD',
fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default`,
tags: [],
children: [
{
name: 'name',
dataType: 'RECORD',
fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.name`,
tags: [],
children: [
{
name: 'first_name',
dataType: 'STRING',
description: 'Description for schema field first_name',
fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.name.first_name`,
tags: [],
},
{
name: 'last_name',
dataType: 'STRING',
fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.name.last_name`,
tags: [],
},
],
},
{
name: 'age',
dataType: 'INT',
fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.age`,
tags: [],
},
{
name: 'club_name',
dataType: 'STRING',
fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.club_name`,
tags: [],
},
],
},
],
},
partitions: 128,
};

return topicDetails;
};

export const generateRandomDashboard = () => {
const dashboardName = `cypress-dashboard-${uuid()}`;

const dashboardDetails = {
name: dashboardName,
displayName: dashboardName,
service: DASHBOARD_SERVICE_DETAILS.name,
};

return dashboardDetails;
};

export const generateRandomPipeline = () => {
return {
name: `cypress-pipeline-${uuid()}`,
service: PIPELINE_SERVICE_DETAILS.name,
tasks: [{ name: 'snowflake_task' }],
};
};

export const generateRandomMLModel = () => {
return {
name: `cypress-mlmodel-${uuid()}`,
service: ML_MODEL_SERVICE_DETAILS.name,
algorithm: 'Time Series',
mlFeatures: [
{
name: 'sales',
dataType: 'numerical',
description: 'Sales amount',
},
],
};
};

export const generateRandomContainer = () => {
return {
name: `cypress-container-${uuid()}`,
service: STORAGE_SERVICE_DETAILS.name,
};
};

/**
* get Table by name and create query in the table
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export const visitEntityDetailsPage = ({
}
});

verifyResponseStatusCode('@getEntityDetails', 200);
cy.wait('@getEntityDetails');
cy.clickOutside();
cy.get('[data-testid="searchBox"]').clear();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { interceptURL, verifyResponseStatusCode } from '../common';
import { interceptURL, uuid, verifyResponseStatusCode } from '../common';

const userURL =
'/api/v1/search/query?q=**%20AND%20isBot:false&from=0&size=0&index=user_search_index';
const teamURL =
'/api/v1/search/query?q=*%20AND%20teamType:Group&from=0&size=10&index=team_search_index&sort_field=displayName.keyword&sort_order=asc';

export const generateRandomUser = () => {
return {
firstName: `firstName-${uuid()}`,
lastName: `lastName-${uuid()}`,
email: `user${uuid()}@example.com`,
password: 'User@OMD123',
};
};

export const validateOwnerAndTeamCounts = () => {
cy.getAllLocalStorage().then((data) => {
const token = Object.values(data)[0].oidcIdToken;
Expand Down
16 changes: 16 additions & 0 deletions openmetadata-ui/src/main/resources/ui/cypress/common/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,29 @@ export const mySqlConnectionInput = () => {

export const login = (username, password) => {
cy.visit('/');
interceptURL('POST', '/api/v1/users/login', 'loginUser');
cy.get('[id="email"]').should('be.visible').clear().type(username);
cy.get('[id="password"]').should('be.visible').clear().type(password);

// Don't want to show any popup in the tests
cy.setCookie(`STAR_OMD_USER_${username.split('@')[0]}`, 'true');

// Get version and set cookie to hide version banner
cy.request({
method: 'GET',
url: `api/v1/system/version`,
}).then((res) => {
const version = res.body.version;
const versionCookie = `VERSION_${version
.split('-')[0]
.replaceAll('.', '_')}`;

cy.setCookie(versionCookie, 'true');
window.localStorage.setItem('loggedInUsers', username.split('@')[0]);
});

cy.get('.ant-btn').contains('Login').should('be.visible').click();
verifyResponseStatusCode('@loginUser', 200);
};

export const selectTeamHierarchy = (index) => {
Expand Down
Loading
Loading