From 116a9c0b57846072f14abaf89411d7aef8460f6d Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Mon, 20 Nov 2023 23:34:46 +0530 Subject: [PATCH] cypress: fixed cypress AUT failure of main --- .../resources/ui/cypress/common/common.js | 6 +- .../ui/cypress/common/entityUtils.js | 44 ++ .../ui/cypress/constants/entityConstant.js | 85 ++- .../constants/tagsAddRemove.constants.js | 52 +- .../ui/cypress/constants/voting.constant.js | 70 --- .../e2e/Features/DataConsumerRole.spec.js | 81 ++- .../ui/cypress/e2e/Features/Following.spec.js | 89 ++- .../e2e/Features/RecentlyViewed.spec.js | 78 ++- .../e2e/Flow/AddAndRemoveTierAndOwner.spec.js | 109 +++- .../ui/cypress/e2e/Flow/EntityVoting.spec.js | 88 ++- .../ui/cypress/e2e/Flow/TagsAddRemove.spec.js | 112 +++- .../Pages/ClassificationVersionPage.spec.js | 16 +- .../e2e/Pages/DataModelVersionPage.spec.js | 131 ++--- .../Pages/DatabaseSchemaVersionPage.spec.js | 262 +++------ .../e2e/Pages/DatabaseVersionPage.spec.js | 240 +++----- .../e2e/Pages/EntityVersionPages.spec.js | 442 ++++++--------- .../e2e/Pages/GlossaryVersionPage.spec.js | 226 +++----- .../e2e/Pages/SearchIndexDetails.spec.js | 4 - .../e2e/Pages/ServiceVersionPage.spec.js | 512 ++++++++---------- 19 files changed, 1274 insertions(+), 1373 deletions(-) delete mode 100644 openmetadata-ui/src/main/resources/ui/cypress/constants/voting.constant.js diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js index b7ebbb9be4e6..7ff06444c786 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js @@ -1186,13 +1186,13 @@ export const addOwner = ( isGlossaryPage, isOwnerEmpty = false ) => { + interceptURL('GET', '/api/v1/users?limit=*&isBot=false', 'getUsers'); if (isGlossaryPage && isOwnerEmpty) { cy.get('[data-testid="glossary-owner-name"] > [data-testid="Add"]').click(); } else { cy.get('[data-testid="edit-owner"]').click(); } - interceptURL('GET', '/api/v1/users?limit=25&isBot=false', 'getUsers'); cy.get('.ant-tabs [id*=tab-users]').click(); verifyResponseStatusCode('@getUsers', 200); @@ -1265,7 +1265,6 @@ export const deleteEntity = ( entityName, serviceName, entity, - entityType, successMessageEntityName, deletionType = 'hard' ) => { @@ -1273,7 +1272,6 @@ export const deleteEntity = ( term: entityName, serviceName, entity, - entityType, }); cy.get('[data-testid="manage-button"]').click(); @@ -1417,7 +1415,7 @@ export const signupAndLogin = (email, password, firstName, lastName) => { // Login with the created user login(email, password); - cy.goToHomePage(true); + // cy.goToHomePage(true); cy.url().should('eq', `${BASE_URL}/my-data`); // Verify user profile diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/entityUtils.js b/openmetadata-ui/src/main/resources/ui/cypress/common/entityUtils.js index 7d784ead8922..a052e200c2a2 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/entityUtils.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/entityUtils.js @@ -174,3 +174,47 @@ export const createQueryByTableName = (token, table) => { }); }); }; + +/** + * Create a new user + */ +export const createUserEntity = ({ token, user }) => { + cy.request({ + method: 'POST', + url: `/api/v1/users/signup`, + headers: { Authorization: `Bearer ${token}` }, + body: user, + }).then((response) => { + user.id = response.body.id; + }); +}; + +/** + * Delete a user by id + */ +export const deleteUserEntity = ({ token, id }) => { + cy.request({ + method: 'DELETE', + url: `/api/v1/users/${id}?hardDelete=true&recursive=false`, + headers: { Authorization: `Bearer ${token}` }, + }); +}; + +/** + * Delete any entity by id + */ +export const deleteEntityById = ({ entityType, token, entityFqn }) => { + cy.request({ + method: 'GET', + url: `/api/v1/${entityType}/name/${entityFqn}`, + headers: { Authorization: `Bearer ${token}` }, + }).then((response) => { + cy.request({ + method: 'DELETE', + url: `/api/v1/${entityType}/${response.body.id}?hardDelete=true&recursive=true`, + headers: { Authorization: `Bearer ${token}` }, + }).then((response) => { + expect(response.status).to.eq(200); + }); + }); +}; diff --git a/openmetadata-ui/src/main/resources/ui/cypress/constants/entityConstant.js b/openmetadata-ui/src/main/resources/ui/cypress/constants/entityConstant.js index fa7e8143edcf..c9d270ba7818 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/constants/entityConstant.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/constants/entityConstant.js @@ -10,7 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { uuid } from './constants'; +import { MYDATA_SUMMARY_OPTIONS, uuid } from './constants'; import { SERVICE_CATEGORIES } from './service.constants'; const DATABASE_SERVICE_NAME = `cy-database-service-${uuid()}`; @@ -267,23 +267,44 @@ export const DASHBOARD_DETAILS = { displayName: DASHBOARD_NAME, service: DASHBOARD_SERVICE_DETAILS.name, }; +export const DASHBOARD_CHART_DETAILS = { + name: 'dashboard-chart', + displayName: 'dashboard-chart', + service: DASHBOARD_SERVICE_DETAILS.name, +}; export const DASHBOARD_DATA_MODEL_DETAILS = { name: DASHBOARD_DATA_MODEL_NAME, displayName: DASHBOARD_DATA_MODEL_NAME, service: DASHBOARD_SERVICE_DETAILS.name, - columns: [], + columns: [ + { + name: 'country_name', + dataType: 'VARCHAR', + dataLength: 256, + dataTypeDisplay: 'varchar', + description: 'Name of the country.', + }, + ], dataModelType: 'SupersetDataModel', }; export const PIPELINE_DETAILS = { name: `cypress-pipeline-${uuid()}`, service: PIPELINE_SERVICE_DETAILS.name, + tasks: [{ name: 'snowflake_task' }], }; export const ML_MODEL_DETAILS = { name: `cypress-mlmodel-${uuid()}`, service: ML_MODEL_SERVICE_DETAILS.name, algorithm: 'Time Series', + mlFeatures: [ + { + name: 'sales', + dataType: 'numerical', + description: 'Sales amount', + }, + ], }; export const CONTAINER_DETAILS = { @@ -342,3 +363,63 @@ export const SINGLE_LEVEL_SERVICE = [ MLMODEL_SERVICE, STORAGE_SERVICE, ]; + +// visit entity details page object +export const VISIT_ENTITIES_DATA = { + table: { + term: DATABASE_SERVICE.tables.name, + displayName: DATABASE_SERVICE.tables.name, + entity: MYDATA_SUMMARY_OPTIONS.tables, + serviceName: DATABASE_SERVICE.service.name, + schemaName: DATABASE_SERVICE.schema.name, + entityType: 'Table', + }, + topic: { + term: MESSAGING_SERVICE.entity.name, + displayName: MESSAGING_SERVICE.entity.name, + entity: MYDATA_SUMMARY_OPTIONS.topics, + serviceName: MESSAGING_SERVICE.service.name, + entityType: 'Topic', + }, + dashboard: { + term: DASHBOARD_SERVICE.entity.name, + displayName: DASHBOARD_SERVICE.entity.name, + entity: MYDATA_SUMMARY_OPTIONS.dashboards, + serviceName: DASHBOARD_SERVICE.service.name, + entityType: 'Dashboard', + }, + pipeline: { + term: PIPELINE_SERVICE.entity.name, + displayName: PIPELINE_SERVICE.entity.name, + entity: MYDATA_SUMMARY_OPTIONS.pipelines, + serviceName: PIPELINE_SERVICE.service.name, + entityType: 'Pipeline', + }, + mlmodel: { + term: MLMODEL_SERVICE.entity.name, + displayName: MLMODEL_SERVICE.entity.name, + entity: MYDATA_SUMMARY_OPTIONS.mlmodels, + serviceName: MLMODEL_SERVICE.service.name, + entityType: 'ML Model', + }, + storedProcedure: { + term: STORED_PROCEDURE_DETAILS.name, + displayName: STORED_PROCEDURE_DETAILS.name, + entity: MYDATA_SUMMARY_OPTIONS.storedProcedures, + serviceName: DATABASE_SERVICE_DETAILS.name, + entityType: 'Stored Procedure', + }, + dataModel: { + term: DASHBOARD_DATA_MODEL_DETAILS.name, + entity: MYDATA_SUMMARY_OPTIONS.dataModel, + serviceName: DASHBOARD_DATA_MODEL_DETAILS.service, + displayName: DASHBOARD_DATA_MODEL_DETAILS.name, + entityType: 'Data Model', + }, + container: { + term: STORAGE_SERVICE.entity.name, + displayName: STORAGE_SERVICE.entity.name, + entity: 'containers', + serviceName: STORAGE_SERVICE.service.name, + }, +}; diff --git a/openmetadata-ui/src/main/resources/ui/cypress/constants/tagsAddRemove.constants.js b/openmetadata-ui/src/main/resources/ui/cypress/constants/tagsAddRemove.constants.js index 83419e0108f9..1aa4b20355d6 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/constants/tagsAddRemove.constants.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/constants/tagsAddRemove.constants.js @@ -1,3 +1,6 @@ +import { generateRandomTable } from '../common/entityUtils'; +import { DATABASE_SERVICE, VISIT_ENTITIES_DATA } from './entityConstant'; + /* * Copyright 2023 Collate. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,74 +14,55 @@ * limitations under the License. */ +export const TAGS_ADD_REMOVE_TABLE = generateRandomTable(); + export const TAGS_ADD_REMOVE_ENTITIES = [ { - term: 'marketing', - displayName: 'marketing', + term: TAGS_ADD_REMOVE_TABLE.name, + displayName: TAGS_ADD_REMOVE_TABLE.name, entity: 'tables', - serviceName: 'sample_data', - fieldName: 'SKU', + serviceName: DATABASE_SERVICE.service.name, + fieldName: TAGS_ADD_REMOVE_TABLE.columns[0].name, tags: ['PersonalData.Personal', 'PII.Sensitive'], permissionApi: '/api/v1/permissions/*/name/*', }, { - term: 'address_book', - displayName: 'address_book', - entity: 'topics', - serviceName: 'sample_kafka', - fieldName: 'AddressBook', + ...VISIT_ENTITIES_DATA.topic, + fieldName: 'first_name', tags: ['PersonalData.Personal', 'PII.Sensitive'], permissionApi: '/api/v1/permissions/*/name/*', }, { - term: 'deck.gl Demo', - displayName: 'deck.gl Demo', - entity: 'dashboards', + ...VISIT_ENTITIES_DATA.dashboard, insideEntity: 'charts', - serviceName: 'sample_superset', fieldName: 'e3cfd274-44f8-4bf3-b75d-d40cf88869ba', tags: ['PersonalData.Personal', 'PII.Sensitive'], permissionApi: '/api/v1/permissions/*/*', }, { - term: 'dim_address_etl', - displayName: 'dim_address etl', - entity: 'pipelines', - serviceName: 'sample_airflow', - fieldName: 'dim_address_task', + ...VISIT_ENTITIES_DATA.pipeline, + fieldName: 'snowflake_task', tags: ['PersonalData.Personal', 'PII.Sensitive'], permissionApi: '/api/v1/permissions/*/*', }, { - term: 'eta_predictions', - displayName: 'ETA Predictions', - entity: 'mlmodels', - serviceName: 'mlflow_svc', + ...VISIT_ENTITIES_DATA.mlmodel, fieldName: 'sales', tags: ['PersonalData.Personal', 'PII.Sensitive'], permissionApi: '/api/v1/permissions/*/*', }, { - term: 'engineering', - displayName: 'Engineering department', - entity: 'containers', - serviceName: 's3_storage_sample', + ...VISIT_ENTITIES_DATA.container, tags: ['PersonalData.Personal', 'PII.Sensitive'], permissionApi: '/api/v1/permissions/*/name/*', }, { - term: 'update_orders_table', - displayName: 'update_orders_table', - entity: 'storedProcedures', - serviceName: 'sample_data', + ...VISIT_ENTITIES_DATA.storedProcedure, tags: ['PersonalData.Personal', 'PII.Sensitive'], permissionApi: '/api/v1/permissions/*/name/*', }, { - term: 'orders_view', - displayName: 'orders_view', - entity: 'dashboardDataModel', - serviceName: 'sample_looker', + ...VISIT_ENTITIES_DATA.dataModel, tags: ['PersonalData.Personal', 'PII.Sensitive'], permissionApi: '/api/v1/permissions/*/name/*', }, diff --git a/openmetadata-ui/src/main/resources/ui/cypress/constants/voting.constant.js b/openmetadata-ui/src/main/resources/ui/cypress/constants/voting.constant.js deleted file mode 100644 index 062fa7667873..000000000000 --- a/openmetadata-ui/src/main/resources/ui/cypress/constants/voting.constant.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2023 Collate. - * Licensed 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 const VOTING_ENTITIES = [ - { - term: 'marketing', - displayName: 'marketing', - entity: 'tables', - serviceName: 'sample_data', - fieldName: 'SKU', - permissionApi: '/api/v1/permissions/*/name/*', - }, - { - term: 'address_book', - displayName: 'address_book', - entity: 'topics', - serviceName: 'sample_kafka', - fieldName: 'AddressBook', - permissionApi: '/api/v1/permissions/*/name/*', - }, - { - term: 'deck.gl Demo', - displayName: 'deck.gl Demo', - entity: 'dashboards', - insideEntity: 'charts', - serviceName: 'sample_superset', - fieldName: 'e3cfd274-44f8-4bf3-b75d-d40cf88869ba', - permissionApi: '/api/v1/permissions/*/*', - }, - { - term: 'dim_address_etl', - displayName: 'dim_address etl', - entity: 'pipelines', - serviceName: 'sample_airflow', - fieldName: 'dim_address_task', - permissionApi: '/api/v1/permissions/*/*', - }, - { - term: 'eta_predictions', - displayName: 'ETA Predictions', - entity: 'mlmodels', - serviceName: 'mlflow_svc', - fieldName: 'sales', - permissionApi: '/api/v1/permissions/*/*', - }, - { - term: 'update_orders_table', - displayName: 'update_orders_table', - entity: 'storedProcedures', - serviceName: 'sample_data', - permissionApi: '/api/v1/permissions/*/name/*', - }, - { - term: 'orders_view', - displayName: 'orders_view', - entity: 'dashboardDataModel', - serviceName: 'sample_looker', - permissionApi: '/api/v1/permissions/*/name/*', - }, -]; diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/DataConsumerRole.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/DataConsumerRole.spec.js index fbe440d30e58..f9af5a82b8c4 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/DataConsumerRole.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/DataConsumerRole.spec.js @@ -21,13 +21,18 @@ import { visitEntityDetailsPage, } from '../../common/common'; import { - BASE_URL, - SEARCH_ENTITY_DASHBOARD, - SEARCH_ENTITY_PIPELINE, - SEARCH_ENTITY_TABLE, - SEARCH_ENTITY_TOPIC, -} from '../../constants/constants'; + createEntityTable, + createSingleLevelEntity, + hardDeleteService, +} from '../../common/entityUtils'; +import { BASE_URL } from '../../constants/constants'; +import { + DATABASE_SERVICE, + SINGLE_LEVEL_SERVICE, + VISIT_ENTITIES_DATA, +} from '../../constants/entityConstant'; import { NAVBAR_DETAILS } from '../../constants/redirections.constants'; +import { SERVICE_CATEGORIES } from '../../constants/service.constants'; const CREDENTIALS = { firstName: 'Test_Data_Consumer', @@ -35,13 +40,13 @@ const CREDENTIALS = { email: `test_dataconsumer${uuid()}@openmetadata.org`, password: 'User@OMD123', }; - +const { dashboard, pipeline, table, topic } = VISIT_ENTITIES_DATA; const policy = 'Data Consumer'; const ENTITIES = { - table: SEARCH_ENTITY_TABLE.table_2, - topic: SEARCH_ENTITY_TOPIC.topic_1, - dashboard: SEARCH_ENTITY_DASHBOARD.dashboard_1, - pipeline: SEARCH_ENTITY_PIPELINE.pipeline_1, + dashboard, + pipeline, + table, + topic, }; const glossary = NAVBAR_DETAILS.glossary; @@ -119,6 +124,49 @@ const PERMISSIONS = { }; describe('DataConsumer Edit policy should work properly', () => { + before(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + createEntityTable({ + token, + ...DATABASE_SERVICE, + tables: [DATABASE_SERVICE.tables], + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + createSingleLevelEntity({ + token, + ...data, + entity: [data.entity], + }); + }); + }); + cy.logout(); + }); + + after(() => { + Cypress.session.clearAllSavedSessions(); + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + hardDeleteService({ + token, + serviceFqn: DATABASE_SERVICE.service.name, + serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES, + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + hardDeleteService({ + token, + serviceFqn: data.service.name, + serviceType: data.serviceType, + }); + }); + }); + deleteUser(CREDENTIALS.id); + }); + it('Create a new account and assign Data consumer role to the user', () => { signupAndLogin( CREDENTIALS.email, @@ -263,14 +311,3 @@ describe('DataConsumer Edit policy should work properly', () => { }); }); }); - -describe('Cleanup', () => { - beforeEach(() => { - Cypress.session.clearAllSavedSessions(); - cy.login(); - }); - - it('delete user', () => { - deleteUser(CREDENTIALS.id); - }); -}); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/Following.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/Following.spec.js index 599cd948ea70..e341a322d35a 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/Following.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/Following.spec.js @@ -16,27 +16,31 @@ import { visitEntityDetailsPage, } from '../../common/common'; import { - SEARCH_ENTITY_DASHBOARD, - SEARCH_ENTITY_DATA_MODEL, - SEARCH_ENTITY_MLMODEL, - SEARCH_ENTITY_PIPELINE, - SEARCH_ENTITY_STORED_PROCEDURE, - SEARCH_ENTITY_TABLE, - SEARCH_ENTITY_TOPIC, -} from '../../constants/constants'; + createEntityTable, + createSingleLevelEntity, + hardDeleteService, +} from '../../common/entityUtils'; +import { + DASHBOARD_DATA_MODEL_DETAILS, + DATABASE_SERVICE, + SINGLE_LEVEL_SERVICE, + STORED_PROCEDURE_DETAILS, + VISIT_ENTITIES_DATA, +} from '../../constants/entityConstant'; +import { SERVICE_CATEGORIES } from '../../constants/service.constants'; // eslint-disable-next-line spaced-comment /// // Update list if we support this for other entities too const FOLLOWING_ENTITIES = [ - SEARCH_ENTITY_TABLE.table_2, - SEARCH_ENTITY_DASHBOARD.dashboard_1, - SEARCH_ENTITY_TOPIC.topic_1, - SEARCH_ENTITY_PIPELINE.pipeline_1, - SEARCH_ENTITY_MLMODEL.mlmodel_2, - SEARCH_ENTITY_STORED_PROCEDURE.stored_procedure_2, - SEARCH_ENTITY_DATA_MODEL.data_model_2, + VISIT_ENTITIES_DATA.table, + VISIT_ENTITIES_DATA.dashboard, + VISIT_ENTITIES_DATA.topic, + VISIT_ENTITIES_DATA.pipeline, + VISIT_ENTITIES_DATA.mlmodel, + VISIT_ENTITIES_DATA.storedProcedure, + VISIT_ENTITIES_DATA.dataModel, ]; const followEntity = ({ term, serviceName, entity }, isUnfollow) => { @@ -72,6 +76,61 @@ const followEntity = ({ term, serviceName, entity }, isUnfollow) => { }; describe('Following data assets', () => { + before(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + createEntityTable({ + token, + ...DATABASE_SERVICE, + tables: [DATABASE_SERVICE.tables], + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + createSingleLevelEntity({ + token, + ...data, + entity: [data.entity], + }); + }); + + // creating data model + cy.request({ + method: 'POST', + url: `/api/v1/dashboard/datamodels`, + headers: { Authorization: `Bearer ${token}` }, + body: DASHBOARD_DATA_MODEL_DETAILS, + }); + // creating stored procedure + cy.request({ + method: 'POST', + url: `/api/v1/storedProcedures`, + headers: { Authorization: `Bearer ${token}` }, + body: STORED_PROCEDURE_DETAILS, + }); + }); + }); + + after(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + hardDeleteService({ + token, + serviceFqn: DATABASE_SERVICE.service.name, + serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES, + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + hardDeleteService({ + token, + serviceFqn: data.service.name, + serviceType: data.serviceType, + }); + }); + }); + }); + beforeEach(() => { cy.login(); cy.get("[data-testid='welcome-screen-close-btn']").click(); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/RecentlyViewed.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/RecentlyViewed.spec.js index 88b547948ed4..f44cd387983e 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/RecentlyViewed.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/RecentlyViewed.spec.js @@ -16,28 +16,80 @@ import { visitEntityDetailsPage, } from '../../common/common'; import { - SEARCH_ENTITY_DASHBOARD, - SEARCH_ENTITY_MLMODEL, - SEARCH_ENTITY_PIPELINE, - SEARCH_ENTITY_STORED_PROCEDURE, - SEARCH_ENTITY_TABLE, - SEARCH_ENTITY_TOPIC, -} from '../../constants/constants'; + createEntityTable, + createSingleLevelEntity, + hardDeleteService, +} from '../../common/entityUtils'; +import { + DATABASE_SERVICE, + SINGLE_LEVEL_SERVICE, + STORED_PROCEDURE_DETAILS, + VISIT_ENTITIES_DATA, +} from '../../constants/entityConstant'; +import { SERVICE_CATEGORIES } from '../../constants/service.constants'; // eslint-disable-next-line spaced-comment /// // Update list if we support this for other entities too const RECENTLY_VIEW_ENTITIES = [ - SEARCH_ENTITY_TABLE.table_2, - SEARCH_ENTITY_DASHBOARD.dashboard_1, - SEARCH_ENTITY_TOPIC.topic_1, - SEARCH_ENTITY_PIPELINE.pipeline_1, - SEARCH_ENTITY_MLMODEL.mlmodel_2, - SEARCH_ENTITY_STORED_PROCEDURE.stored_procedure_2, + VISIT_ENTITIES_DATA.table, + VISIT_ENTITIES_DATA.dashboard, + VISIT_ENTITIES_DATA.topic, + VISIT_ENTITIES_DATA.pipeline, + VISIT_ENTITIES_DATA.mlmodel, + VISIT_ENTITIES_DATA.storedProcedure, ]; describe('Recently viwed data assets', () => { + before(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + createEntityTable({ + token, + ...DATABASE_SERVICE, + tables: [DATABASE_SERVICE.tables], + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + createSingleLevelEntity({ + token, + ...data, + entity: [data.entity], + }); + }); + + // creating stored procedure + cy.request({ + method: 'POST', + url: `/api/v1/storedProcedures`, + headers: { Authorization: `Bearer ${token}` }, + body: STORED_PROCEDURE_DETAILS, + }); + }); + }); + + after(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + hardDeleteService({ + token, + serviceFqn: DATABASE_SERVICE.service.name, + serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES, + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + hardDeleteService({ + token, + serviceFqn: data.service.name, + serviceType: data.serviceType, + }); + }); + }); + }); + beforeEach(() => { cy.login(); cy.get("[data-testid='welcome-screen-close-btn']").click(); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddAndRemoveTierAndOwner.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddAndRemoveTierAndOwner.spec.js index 28a604dc7689..f8591f4892ea 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddAndRemoveTierAndOwner.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/AddAndRemoveTierAndOwner.spec.js @@ -24,31 +24,40 @@ import { visitEntityDetailsPage, } from '../../common/common'; import { - DELETE_TERM, - SEARCH_ENTITY_DASHBOARD, - SEARCH_ENTITY_MLMODEL, - SEARCH_ENTITY_PIPELINE, - SEARCH_ENTITY_STORED_PROCEDURE, - SEARCH_ENTITY_TABLE, - SEARCH_ENTITY_TOPIC, -} from '../../constants/constants'; + createEntityTable, + createSingleLevelEntity, + createUserEntity, + deleteEntityById, + deleteUserEntity, + hardDeleteService, +} from '../../common/entityUtils'; +import { DELETE_TERM, uuid } from '../../constants/constants'; +import { + DATABASE_SERVICE, + SINGLE_LEVEL_SERVICE, + STORED_PROCEDURE_DETAILS, + VISIT_ENTITIES_DATA, +} from '../../constants/entityConstant'; +import { USER_CREDENTIALS } from '../../constants/SearchIndexDetails.constants'; +import { SERVICE_CATEGORIES } from '../../constants/service.constants'; const ENTITIES = { table: { - ...SEARCH_ENTITY_TABLE.table_5, - schema: 'shopify', - database: 'ecommerce_db', + ...VISIT_ENTITIES_DATA.table, + schema: DATABASE_SERVICE.schema.name, + database: DATABASE_SERVICE.database.name, }, - topic: SEARCH_ENTITY_TOPIC.topic_2, - dashboard: SEARCH_ENTITY_DASHBOARD.dashboard_2, - pipeline: SEARCH_ENTITY_PIPELINE.pipeline_2, - mlmodel: SEARCH_ENTITY_MLMODEL.mlmodel_2, - storedProcedure: SEARCH_ENTITY_STORED_PROCEDURE.stored_procedure_2, + topic: VISIT_ENTITIES_DATA.topic, + dashboard: VISIT_ENTITIES_DATA.dashboard, + pipeline: VISIT_ENTITIES_DATA.pipeline, + mlmodel: VISIT_ENTITIES_DATA.mlmodel, + storedProcedure: VISIT_ENTITIES_DATA.storedProcedure, }; +const TEST_SUITE = { name: `aaa-cypress-test-suite-${uuid()}` }; const glossary = 'GlossaryOwnerTest'; const glossaryTerm = 'GlossaryTermOwnerTest'; -const OWNER = 'Amber Green'; +const OWNER = `${USER_CREDENTIALS.firstName}${USER_CREDENTIALS.lastName}`; const TIER = 'Tier1'; const addRemoveOwner = (ownerName, entity, isGlossaryPage) => { @@ -63,6 +72,44 @@ const addRemoveTier = (tier, entity) => { }; describe('Add and Remove Owner', () => { + before(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + createEntityTable({ + token, + ...DATABASE_SERVICE, + tables: [DATABASE_SERVICE.tables], + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + createSingleLevelEntity({ + token, + ...data, + entity: [data.entity], + }); + }); + + // creating stored procedure + cy.request({ + method: 'POST', + url: `/api/v1/storedProcedures`, + headers: { Authorization: `Bearer ${token}` }, + body: STORED_PROCEDURE_DETAILS, + }); + + // creating test suite + cy.request({ + method: 'POST', + url: `/api/v1/dataQuality/testSuites`, + headers: { Authorization: `Bearer ${token}` }, + body: TEST_SUITE, + }); + + createUserEntity({ token, user: USER_CREDENTIALS }); + }); + }); + beforeEach(() => { interceptURL('GET', '/api/v1/permissions/*/name/*', 'entityPermission'); interceptURL('GET', '/api/v1/feed/count?entityLink=*', 'activityFeed'); @@ -323,6 +370,34 @@ describe('Add and Remove Owner', () => { }); describe('Add and Remove Tier', () => { + after(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + hardDeleteService({ + token, + serviceFqn: DATABASE_SERVICE.service.name, + serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES, + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + hardDeleteService({ + token, + serviceFqn: data.service.name, + serviceType: data.serviceType, + }); + }); + deleteUserEntity({ token, id: USER_CREDENTIALS.id }); + + // Delete test suite + deleteEntityById({ + entityFqn: TEST_SUITE.name, + entityType: 'dataQuality/testSuites', + token, + }); + }); + }); + beforeEach(() => { interceptURL('GET', '/api/v1/permissions/*/name/*', 'entityPermission'); interceptURL('GET', '/api/v1/feed/count?entityLink=*', 'activityFeed'); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/EntityVoting.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/EntityVoting.spec.js index e50796cb09ca..87733757242e 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/EntityVoting.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/EntityVoting.spec.js @@ -16,9 +16,86 @@ import { verifyResponseStatusCode, visitEntityDetailsPage, } from '../../common/common'; -import { VOTING_ENTITIES } from '../../constants/voting.constant'; +import { + createEntityTable, + createSingleLevelEntity, + hardDeleteService, +} from '../../common/entityUtils'; +import { + DASHBOARD_DATA_MODEL_DETAILS, + DATABASE_SERVICE, + SINGLE_LEVEL_SERVICE, + STORED_PROCEDURE_DETAILS, + VISIT_ENTITIES_DATA, +} from '../../constants/entityConstant'; +import { SERVICE_CATEGORIES } from '../../constants/service.constants'; + +const VOTING_ENTITIES = [ + VISIT_ENTITIES_DATA.table, + VISIT_ENTITIES_DATA.topic, + VISIT_ENTITIES_DATA.dashboard, + VISIT_ENTITIES_DATA.pipeline, + VISIT_ENTITIES_DATA.mlmodel, + VISIT_ENTITIES_DATA.storedProcedure, + VISIT_ENTITIES_DATA.dataModel, +]; describe('Check if voting work properly in entities', () => { + before(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + createEntityTable({ + token, + ...DATABASE_SERVICE, + tables: [DATABASE_SERVICE.tables], + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + createSingleLevelEntity({ + token, + ...data, + entity: [data.entity], + }); + }); + + // creating data model + cy.request({ + method: 'POST', + url: `/api/v1/dashboard/datamodels`, + headers: { Authorization: `Bearer ${token}` }, + body: DASHBOARD_DATA_MODEL_DETAILS, + }); + // creating stored procedure + cy.request({ + method: 'POST', + url: `/api/v1/storedProcedures`, + headers: { Authorization: `Bearer ${token}` }, + body: STORED_PROCEDURE_DETAILS, + }); + }); + }); + + after(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + hardDeleteService({ + token, + serviceFqn: DATABASE_SERVICE.service.name, + serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES, + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + hardDeleteService({ + token, + serviceFqn: data.service.name, + serviceType: data.serviceType, + }); + }); + }); + }); + beforeEach(() => { cy.login(); }); @@ -30,8 +107,6 @@ describe('Check if voting work properly in entities', () => { : entityDetails.entity; it(`UpVote the ${entityDetails.entity} entity`, () => { - interceptURL('GET', entityDetails.permissionApi, 'getEntityPermission'); - interceptURL( 'GET', `/api/v1/${apiEntity}/name/*?fields=*`, @@ -45,7 +120,6 @@ describe('Check if voting work properly in entities', () => { entity: entityDetails.entity, }); verifyResponseStatusCode('@getEntityDetail', 200); - verifyResponseStatusCode('@getEntityPermission', 200); cy.get('[data-testid="up-vote-btn"]').click(); @@ -66,8 +140,6 @@ describe('Check if voting work properly in entities', () => { : entityDetails.entity; it(`DownVote the ${entityDetails.entity} entity`, () => { - interceptURL('GET', entityDetails.permissionApi, 'getEntityPermission'); - interceptURL( 'GET', `/api/v1/${apiEntity}/name/*?fields=*`, @@ -81,7 +153,6 @@ describe('Check if voting work properly in entities', () => { entity: entityDetails.entity, }); verifyResponseStatusCode('@getEntityDetail', 200); - verifyResponseStatusCode('@getEntityPermission', 200); cy.get('[data-testid="up-vote-count"]').contains(1); @@ -105,8 +176,6 @@ describe('Check if voting work properly in entities', () => { : entityDetails.entity; it(`UnVote the ${entityDetails.entity} entity`, () => { - interceptURL('GET', entityDetails.permissionApi, 'getEntityPermission'); - interceptURL( 'GET', `/api/v1/${apiEntity}/name/*?fields=*`, @@ -120,7 +189,6 @@ describe('Check if voting work properly in entities', () => { entity: entityDetails.entity, }); verifyResponseStatusCode('@getEntityDetail', 200); - verifyResponseStatusCode('@getEntityPermission', 200); cy.get('[data-testid="down-vote-count"]').contains(1); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/TagsAddRemove.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/TagsAddRemove.spec.js index c3909ce584d9..4169f4b632fb 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/TagsAddRemove.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Flow/TagsAddRemove.spec.js @@ -19,7 +19,40 @@ import { verifyResponseStatusCode, visitEntityDetailsPage, } from '../../common/common'; -import { TAGS_ADD_REMOVE_ENTITIES } from '../../constants/tagsAddRemove.constants'; +import { + createEntityTable, + createSingleLevelEntity, +} from '../../common/entityUtils'; +import { + DASHBOARD_CHART_DETAILS, + DASHBOARD_DATA_MODEL_DETAILS, + DASHBOARD_DETAILS, + DASHBOARD_SERVICE, + DATABASE_SERVICE, + MESSAGING_SERVICE, + MLMODEL_SERVICE, + PIPELINE_SERVICE, + STORAGE_SERVICE, + STORED_PROCEDURE_DETAILS, +} from '../../constants/entityConstant'; +import { + TAGS_ADD_REMOVE_ENTITIES, + TAGS_ADD_REMOVE_TABLE, +} from '../../constants/tagsAddRemove.constants'; + +const SINGLE_LEVEL_SERVICE = [ + MESSAGING_SERVICE, + PIPELINE_SERVICE, + MLMODEL_SERVICE, + STORAGE_SERVICE, +]; + +const DASHBOARD_SERVICE_WITH_CHART = { + ...DASHBOARD_DETAILS, + charts: [ + `${DASHBOARD_CHART_DETAILS.service}.${DASHBOARD_CHART_DETAILS.name}`, + ], +}; const addTags = (tag) => { const tagName = Cypress._.split(tag, '.')[1]; @@ -105,6 +138,83 @@ const removeTags = (checkForParentEntity) => { }; describe('Check if tags addition and removal flow working properly from tables', () => { + before(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + + createEntityTable({ + token, + ...DATABASE_SERVICE, + tables: [TAGS_ADD_REMOVE_TABLE], + }); + SINGLE_LEVEL_SERVICE.forEach((data) => { + createSingleLevelEntity({ + token, + ...data, + entity: [data.entity], + }); + }); + + // create dashboard service + cy.request({ + method: 'POST', + url: `/api/v1/services/${DASHBOARD_SERVICE.serviceType}`, + headers: { Authorization: `Bearer ${token}` }, + body: DASHBOARD_SERVICE.service, + }); + // creating chart + cy.request({ + method: 'POST', + url: `/api/v1/charts`, + headers: { Authorization: `Bearer ${token}` }, + body: DASHBOARD_CHART_DETAILS, + }); + // creating dashboard + cy.request({ + method: 'POST', + url: `/api/v1/dashboards`, + headers: { Authorization: `Bearer ${token}` }, + body: DASHBOARD_SERVICE_WITH_CHART, + }); + + // creating data model + cy.request({ + method: 'POST', + url: `/api/v1/dashboard/datamodels`, + headers: { Authorization: `Bearer ${token}` }, + body: DASHBOARD_DATA_MODEL_DETAILS, + }); + // creating stored procedure + cy.request({ + method: 'POST', + url: `/api/v1/storedProcedures`, + headers: { Authorization: `Bearer ${token}` }, + body: STORED_PROCEDURE_DETAILS, + }); + }); + }); + + // after(() => { + // cy.login(); + // cy.getAllLocalStorage().then((data) => { + // const token = Object.values(data)[0].oidcIdToken; + + // hardDeleteService({ + // token, + // serviceFqn: DATABASE_SERVICE.service.name, + // serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES, + // }); + // SINGLE_LEVEL_SERVICE.forEach((data) => { + // hardDeleteService({ + // token, + // serviceFqn: data.service.name, + // serviceType: data.serviceType, + // }); + // }); + // }); + // }); + beforeEach(() => { cy.login(); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/ClassificationVersionPage.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/ClassificationVersionPage.spec.js index e98967eb356f..3f3960172664 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/ClassificationVersionPage.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/ClassificationVersionPage.spec.js @@ -139,13 +139,8 @@ describe('Classification version page should work properly', () => { `/api/v1/classifications/${classificationId}/versions`, 'getVersionsList' ); - interceptURL( - 'GET', - `/api/v1/classifications/${classificationId}/versions/0.3`, - 'getSelectedVersionDetails' - ); - cy.get('[data-testid="version-button"]').contains('0.3').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode(`@getClassificationDetails`, 200); verifyResponseStatusCode('@getVersionsList', 200); @@ -153,7 +148,7 @@ describe('Classification version page should work properly', () => { cy.get('[data-testid="disabled"]').should('be.visible'); - cy.get('[data-testid="version-button"]').contains('0.3').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); cy.get('[data-testid="manage-button"]').click({ waitForAnimations: true }); @@ -171,13 +166,8 @@ describe('Classification version page should work properly', () => { `/api/v1/classifications/${classificationId}/versions`, 'getVersionsList' ); - interceptURL( - 'GET', - `/api/v1/classifications/${classificationId}/versions/0.4`, - 'getSelectedVersionDetails' - ); - cy.get('[data-testid="version-button"]').contains('0.4').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode(`@getClassificationDetails`, 200); verifyResponseStatusCode('@getVersionsList', 200); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataModelVersionPage.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataModelVersionPage.spec.js index 72e62349c2c2..483a5c34b554 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataModelVersionPage.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DataModelVersionPage.spec.js @@ -17,8 +17,6 @@ import { addOwner, addTier, interceptURL, - removeOwner, - removeTier, toastNotification, verifyResponseStatusCode, visitDataModelPage, @@ -38,38 +36,37 @@ describe('Data model version page should work properly', () => { let dataModelId; let dataModelFQN; - beforeEach(() => { + before(() => { cy.login(); - }); - - it('Prerequisite for data model version page tests', () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'PUT', - url: `/api/v1/dashboard/datamodels`, - headers: { Authorization: `Bearer ${token}` }, - body: DATA_MODEL_DETAILS_FOR_VERSION_TEST, - }).then((response) => { - expect(response.status).to.eq(201); - - dataModelId = response.body.id; - dataModelFQN = response.body.fullyQualifiedName; + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; cy.request({ - method: 'PATCH', - url: `/api/v1/dashboard/datamodels/${dataModelId}`, - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json-patch+json', - }, - body: DATA_MODEL_PATCH_PAYLOAD, + method: 'PUT', + url: `/api/v1/dashboard/datamodels`, + headers: { Authorization: `Bearer ${token}` }, + body: DATA_MODEL_DETAILS_FOR_VERSION_TEST, }).then((response) => { - expect(response.status).to.eq(200); + dataModelId = response.body.id; + dataModelFQN = response.body.fullyQualifiedName; + + cy.request({ + method: 'PATCH', + url: `/api/v1/dashboard/datamodels/${dataModelId}`, + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json-patch+json', + }, + body: DATA_MODEL_PATCH_PAYLOAD, + }); }); }); }); + beforeEach(() => { + cy.login(); + }); + it('Data model version page should show description and tag changes properly', () => { visitDataModelVersionPage(dataModelFQN, dataModelId, dataModelName, '0.2'); @@ -104,42 +101,12 @@ describe('Data model version page should work properly', () => { .should('be.visible'); }); - it(`Data model version page should show removed tags changes properly`, () => { - visitDataModelPage(dataModelFQN, dataModelName); - - cy.get( - '[data-testid="entity-right-panel"] [data-testid="edit-button"]' - ).click(); - - cy.get( - '[data-testid="selected-tag-PersonalData.SpecialCategory"] [data-testid="remove-tags"]' - ).click(); - - interceptURL( - 'PATCH', - `/api/v1/dashboard/datamodels/${dataModelId}`, - `patchDataModel` - ); - - cy.get('[data-testid="saveAssociatedTag"]').click(); - - verifyResponseStatusCode(`@patchDataModel`, 200); - - cy.get('[data-testid="version-button"]').contains('0.3').click(); - - cy.get( - `[data-testid="entity-right-panel"] .diff-removed [data-testid="tag-PersonalData.SpecialCategory"]` - ) - .scrollIntoView() - .should('be.visible'); - }); - it(`Data model version page should show owner changes properly`, () => { visitDataModelPage(dataModelFQN, dataModelName); cy.get('[data-testid="version-button"]').as('versionButton'); - cy.get('@versionButton').contains('0.3'); + cy.get('@versionButton').contains('0.2'); addOwner(OWNER, 'dashboard/datamodels'); @@ -155,35 +122,17 @@ describe('Data model version page should work properly', () => { ); interceptURL( 'GET', - `/api/v1/dashboard/datamodels/${dataModelId}/versions/0.4`, + `/api/v1/dashboard/datamodels/${dataModelId}/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('@versionButton').contains('0.4').click(); + cy.get('@versionButton').contains('0.2').click(); verifyResponseStatusCode(`@getDataModelDetails`, 200); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); - cy.get(`[data-testid="diff-added"]`).scrollIntoView().should('be.visible'); - - cy.get('@versionButton').contains('0.4').click(); - - removeOwner('dashboard/datamodels'); - - interceptURL( - 'GET', - `/api/v1/dashboard/datamodels/${dataModelId}/versions/0.5`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.5').click(); - - verifyResponseStatusCode(`@getDataModelDetails`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-removed"]`) + cy.get('[data-testid="owner-link"] > [data-testid="diff-added"]') .scrollIntoView() .should('be.visible'); }); @@ -193,7 +142,7 @@ describe('Data model version page should work properly', () => { cy.get('[data-testid="version-button"]').as('versionButton'); - cy.get('@versionButton').contains('0.5'); + cy.get('@versionButton').contains('0.2'); addTier(TIER, 'dashboard/datamodels'); @@ -209,35 +158,17 @@ describe('Data model version page should work properly', () => { ); interceptURL( 'GET', - `/api/v1/dashboard/datamodels/${dataModelId}/versions/0.6`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.6').click(); - - verifyResponseStatusCode(`@getDataModelDetails`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-added"]`).scrollIntoView().should('be.visible'); - - cy.get('@versionButton').contains('0.6').click(); - - removeTier('dashboard/datamodels'); - - interceptURL( - 'GET', - `/api/v1/dashboard/datamodels/${dataModelId}/versions/0.7`, + `/api/v1/dashboard/datamodels/${dataModelId}/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('@versionButton').contains('0.7').click(); + cy.get('@versionButton').contains('0.2').click(); verifyResponseStatusCode(`@getDataModelDetails`, 200); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); - cy.get(`[data-testid="diff-removed"]`) + cy.get('[data-testid="Tier"] > [data-testid="diff-added"]') .scrollIntoView() .should('be.visible'); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DatabaseSchemaVersionPage.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DatabaseSchemaVersionPage.spec.js index 77c37fb07571..7a0ab8d8cae1 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DatabaseSchemaVersionPage.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DatabaseSchemaVersionPage.spec.js @@ -17,8 +17,6 @@ import { addOwner, addTier, interceptURL, - removeOwner, - removeTier, toastNotification, verifyResponseStatusCode, visitServiceDetailsPage, @@ -38,99 +36,93 @@ const serviceDetails = SERVICE_DETAILS_FOR_VERSION_TEST.Database; let domainId; -describe('Common prerequisite for database schema version test', () => { - beforeEach(() => { - cy.login(); - }); - - it('Domain creation for database schema version test', () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'PUT', - url: `/api/v1/domains`, - headers: { Authorization: `Bearer ${token}` }, - body: DOMAIN_CREATION_DETAILS, - }).then((response) => { - expect(response.status).to.eq(201); - - domainId = response.body.id; - }); - }); -}); - describe(`Database schema version page should work properly`, () => { let databaseId; let databaseSchemaId; let databaseSchemaFQN; - beforeEach(() => { + before(() => { cy.login(); - }); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'PUT', + url: `/api/v1/domains`, + headers: { Authorization: `Bearer ${token}` }, + body: DOMAIN_CREATION_DETAILS, + }).then((response) => { + domainId = response.body.id; + }); - it(`Prerequisite for Database Schema version page tests`, () => { - const token = localStorage.getItem('oidcIdToken'); - - // Create service - cy.request({ - method: 'POST', - url: `/api/v1/services/${serviceDetails.serviceCategory}`, - headers: { Authorization: `Bearer ${token}` }, - body: serviceDetails.entityCreationDetails, - }).then((response) => { - expect(response.status).to.eq(201); - }); + // Create service + cy.request({ + method: 'POST', + url: `/api/v1/services/${serviceDetails.serviceCategory}`, + headers: { Authorization: `Bearer ${token}` }, + body: serviceDetails.entityCreationDetails, + }); - // Create Database - cy.request({ - method: 'POST', - url: `/api/v1/databases`, - headers: { Authorization: `Bearer ${token}` }, - body: DATABASE_DETAILS_FOR_VERSION_TEST, - }).then((response) => { - expect(response.status).to.eq(201); + // Create Database + cy.request({ + method: 'POST', + url: `/api/v1/databases`, + headers: { Authorization: `Bearer ${token}` }, + body: DATABASE_DETAILS_FOR_VERSION_TEST, + }).then((response) => { + databaseId = response.body.id; + }); - databaseId = response.body.id; + // Create Database Schema + cy.request({ + method: 'PUT', + url: `/api/v1/databaseSchemas`, + headers: { Authorization: `Bearer ${token}` }, + body: DATABASE_SCHEMA_DETAILS_FOR_VERSION_TEST, + }).then((response) => { + databaseSchemaId = response.body.id; + databaseSchemaFQN = response.body.fullyQualifiedName; + + cy.request({ + method: 'PATCH', + url: `/api/v1/databaseSchemas/${databaseSchemaId}`, + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json-patch+json', + }, + body: [ + ...COMMON_PATCH_PAYLOAD, + { + op: 'add', + path: '/domain', + value: { + id: domainId, + type: 'domain', + name: DOMAIN_CREATION_DETAILS.name, + description: DOMAIN_CREATION_DETAILS.description, + }, + }, + ], + }); + }); }); + }); - // Create Database Schema - cy.request({ - method: 'PUT', - url: `/api/v1/databaseSchemas`, - headers: { Authorization: `Bearer ${token}` }, - body: DATABASE_SCHEMA_DETAILS_FOR_VERSION_TEST, - }).then((response) => { - expect(response.status).to.eq(201); - - databaseSchemaId = response.body.id; - databaseSchemaFQN = response.body.fullyQualifiedName; - + after(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; cy.request({ - method: 'PATCH', - url: `/api/v1/databaseSchemas/${databaseSchemaId}`, - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json-patch+json', - }, - body: [ - ...COMMON_PATCH_PAYLOAD, - { - op: 'add', - path: '/domain', - value: { - id: domainId, - type: 'domain', - name: DOMAIN_CREATION_DETAILS.name, - description: DOMAIN_CREATION_DETAILS.description, - }, - }, - ], - }).then((response) => { - expect(response.status).to.eq(200); + method: 'DELETE', + url: `/api/v1/domains/name/${DOMAIN_CREATION_DETAILS.name}`, + headers: { Authorization: `Bearer ${token}` }, }); }); }); + beforeEach(() => { + cy.login(); + }); + it(`Database Schema version page should show edited tags and description changes properly`, () => { visitServiceDetailsPage( serviceDetails.settingsMenuId, @@ -191,48 +183,6 @@ describe(`Database schema version page should work properly`, () => { .should('be.visible'); }); - it(`Database Schema version page should show removed tags changes properly`, () => { - visitServiceDetailsPage( - serviceDetails.settingsMenuId, - serviceDetails.serviceCategory, - serviceDetails.serviceName - ); - - cy.get(`[data-row-key="${databaseId}"]`) - .contains(DATABASE_DETAILS_FOR_VERSION_TEST.name) - .click(); - - cy.get(`[data-row-key="${databaseSchemaId}"]`) - .contains(DATABASE_SCHEMA_DETAILS_FOR_VERSION_TEST.name) - .click(); - - cy.get( - '[data-testid="entity-right-panel"] [data-testid="edit-button"]' - ).click(); - - cy.get( - '[data-testid="selected-tag-PersonalData.SpecialCategory"] [data-testid="remove-tags"]' - ).click(); - - interceptURL( - 'PATCH', - `/api/v1/databaseSchemas/${databaseSchemaId}`, - `patchDatabase` - ); - - cy.get('[data-testid="saveAssociatedTag"]').click(); - - verifyResponseStatusCode(`@patchDatabase`, 200); - - cy.get('[data-testid="version-button"]').contains('0.3').click(); - - cy.get( - `[data-testid="entity-right-panel"] .diff-removed [data-testid="tag-PersonalData.SpecialCategory"]` - ) - .scrollIntoView() - .should('be.visible'); - }); - it(`Database Schema version page should show owner changes properly`, () => { visitServiceDetailsPage( serviceDetails.settingsMenuId, @@ -250,7 +200,7 @@ describe(`Database schema version page should work properly`, () => { cy.get('[data-testid="version-button"]').as('versionButton'); - cy.get('@versionButton').contains('0.3'); + cy.get('@versionButton').contains('0.2'); addOwner(OWNER, `databaseSchemas`); @@ -266,35 +216,17 @@ describe(`Database schema version page should work properly`, () => { ); interceptURL( 'GET', - `/api/v1/databaseSchemas/${databaseSchemaId}/versions/0.4`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.4').click(); - - verifyResponseStatusCode(`@getDatabaseSchemaDetails`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-added"]`).scrollIntoView().should('be.visible'); - - cy.get('@versionButton').contains('0.4').click(); - - removeOwner(`databaseSchemas`); - - interceptURL( - 'GET', - `/api/v1/databaseSchemas/${databaseSchemaId}/versions/0.5`, + `/api/v1/databaseSchemas/${databaseSchemaId}/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('@versionButton').contains('0.5').click(); + cy.get('@versionButton').contains('0.2').click(); verifyResponseStatusCode(`@getDatabaseSchemaDetails`, 200); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); - cy.get(`[data-testid="diff-removed"]`) + cy.get('[data-testid="owner-link"] > [data-testid="diff-added"]') .scrollIntoView() .should('be.visible'); }); @@ -316,7 +248,7 @@ describe(`Database schema version page should work properly`, () => { cy.get('[data-testid="version-button"]').as('versionButton'); - cy.get('@versionButton').contains('0.5'); + cy.get('@versionButton').contains('0.2'); addTier(TIER, `databaseSchemas`); @@ -332,35 +264,17 @@ describe(`Database schema version page should work properly`, () => { ); interceptURL( 'GET', - `/api/v1/databaseSchemas/${databaseSchemaId}/versions/0.6`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.6').click(); - - verifyResponseStatusCode(`@getDatabaseSchemaDetails`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-added"]`).scrollIntoView().should('be.visible'); - - cy.get('@versionButton').contains('0.6').click(); - - removeTier(`databaseSchemas`); - - interceptURL( - 'GET', - `/api/v1/databaseSchemas/${databaseSchemaId}/versions/0.7`, + `/api/v1/databaseSchemas/${databaseSchemaId}/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('@versionButton').contains('0.7').click(); + cy.get('@versionButton').contains('0.2').click(); verifyResponseStatusCode(`@getDatabaseSchemaDetails`, 200); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); - cy.get(`[data-testid="diff-removed"]`) + cy.get('[data-testid="Tier"] > [data-testid="diff-added"]') .scrollIntoView() .should('be.visible'); }); @@ -421,21 +335,3 @@ describe(`Database schema version page should work properly`, () => { ).should('not.exist'); }); }); - -describe('Common cleanup for database schema version test', () => { - beforeEach(() => { - cy.login(); - }); - - it('Domain deletion for database schema version test', () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'DELETE', - url: `/api/v1/domains/name/${DOMAIN_CREATION_DETAILS.name}`, - headers: { Authorization: `Bearer ${token}` }, - }).then((response) => { - expect(response.status).to.eq(200); - }); - }); -}); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DatabaseVersionPage.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DatabaseVersionPage.spec.js index 70d8df4f6936..8b0c531c5ffa 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DatabaseVersionPage.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/DatabaseVersionPage.spec.js @@ -10,14 +10,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// / + +// eslint-disable-next-line spaced-comment +/// import { addOwner, addTier, interceptURL, - removeOwner, - removeTier, toastNotification, verifyResponseStatusCode, visitServiceDetailsPage, @@ -36,86 +36,82 @@ const serviceDetails = SERVICE_DETAILS_FOR_VERSION_TEST.Database; let domainId; -describe('Common prerequisite for database version test', () => { - beforeEach(() => { - cy.login(); - }); - - it('Domain creation for database version test', () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'PUT', - url: `/api/v1/domains`, - headers: { Authorization: `Bearer ${token}` }, - body: DOMAIN_CREATION_DETAILS, - }).then((response) => { - expect(response.status).to.eq(201); - - domainId = response.body.id; - }); - }); -}); - describe(`Database version page should work properly`, () => { let databaseId; let databaseFQN; - beforeEach(() => { + before(() => { cy.login(); - }); - - it(`Prerequisite for Database version page tests`, () => { - const token = localStorage.getItem('oidcIdToken'); - - // Create service - cy.request({ - method: 'POST', - url: `/api/v1/services/${serviceDetails.serviceCategory}`, - headers: { Authorization: `Bearer ${token}` }, - body: serviceDetails.entityCreationDetails, - }).then((response) => { - expect(response.status).to.eq(201); - }); - - // Create Database - cy.request({ - method: 'POST', - url: `/api/v1/databases`, - headers: { Authorization: `Bearer ${token}` }, - body: DATABASE_DETAILS_FOR_VERSION_TEST, - }).then((response) => { - expect(response.status).to.eq(201); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'PUT', + url: `/api/v1/domains`, + headers: { Authorization: `Bearer ${token}` }, + body: DOMAIN_CREATION_DETAILS, + }).then((response) => { + domainId = response.body.id; + }); - databaseId = response.body.id; - databaseFQN = response.body.fullyQualifiedName; + // Create service + cy.request({ + method: 'POST', + url: `/api/v1/services/${serviceDetails.serviceCategory}`, + headers: { Authorization: `Bearer ${token}` }, + body: serviceDetails.entityCreationDetails, + }); + // Create Database cy.request({ - method: 'PATCH', - url: `/api/v1/databases/${databaseId}`, - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json-patch+json', - }, - body: [ - ...COMMON_PATCH_PAYLOAD, - { - op: 'add', - path: '/domain', - value: { - id: domainId, - type: 'domain', - name: DOMAIN_CREATION_DETAILS.name, - description: DOMAIN_CREATION_DETAILS.description, - }, - }, - ], + method: 'POST', + url: `/api/v1/databases`, + headers: { Authorization: `Bearer ${token}` }, + body: DATABASE_DETAILS_FOR_VERSION_TEST, }).then((response) => { - expect(response.status).to.eq(200); + databaseId = response.body.id; + databaseFQN = response.body.fullyQualifiedName; + + cy.request({ + method: 'PATCH', + url: `/api/v1/databases/${databaseId}`, + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json-patch+json', + }, + body: [ + ...COMMON_PATCH_PAYLOAD, + { + op: 'add', + path: '/domain', + value: { + id: domainId, + type: 'domain', + name: DOMAIN_CREATION_DETAILS.name, + description: DOMAIN_CREATION_DETAILS.description, + }, + }, + ], + }); + }); + }); + }); + + after(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'DELETE', + url: `/api/v1/domains/name/${DOMAIN_CREATION_DETAILS.name}`, + headers: { Authorization: `Bearer ${token}` }, }); }); }); + beforeEach(() => { + cy.login(); + }); + it(`Database version page should show edited tags and description changes properly`, () => { visitServiceDetailsPage( serviceDetails.settingsMenuId, @@ -172,40 +168,6 @@ describe(`Database version page should work properly`, () => { .should('be.visible'); }); - it(`Database version page should show removed tags changes properly`, () => { - visitServiceDetailsPage( - serviceDetails.settingsMenuId, - serviceDetails.serviceCategory, - serviceDetails.serviceName - ); - - cy.get(`[data-row-key="${databaseId}"]`) - .contains(DATABASE_DETAILS_FOR_VERSION_TEST.name) - .click(); - - cy.get( - '[data-testid="entity-right-panel"] [data-testid="edit-button"]' - ).click(); - - cy.get( - '[data-testid="selected-tag-PersonalData.SpecialCategory"] [data-testid="remove-tags"]' - ).click(); - - interceptURL('PATCH', `/api/v1/databases/${databaseId}`, `patchDatabase`); - - cy.get('[data-testid="saveAssociatedTag"]').click(); - - verifyResponseStatusCode(`@patchDatabase`, 200); - - cy.get('[data-testid="version-button"]').contains('0.3').click(); - - cy.get( - `[data-testid="entity-right-panel"] .diff-removed [data-testid="tag-PersonalData.SpecialCategory"]` - ) - .scrollIntoView() - .should('be.visible'); - }); - it(`Database version page should show owner changes properly`, () => { visitServiceDetailsPage( serviceDetails.settingsMenuId, @@ -219,7 +181,7 @@ describe(`Database version page should work properly`, () => { cy.get('[data-testid="version-button"]').as('versionButton'); - cy.get('@versionButton').contains('0.3'); + cy.get('@versionButton').contains('0.2'); addOwner(OWNER, `databases`); @@ -235,35 +197,17 @@ describe(`Database version page should work properly`, () => { ); interceptURL( 'GET', - `/api/v1/databases/${databaseId}/versions/0.4`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.4').click(); - - verifyResponseStatusCode(`@getDatabaseDetails`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-added"]`).scrollIntoView().should('be.visible'); - - cy.get('@versionButton').contains('0.4').click(); - - removeOwner(`databases`); - - interceptURL( - 'GET', - `/api/v1/databases/${databaseId}/versions/0.5`, + `/api/v1/databases/${databaseId}/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('@versionButton').contains('0.5').click(); + cy.get('@versionButton').contains('0.2').click(); verifyResponseStatusCode(`@getDatabaseDetails`, 200); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); - cy.get(`[data-testid="diff-removed"]`) + cy.get('[data-testid="owner-link"] > [data-testid="diff-added"]') .scrollIntoView() .should('be.visible'); }); @@ -281,7 +225,7 @@ describe(`Database version page should work properly`, () => { cy.get('[data-testid="version-button"]').as('versionButton'); - cy.get('@versionButton').contains('0.5'); + cy.get('@versionButton').contains('0.2'); addTier(TIER, `databases`); @@ -297,35 +241,17 @@ describe(`Database version page should work properly`, () => { ); interceptURL( 'GET', - `/api/v1/databases/${databaseId}/versions/0.6`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.6').click(); - - verifyResponseStatusCode(`@getDatabaseDetails`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-added"]`).scrollIntoView().should('be.visible'); - - cy.get('@versionButton').contains('0.6').click(); - - removeTier(`databases`); - - interceptURL( - 'GET', - `/api/v1/databases/${databaseId}/versions/0.7`, + `/api/v1/databases/${databaseId}/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('@versionButton').contains('0.7').click(); + cy.get('@versionButton').contains('0.2').click(); verifyResponseStatusCode(`@getDatabaseDetails`, 200); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); - cy.get(`[data-testid="diff-removed"]`) + cy.get('[data-testid="Tier"] > [data-testid="diff-added"]') .scrollIntoView() .should('be.visible'); }); @@ -382,21 +308,3 @@ describe(`Database version page should work properly`, () => { ).should('not.exist'); }); }); - -describe('Common cleanup for database version test', () => { - beforeEach(() => { - cy.login(); - }); - - it('Domain deletion for database version test', () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'DELETE', - url: `/api/v1/domains/name/${DOMAIN_CREATION_DETAILS.name}`, - headers: { Authorization: `Bearer ${token}` }, - }).then((response) => { - expect(response.status).to.eq(200); - }); - }); -}); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/EntityVersionPages.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/EntityVersionPages.spec.js index 748f1451185e..d3590f4f8d4b 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/EntityVersionPages.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/EntityVersionPages.spec.js @@ -18,8 +18,6 @@ import { addTier, deleteEntity, interceptURL, - removeOwner, - removeTier, verifyResponseStatusCode, visitEntityDetailsPage, } from '../../common/common'; @@ -34,311 +32,221 @@ import { let domainId; describe('Common prerequisite for entity version test', () => { - beforeEach(() => { + before(() => { cy.login(); - }); - - it('Domain creation for entity version test', () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'PUT', - url: `/api/v1/domains`, - headers: { Authorization: `Bearer ${token}` }, - body: DOMAIN_CREATION_DETAILS, - }).then((response) => { - expect(response.status).to.eq(201); - - domainId = response.body.id; + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'PUT', + url: `/api/v1/domains`, + headers: { Authorization: `Bearer ${token}` }, + body: DOMAIN_CREATION_DETAILS, + }).then((response) => { + domainId = response.body.id; + }); }); }); -}); -Object.entries(ENTITY_DETAILS_FOR_VERSION_TEST).map( - ([entityType, entityDetails]) => { - describe(`${entityType} version page should work properly`, () => { - const successMessageEntityName = - entityType === 'ML Model' ? 'Mlmodel' : entityType; - let entityId; - let entityFQN; - - beforeEach(() => { - cy.login(); + after(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'DELETE', + url: `/api/v1/domains/name/${DOMAIN_CREATION_DETAILS.name}`, + headers: { Authorization: `Bearer ${token}` }, }); + }); + }); - it(`Prerequisite for ${entityType} version page test`, () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'PUT', - url: `/api/v1/${entityDetails.entity}`, - headers: { Authorization: `Bearer ${token}` }, - body: entityDetails.entityCreationDetails, - }).then((response) => { - expect(response.status).to.eq(201); - - entityId = response.body.id; - entityFQN = response.body.fullyQualifiedName; - - cy.request({ - method: 'PATCH', - url: `/api/v1/${entityDetails.entity}/${entityId}`, - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json-patch+json', - }, - body: [ - ...entityDetails.entityPatchPayload, - { - op: 'add', - path: '/domain', - value: { - id: domainId, - type: 'domain', - name: DOMAIN_CREATION_DETAILS.name, - description: DOMAIN_CREATION_DETAILS.description, + Object.entries(ENTITY_DETAILS_FOR_VERSION_TEST).map( + ([entityType, entityDetails]) => { + describe(`${entityType} version page should work properly`, () => { + const successMessageEntityName = + entityType === 'ML Model' ? 'Mlmodel' : entityType; + let entityId; + let entityFQN; + + before(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'PUT', + url: `/api/v1/${entityDetails.entity}`, + headers: { Authorization: `Bearer ${token}` }, + body: entityDetails.entityCreationDetails, + }).then((response) => { + entityId = response.body.id; + entityFQN = response.body.fullyQualifiedName; + + cy.request({ + method: 'PATCH', + url: `/api/v1/${entityDetails.entity}/${entityId}`, + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json-patch+json', }, - }, - ], - }).then((response) => { - expect(response.status).to.eq(200); + body: [ + ...entityDetails.entityPatchPayload, + { + op: 'add', + path: '/domain', + value: { + id: domainId, + type: 'domain', + name: DOMAIN_CREATION_DETAILS.name, + description: DOMAIN_CREATION_DETAILS.description, + }, + }, + ], + }); + }); }); }); - }); - it(`${entityType} version page should show description and tag changes properly`, () => { - visitEntityDetailsVersionPage( - entityDetails, - entityId, - entityFQN, - '0.2' - ); - - cy.get(`[data-testid="domain-link"] [data-testid="diff-added"]`) - .scrollIntoView() - .should('be.visible'); - - cy.get( - `[data-testid="asset-description-container"] [data-testid="diff-added"]` - ) - .scrollIntoView() - .should('be.visible'); - - cy.get( - `[data-testid="entity-right-panel"] .diff-added [data-testid="tag-PersonalData.SpecialCategory"]` - ) - .scrollIntoView() - .should('be.visible'); - - if (entityDetails.isChildrenExist) { - cy.get( - `[${entityDetails.childSelector}="${entityDetails.updatedTagEntityChildName}"] .diff-added [data-testid="tag-PersonalData.Personal"]` - ) + beforeEach(() => { + cy.login(); + }); + + it(`${entityType} version page should show description and tag changes properly`, () => { + visitEntityDetailsVersionPage( + entityDetails, + entityId, + entityFQN, + '0.2' + ); + + cy.get(`[data-testid="domain-link"] [data-testid="diff-added"]`) .scrollIntoView() .should('be.visible'); cy.get( - `[${entityDetails.childSelector}="${entityDetails.updatedTagEntityChildName}"] .diff-added [data-testid="tag-PII.Sensitive"]` + `[data-testid="asset-description-container"] [data-testid="diff-added"]` ) .scrollIntoView() .should('be.visible'); - cy.get(`[data-testid="diff-removed"]`) - .contains(entityDetails.entityChildRemovedDescription) - .scrollIntoView() - .should('be.visible'); - - cy.get(`[data-testid="diff-added"]`) - .contains(entityDetails.entityChildAddedDescription) + cy.get( + `[data-testid="entity-right-panel"] .diff-added [data-testid="tag-PersonalData.SpecialCategory"]` + ) .scrollIntoView() .should('be.visible'); - } - }); - it(`${entityType} version page should show removed tags changes properly`, () => { - visitEntityDetailsPage({ - term: entityDetails.name, - serviceName: entityDetails.serviceName, - entity: entityDetails.entity, - entityType: entityType, + if (entityDetails.isChildrenExist) { + cy.get( + `[${entityDetails.childSelector}="${entityDetails.updatedTagEntityChildName}"] .diff-added [data-testid="tag-PersonalData.Personal"]` + ) + .scrollIntoView() + .should('be.visible'); + + cy.get( + `[${entityDetails.childSelector}="${entityDetails.updatedTagEntityChildName}"] .diff-added [data-testid="tag-PII.Sensitive"]` + ) + .scrollIntoView() + .should('be.visible'); + + cy.get(`[data-testid="diff-removed"]`) + .contains(entityDetails.entityChildRemovedDescription) + .scrollIntoView() + .should('be.visible'); + + cy.get(`[data-testid="diff-added"]`) + .contains(entityDetails.entityChildAddedDescription) + .scrollIntoView() + .should('be.visible'); + } }); - cy.get( - '[data-testid="entity-right-panel"] [data-testid="edit-button"]' - ).click(); + it(`${entityType} version page should show owner changes properly`, () => { + visitEntityDetailsPage({ + term: entityDetails.name, + serviceName: entityDetails.serviceName, + entity: entityDetails.entity, + }); - cy.get( - '[data-testid="selected-tag-PersonalData.SpecialCategory"] [data-testid="remove-tags"]' - ).click(); + cy.get('[data-testid="version-button"]').as('versionButton'); - interceptURL( - 'PATCH', - `/api/v1/${entityDetails.entity}/${entityId}`, - `patch${entityType}` - ); + cy.get('@versionButton').contains('0.2'); - cy.get('[data-testid="saveAssociatedTag"]').click(); + addOwner(OWNER, entityDetails.entity); - verifyResponseStatusCode(`@patch${entityType}`, 200); + interceptURL( + 'GET', + `/api/v1/${entityDetails.entity}/name/${entityFQN}?*include=all`, + `get${entityType}Details` + ); + interceptURL( + 'GET', + `/api/v1/${entityDetails.entity}/${entityId}/versions`, + 'getVersionsList' + ); + interceptURL( + 'GET', + `/api/v1/${entityDetails.entity}/${entityId}/versions/0.2`, + 'getSelectedVersionDetails' + ); - cy.get('[data-testid="version-button"]').contains('0.3').click(); + cy.get('@versionButton').contains('0.2').click(); - cy.get( - `[data-testid="entity-right-panel"] .diff-removed [data-testid="tag-PersonalData.SpecialCategory"]` - ) - .scrollIntoView() - .should('be.visible'); - }); + verifyResponseStatusCode(`@get${entityType}Details`, 200); + verifyResponseStatusCode('@getVersionsList', 200); + verifyResponseStatusCode('@getSelectedVersionDetails', 200); - it(`${entityType} version page should show owner changes properly`, () => { - visitEntityDetailsPage({ - term: entityDetails.name, - serviceName: entityDetails.serviceName, - entity: entityDetails.entity, - entityType: entityType, + cy.get('[data-testid="owner-link"] > [data-testid="diff-added"]') + .scrollIntoView() + .should('be.visible'); }); - cy.get('[data-testid="version-button"]').as('versionButton'); - - cy.get('@versionButton').contains('0.3'); - - addOwner(OWNER, entityDetails.entity); - - interceptURL( - 'GET', - `/api/v1/${entityDetails.entity}/name/${entityFQN}?*include=all`, - `get${entityType}Details` - ); - interceptURL( - 'GET', - `/api/v1/${entityDetails.entity}/${entityId}/versions`, - 'getVersionsList' - ); - interceptURL( - 'GET', - `/api/v1/${entityDetails.entity}/${entityId}/versions/0.4`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.4').click(); - - verifyResponseStatusCode(`@get${entityType}Details`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-added`) - .scrollIntoView() - .should('be.visible'); + it(`${entityType} version page should show tier changes properly`, () => { + visitEntityDetailsPage({ + term: entityDetails.name, + serviceName: entityDetails.serviceName, + entity: entityDetails.entity, + }); - cy.get('@versionButton').contains('0.4').click(); + cy.get('[data-testid="version-button"]').as('versionButton'); - removeOwner(entityDetails.entity); + cy.get('@versionButton').contains('0.2'); - interceptURL( - 'GET', - `/api/v1/${entityDetails.entity}/${entityId}/versions/0.5`, - 'getSelectedVersionDetails' - ); + addTier(TIER, entityDetails.entity); - cy.get('@versionButton').contains('0.5').click(); + interceptURL( + 'GET', + `/api/v1/${entityDetails.entity}/name/${entityFQN}?*include=all`, + `get${entityType}Details` + ); + interceptURL( + 'GET', + `/api/v1/${entityDetails.entity}/${entityId}/versions`, + 'getVersionsList' + ); + interceptURL( + 'GET', + `/api/v1/${entityDetails.entity}/${entityId}/versions/0.2`, + 'getSelectedVersionDetails' + ); - verifyResponseStatusCode(`@get${entityType}Details`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); + cy.get('@versionButton').contains('0.2').click(); - cy.get(`[data-testid="diff-removed"]`) - .scrollIntoView() - .should('be.visible'); - }); + verifyResponseStatusCode(`@get${entityType}Details`, 200); + verifyResponseStatusCode('@getVersionsList', 200); + verifyResponseStatusCode('@getSelectedVersionDetails', 200); - it(`${entityType} version page should show tier changes properly`, () => { - visitEntityDetailsPage({ - term: entityDetails.name, - serviceName: entityDetails.serviceName, - entity: entityDetails.entity, - entityType: entityType, + cy.get('[data-testid="Tier"] > [data-testid="diff-added"]') + .scrollIntoView() + .should('be.visible'); }); - cy.get('[data-testid="version-button"]').as('versionButton'); - - cy.get('@versionButton').contains('0.5'); - - addTier(TIER, entityDetails.entity); - - interceptURL( - 'GET', - `/api/v1/${entityDetails.entity}/name/${entityFQN}?*include=all`, - `get${entityType}Details` - ); - interceptURL( - 'GET', - `/api/v1/${entityDetails.entity}/${entityId}/versions`, - 'getVersionsList' - ); - interceptURL( - 'GET', - `/api/v1/${entityDetails.entity}/${entityId}/versions/0.6`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.6').click(); - - verifyResponseStatusCode(`@get${entityType}Details`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-added"]`) - .scrollIntoView() - .should('be.visible'); - - cy.get('@versionButton').contains('0.6').click(); - - removeTier(entityDetails.entity); - - interceptURL( - 'GET', - `/api/v1/${entityDetails.entity}/${entityId}/versions/0.7`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.7').click(); - - verifyResponseStatusCode(`@get${entityType}Details`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-removed"]`) - .scrollIntoView() - .should('be.visible'); - }); - - it(`Cleanup for ${entityType} version page test`, () => { - deleteEntity( - entityDetails.name, - entityDetails.serviceName, - entityDetails.entity, - entityType, - successMessageEntityName - ); + it(`Cleanup for ${entityType} version page test`, () => { + deleteEntity( + entityDetails.name, + entityDetails.serviceName, + entityDetails.entity, + successMessageEntityName + ); + }); }); - }); - } -); - -describe('Common cleanup for entity version test', () => { - beforeEach(() => { - cy.login(); - }); - - it('Domain deletion for entity version test', () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'DELETE', - url: `/api/v1/domains/name/${DOMAIN_CREATION_DETAILS.name}`, - headers: { Authorization: `Bearer ${token}` }, - }).then((response) => { - expect(response.status).to.eq(200); - }); - }); + } + ); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/GlossaryVersionPage.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/GlossaryVersionPage.spec.js index 528db3ec2fa7..d12aa5f4ef83 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/GlossaryVersionPage.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/GlossaryVersionPage.spec.js @@ -42,88 +42,80 @@ describe('Glossary and glossary term version pages should work properly', () => let glossaryTerm1Id; let glossaryTerm2Id; - beforeEach(() => { + before(() => { cy.login(); - interceptURL('GET', `/api/v1/glossaries?fields=*`, 'getGlossaryDetails'); - interceptURL('GET', '/api/v1/glossaryTerms?glossary=*', 'getGlossaryTerms'); - visitGlossaryPage(); - }); - - it('Prerequisites for glossary and glossary term version page tests', () => { - const token = localStorage.getItem('oidcIdToken'); - - // Create Glossary - cy.request({ - method: 'PUT', - url: `/api/v1/glossaries`, - headers: { Authorization: `Bearer ${token}` }, - body: GLOSSARY_FOR_VERSION_TEST, - }).then((response) => { - expect(response.status).to.eq(201); - - glossaryId = response.body.id; - + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + // Create Glossary cy.request({ - method: 'PATCH', - url: `/api/v1/glossaries/${glossaryId}`, - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json-patch+json', - }, - body: GLOSSARY_PATCH_PAYLOAD, + method: 'PUT', + url: `/api/v1/glossaries`, + headers: { Authorization: `Bearer ${token}` }, + body: GLOSSARY_FOR_VERSION_TEST, }).then((response) => { - expect(response.status).to.eq(200); + glossaryId = response.body.id; + + cy.request({ + method: 'PATCH', + url: `/api/v1/glossaries/${glossaryId}`, + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json-patch+json', + }, + body: GLOSSARY_PATCH_PAYLOAD, + }); }); - }); - - // Create First Glossary Term - cy.request({ - method: 'PUT', - url: `/api/v1/glossaryTerms`, - headers: { Authorization: `Bearer ${token}` }, - body: GLOSSARY_TERM_FOR_VERSION_TEST1, - }).then((response) => { - expect(response.status).to.eq(201); - glossaryTerm1Id = response.body.id; - }); - - // Create Second Glossary Term - cy.request({ - method: 'PUT', - url: `/api/v1/glossaryTerms`, - headers: { Authorization: `Bearer ${token}` }, - body: GLOSSARY_TERM_FOR_VERSION_TEST2, - }).then((response) => { - expect(response.status).to.eq(201); - - glossaryTerm2Id = response.body.id; - - const relatedTermsPatchValue = { - op: 'add', - path: '/relatedTerms/0', - value: { - id: glossaryTerm1Id, - type: 'glossaryTerm', - displayName: GLOSSARY_TERM_NAME_FOR_VERSION_TEST1, - name: GLOSSARY_TERM_NAME_FOR_VERSION_TEST1, - }, - }; + // Create First Glossary Term + cy.request({ + method: 'PUT', + url: `/api/v1/glossaryTerms`, + headers: { Authorization: `Bearer ${token}` }, + body: GLOSSARY_TERM_FOR_VERSION_TEST1, + }).then((response) => { + glossaryTerm1Id = response.body.id; + }); + // Create Second Glossary Term cy.request({ - method: 'PATCH', - url: `/api/v1/glossaryTerms/${glossaryTerm2Id}`, - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json-patch+json', - }, - body: [...GLOSSARY_TERM_PATCH_PAYLOAD2, relatedTermsPatchValue], + method: 'PUT', + url: `/api/v1/glossaryTerms`, + headers: { Authorization: `Bearer ${token}` }, + body: GLOSSARY_TERM_FOR_VERSION_TEST2, }).then((response) => { - expect(response.status).to.eq(200); + glossaryTerm2Id = response.body.id; + + const relatedTermsPatchValue = { + op: 'add', + path: '/relatedTerms/0', + value: { + id: glossaryTerm1Id, + type: 'glossaryTerm', + displayName: GLOSSARY_TERM_NAME_FOR_VERSION_TEST1, + name: GLOSSARY_TERM_NAME_FOR_VERSION_TEST1, + }, + }; + + cy.request({ + method: 'PATCH', + url: `/api/v1/glossaryTerms/${glossaryTerm2Id}`, + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json-patch+json', + }, + body: [...GLOSSARY_TERM_PATCH_PAYLOAD2, relatedTermsPatchValue], + }); }); }); }); + beforeEach(() => { + cy.login(); + interceptURL('GET', `/api/v1/glossaries?fields=*`, 'getGlossaryDetails'); + interceptURL('GET', '/api/v1/glossaryTerms?glossary=*', 'getGlossaryTerms'); + visitGlossaryPage(); + }); + it('Glossary version page should display the version changes properly', () => { cy.get(`[data-menu-id*=${GLOSSARY_FOR_VERSION_TEST.displayName}]`).click(); @@ -156,11 +148,11 @@ describe('Glossary and glossary term version pages should work properly', () => interceptURL('GET', `/api/v1/glossaries/*/versions`, 'getVersionsList'); interceptURL( 'GET', - `/api/v1/glossaries/*/versions/0.3`, + `/api/v1/glossaries/*/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('[data-testid="version-button"]').contains('0.3').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); @@ -169,42 +161,22 @@ describe('Glossary and glossary term version pages should work properly', () => .scrollIntoView() .should('be.visible'); - cy.get('[data-testid="version-button"]').contains('0.3').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode('@getGlossaryDetails', 200); verifyResponseStatusCode('@getGlossaryTerms', 200); removeOwner('glossaries', true); - interceptURL( - 'GET', - `/api/v1/glossaries/*/versions/0.4`, - 'getSelectedVersionDetails' - ); - - cy.get('[data-testid="version-button"]').contains('0.4').click(); - - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get('[data-testid="glossary-owner-name"] [data-testid="diff-removed"]') - .scrollIntoView() - .should('be.visible'); - - cy.get('[data-testid="version-button"]').contains('0.4').click(); - - verifyResponseStatusCode('@getGlossaryDetails', 200); - verifyResponseStatusCode('@getGlossaryTerms', 200); - addReviewer(REVIEWER, 'glossaries'); interceptURL( 'GET', - `/api/v1/glossaries/*/versions/0.5`, + `/api/v1/glossaries/*/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('[data-testid="version-button"]').contains('0.5').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); @@ -213,27 +185,12 @@ describe('Glossary and glossary term version pages should work properly', () => .scrollIntoView() .should('be.visible'); - cy.get('[data-testid="version-button"]').contains('0.5').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode('@getGlossaryDetails', 200); verifyResponseStatusCode('@getGlossaryTerms', 200); removeReviewer('glossaries'); - - interceptURL( - 'GET', - `/api/v1/glossaries/*/versions/0.6`, - 'getSelectedVersionDetails' - ); - - cy.get('[data-testid="version-button"]').contains('0.6').click(); - - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get('[data-testid="glossary-reviewer"] [data-testid="diff-removed"]') - .scrollIntoView() - .should('be.visible'); }); it('Glossary term version page should display version changes properly', () => { @@ -318,11 +275,11 @@ describe('Glossary and glossary term version pages should work properly', () => interceptURL('GET', `/api/v1/glossaryTerms/*/versions`, 'getVersionsList'); interceptURL( 'GET', - `/api/v1/glossaryTerms/*/versions/0.3`, + `/api/v1/glossaryTerms/*/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('[data-testid="version-button"]').contains('0.3').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); @@ -331,42 +288,22 @@ describe('Glossary and glossary term version pages should work properly', () => .scrollIntoView() .should('be.visible'); - cy.get('[data-testid="version-button"]').contains('0.3').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode('@getGlossaryTermParents', 200); verifyResponseStatusCode('@getChildGlossaryTerms', 200); removeOwner('glossaryTerms', true); - interceptURL( - 'GET', - `/api/v1/glossaryTerms/*/versions/0.4`, - 'getSelectedVersionDetails' - ); - - cy.get('[data-testid="version-button"]').contains('0.4').click(); - - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get('[data-testid="glossary-owner-name"] [data-testid="diff-removed"]') - .scrollIntoView() - .should('be.visible'); - - cy.get('[data-testid="version-button"]').contains('0.4').click(); - - verifyResponseStatusCode('@getGlossaryTermParents', 200); - verifyResponseStatusCode('@getChildGlossaryTerms', 200); - addReviewer(REVIEWER, 'glossaryTerms'); interceptURL( 'GET', - `/api/v1/glossaryTerms/*/versions/0.5`, + `/api/v1/glossaryTerms/*/versions/0.2`, 'getSelectedVersionDetails' ); - cy.get('[data-testid="version-button"]').contains('0.5').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); @@ -375,27 +312,12 @@ describe('Glossary and glossary term version pages should work properly', () => .scrollIntoView() .should('be.visible'); - cy.get('[data-testid="version-button"]').contains('0.5').click(); + cy.get('[data-testid="version-button"]').contains('0.2').click(); verifyResponseStatusCode('@getGlossaryTermParents', 200); verifyResponseStatusCode('@getChildGlossaryTerms', 200); removeReviewer('glossaryTerms'); - - interceptURL( - 'GET', - `/api/v1/glossaryTerms/*/versions/0.6`, - 'getSelectedVersionDetails' - ); - - cy.get('[data-testid="version-button"]').contains('0.6').click(); - - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get('[data-testid="glossary-reviewer"] [data-testid="diff-removed"]') - .scrollIntoView() - .should('be.visible'); }); it('Cleanup for glossary and glossary term version page tests', () => { diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexDetails.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexDetails.spec.js index 85e64da8095c..8bb25cc95601 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexDetails.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexDetails.spec.js @@ -207,7 +207,6 @@ describe('SearchIndexDetails page should work properly for data consumer role', term: SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST.name, serviceName: SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST.service, entity: 'searchIndexes', - entityType: 'Search Index', }); // Edit domain option should not be available @@ -286,7 +285,6 @@ describe('SearchIndexDetails page should work properly for data steward role', ( term: SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST.name, serviceName: SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST.service, entity: 'searchIndexes', - entityType: 'Search Index', }); // Edit domain option should not be available @@ -372,7 +370,6 @@ describe('SearchIndexDetails page should work properly for admin role', () => { SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST.service, 'searchIndexes', 'Search Index', - 'Search Index', 'soft' ); @@ -443,7 +440,6 @@ describe('SearchIndexDetails page should work properly for admin role', () => { SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST.name, SEARCH_INDEX_DETAILS_FOR_DETAILS_PAGE_TEST.service, 'searchIndexes', - 'Search Index', 'Search Index' ); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/ServiceVersionPage.spec.js b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/ServiceVersionPage.spec.js index 356c1012685c..7a7d366a2a38 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/ServiceVersionPage.spec.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/ServiceVersionPage.spec.js @@ -17,8 +17,6 @@ import { addOwner, addTier, interceptURL, - removeOwner, - removeTier, toastNotification, verifyResponseStatusCode, visitServiceDetailsPage, @@ -34,88 +32,151 @@ import { let domainId; describe('Common prerequisite for service version test', () => { - beforeEach(() => { + before(() => { cy.login(); - }); - - it('Domain creation for service version test', () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'PUT', - url: `/api/v1/domains`, - headers: { Authorization: `Bearer ${token}` }, - body: DOMAIN_CREATION_DETAILS, - }).then((response) => { - expect(response.status).to.eq(201); - - domainId = response.body.id; + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'PUT', + url: `/api/v1/domains`, + headers: { Authorization: `Bearer ${token}` }, + body: DOMAIN_CREATION_DETAILS, + }).then((response) => { + domainId = response.body.id; + }); }); }); -}); - -Object.entries(SERVICE_DETAILS_FOR_VERSION_TEST).map( - ([serviceType, serviceDetails]) => { - describe(`${serviceType} service version page`, () => { - const successMessageEntityName = - serviceType === 'ML Model' ? 'Mlmodel' : serviceType; - let serviceId; - beforeEach(() => { - cy.login(); + after(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'DELETE', + url: `/api/v1/domains/name/${DOMAIN_CREATION_DETAILS.name}`, + headers: { Authorization: `Bearer ${token}` }, }); + }); + }); - it(`Prerequisite for ${serviceType} service version page`, () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'POST', - url: `/api/v1/services/${serviceDetails.serviceCategory}`, - headers: { Authorization: `Bearer ${token}` }, - body: serviceDetails.entityCreationDetails, - }).then((response) => { - expect(response.status).to.eq(201); - - serviceId = response.body.id; - - cy.request({ - method: 'PATCH', - url: `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}`, - headers: { - Authorization: `Bearer ${token}`, - 'Content-Type': 'application/json-patch+json', - }, - body: [ - ...serviceDetails.entityPatchPayload, - { - op: 'add', - path: '/domain', - value: { - id: domainId, - type: 'domain', - name: DOMAIN_CREATION_DETAILS.name, - description: DOMAIN_CREATION_DETAILS.description, + Object.entries(SERVICE_DETAILS_FOR_VERSION_TEST).map( + ([serviceType, serviceDetails]) => { + describe(`${serviceType} service version page`, () => { + const successMessageEntityName = + serviceType === 'ML Model' ? 'Mlmodel' : serviceType; + let serviceId; + + before(() => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'POST', + url: `/api/v1/services/${serviceDetails.serviceCategory}`, + headers: { Authorization: `Bearer ${token}` }, + body: serviceDetails.entityCreationDetails, + }).then((response) => { + serviceId = response.body.id; + + cy.request({ + method: 'PATCH', + url: `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}`, + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json-patch+json', }, - }, - ], - }).then((response) => { - expect(response.status).to.eq(200); + body: [ + ...serviceDetails.entityPatchPayload, + { + op: 'add', + path: '/domain', + value: { + id: domainId, + type: 'domain', + name: DOMAIN_CREATION_DETAILS.name, + description: DOMAIN_CREATION_DETAILS.description, + }, + }, + ], + }); + }); }); }); - }); - serviceType !== 'Metadata' && - it(`${serviceType} service version page should show edited tags and description changes properly`, () => { + beforeEach(() => { + cy.login(); + }); + + serviceType !== 'Metadata' && + it(`${serviceType} service version page should show edited tags and description changes properly`, () => { + visitServiceDetailsPage( + serviceDetails.settingsMenuId, + serviceDetails.serviceCategory, + serviceDetails.serviceName + ); + + interceptURL( + 'GET', + `/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}?*`, + `getServiceDetails` + ); + interceptURL( + 'GET', + `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions`, + 'getVersionsList' + ); + interceptURL( + 'GET', + `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions/0.2`, + 'getSelectedVersionDetails' + ); + + cy.get('[data-testid="version-button"]').contains('0.2').click(); + + verifyResponseStatusCode(`@getServiceDetails`, 200); + verifyResponseStatusCode('@getVersionsList', 200); + verifyResponseStatusCode('@getSelectedVersionDetails', 200); + + cy.get(`[data-testid="domain-link"]`) + .within(($this) => $this.find(`[data-testid="diff-added"]`)) + .scrollIntoView() + .should('be.visible'); + + cy.get('[data-testid="viewer-container"]') + .within(($this) => $this.find('[data-testid="diff-added"]')) + .scrollIntoView() + .should('be.visible'); + + cy.get( + `[data-testid="entity-right-panel"] .diff-added [data-testid="tag-PersonalData.SpecialCategory"]` + ) + .scrollIntoView() + .should('be.visible'); + + cy.get( + `[data-testid="entity-right-panel"] .diff-added [data-testid="tag-PII.Sensitive"]` + ) + .scrollIntoView() + .should('be.visible'); + }); + + it(`${serviceType} version page should show owner changes properly`, () => { visitServiceDetailsPage( serviceDetails.settingsMenuId, serviceDetails.serviceCategory, serviceDetails.serviceName ); + cy.get('[data-testid="version-button"]').as('versionButton'); + + cy.get('@versionButton').contains('0.2'); + + addOwner(OWNER, `services/${serviceDetails.serviceCategory}`); + interceptURL( 'GET', `/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}?*`, - `getServiceDetails` + `get${serviceType}Details` ); interceptURL( 'GET', @@ -128,259 +189,110 @@ Object.entries(SERVICE_DETAILS_FOR_VERSION_TEST).map( 'getSelectedVersionDetails' ); - cy.get('[data-testid="version-button"]').contains('0.2').click(); + cy.get('@versionButton').contains('0.2').click(); - verifyResponseStatusCode(`@getServiceDetails`, 200); + verifyResponseStatusCode(`@get${serviceType}Details`, 200); verifyResponseStatusCode('@getVersionsList', 200); verifyResponseStatusCode('@getSelectedVersionDetails', 200); - cy.get(`[data-testid="domain-link"]`) - .within(($this) => $this.find(`[data-testid="diff-added"]`)) - .scrollIntoView() - .should('be.visible'); - - cy.get('[data-testid="viewer-container"]') - .within(($this) => $this.find('[data-testid="diff-added"]')) - .scrollIntoView() - .should('be.visible'); - - cy.get( - `[data-testid="entity-right-panel"] .diff-added [data-testid="tag-PersonalData.SpecialCategory"]` - ) - .scrollIntoView() - .should('be.visible'); - - cy.get( - `[data-testid="entity-right-panel"] .diff-added [data-testid="tag-PII.Sensitive"]` - ) + cy.get('[data-testid="owner-link"] > [data-testid="diff-added"]') .scrollIntoView() .should('be.visible'); }); - it(`${serviceType} version page should show removed tags changes properly`, () => { - visitServiceDetailsPage( - serviceDetails.settingsMenuId, - serviceDetails.serviceCategory, - serviceDetails.serviceName - ); - - cy.get( - '[data-testid="entity-right-panel"] [data-testid="edit-button"]' - ).click(); - - cy.get( - '[data-testid="selected-tag-PersonalData.SpecialCategory"] [data-testid="remove-tags"]' - ).click(); - - interceptURL( - 'PATCH', - `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}`, - `patch${serviceType}` - ); - - cy.get('[data-testid="saveAssociatedTag"]').click(); - - verifyResponseStatusCode(`@patch${serviceType}`, 200); - - cy.get('[data-testid="version-button"]').contains('0.3').click(); - - cy.get( - `[data-testid="entity-right-panel"] .diff-removed [data-testid="tag-PersonalData.SpecialCategory"]` - ) - .scrollIntoView() - .should('be.visible'); - }); - - it(`${serviceType} version page should show owner changes properly`, () => { - visitServiceDetailsPage( - serviceDetails.settingsMenuId, - serviceDetails.serviceCategory, - serviceDetails.serviceName - ); - - cy.get('[data-testid="version-button"]').as('versionButton'); - - cy.get('@versionButton').contains('0.3'); - - addOwner(OWNER, `services/${serviceDetails.serviceCategory}`); - - interceptURL( - 'GET', - `/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}?*`, - `get${serviceType}Details` - ); - interceptURL( - 'GET', - `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions`, - 'getVersionsList' - ); - interceptURL( - 'GET', - `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions/0.4`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.4').click(); - - verifyResponseStatusCode(`@get${serviceType}Details`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-added"]`) - .scrollIntoView() - .should('be.visible'); - - cy.get('@versionButton').contains('0.4').click(); - - removeOwner(`services/${serviceDetails.serviceCategory}`); - - interceptURL( - 'GET', - `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions/0.5`, - 'getSelectedVersionDetails' - ); - - cy.get('@versionButton').contains('0.5').click(); - - verifyResponseStatusCode(`@get${serviceType}Details`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); - - cy.get(`[data-testid="diff-removed"]`) - .scrollIntoView() - .should('be.visible'); - }); - - it(`${serviceType} version page should show tier changes properly`, () => { - visitServiceDetailsPage( - serviceDetails.settingsMenuId, - serviceDetails.serviceCategory, - serviceDetails.serviceName - ); - - cy.get('[data-testid="version-button"]').as('versionButton'); - - cy.get('@versionButton').contains('0.5'); - - addTier(TIER, `services/${serviceDetails.serviceCategory}`); + it(`${serviceType} version page should show tier changes properly`, () => { + visitServiceDetailsPage( + serviceDetails.settingsMenuId, + serviceDetails.serviceCategory, + serviceDetails.serviceName + ); - interceptURL( - 'GET', - `/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}?*`, - `get${serviceType}Details` - ); - interceptURL( - 'GET', - `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions`, - 'getVersionsList' - ); - interceptURL( - 'GET', - `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions/0.6`, - 'getSelectedVersionDetails' - ); + cy.get('[data-testid="version-button"]').as('versionButton'); - cy.get('@versionButton').contains('0.6').click(); + cy.get('@versionButton').contains('0.2'); - verifyResponseStatusCode(`@get${serviceType}Details`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); + addTier(TIER, `services/${serviceDetails.serviceCategory}`); - cy.get(`[data-testid="diff-added"]`) - .scrollIntoView() - .should('be.visible'); + interceptURL( + 'GET', + `/api/v1/services/${serviceDetails.serviceCategory}/name/${serviceDetails.serviceName}?*`, + `get${serviceType}Details` + ); + interceptURL( + 'GET', + `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions`, + 'getVersionsList' + ); + interceptURL( + 'GET', + `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions/0.2`, + 'getSelectedVersionDetails' + ); - cy.get('@versionButton').contains('0.6').click(); + cy.get('@versionButton').contains('0.2').click(); - removeTier(`services/${serviceDetails.serviceCategory}`); + verifyResponseStatusCode(`@get${serviceType}Details`, 200); + verifyResponseStatusCode('@getVersionsList', 200); + verifyResponseStatusCode('@getSelectedVersionDetails', 200); - interceptURL( - 'GET', - `/api/v1/services/${serviceDetails.serviceCategory}/${serviceId}/versions/0.7`, - 'getSelectedVersionDetails' - ); + cy.get('[data-testid="Tier"] > [data-testid="diff-added"]') + .scrollIntoView() + .should('be.visible'); + }); - cy.get('@versionButton').contains('0.7').click(); + it(`Cleanup for ${serviceType} service version page tests`, () => { + visitServiceDetailsPage( + serviceDetails.settingsMenuId, + serviceDetails.serviceCategory, + serviceDetails.serviceName + ); + // Clicking on permanent delete radio button and checking the service name + cy.get('[data-testid="manage-button"]') + .should('exist') + .should('be.visible') + .click(); + + cy.get('[data-menu-id*="delete-button"]') + .should('exist') + .should('be.visible'); + cy.get('[data-testid="delete-button-title"]') + .should('be.visible') + .click() + .as('deleteBtn'); + + // Clicking on permanent delete radio button and checking the service name + cy.get('[data-testid="hard-delete-option"]') + .contains(serviceDetails.serviceName) + .should('be.visible') + .click(); + + cy.get('[data-testid="confirmation-text-input"]') + .should('be.visible') + .type(DELETE_TERM); + interceptURL( + 'DELETE', + `/api/v1/services/${serviceDetails.serviceCategory}/*`, + 'deleteService' + ); + interceptURL( + 'GET', + '/api/v1/services/*/name/*?fields=owner', + 'serviceDetails' + ); - verifyResponseStatusCode(`@get${serviceType}Details`, 200); - verifyResponseStatusCode('@getVersionsList', 200); - verifyResponseStatusCode('@getSelectedVersionDetails', 200); + cy.get('[data-testid="confirm-button"]').should('be.visible').click(); + verifyResponseStatusCode('@deleteService', 200); - cy.get(`[data-testid="diff-removed"]`) - .scrollIntoView() - .should('be.visible'); - }); + // Closing the toast notification + toastNotification( + `${successMessageEntityName} Service deleted successfully!` + ); - it(`Cleanup for ${serviceType} service version page tests`, () => { - visitServiceDetailsPage( - serviceDetails.settingsMenuId, - serviceDetails.serviceCategory, - serviceDetails.serviceName - ); - // Clicking on permanent delete radio button and checking the service name - cy.get('[data-testid="manage-button"]') - .should('exist') - .should('be.visible') - .click(); - - cy.get('[data-menu-id*="delete-button"]') - .should('exist') - .should('be.visible'); - cy.get('[data-testid="delete-button-title"]') - .should('be.visible') - .click() - .as('deleteBtn'); - - // Clicking on permanent delete radio button and checking the service name - cy.get('[data-testid="hard-delete-option"]') - .contains(serviceDetails.serviceName) - .should('be.visible') - .click(); - - cy.get('[data-testid="confirmation-text-input"]') - .should('be.visible') - .type(DELETE_TERM); - interceptURL( - 'DELETE', - `/api/v1/services/${serviceDetails.serviceCategory}/*`, - 'deleteService' - ); - interceptURL( - 'GET', - '/api/v1/services/*/name/*?fields=owner', - 'serviceDetails' - ); - - cy.get('[data-testid="confirm-button"]').should('be.visible').click(); - verifyResponseStatusCode('@deleteService', 200); - - // Closing the toast notification - toastNotification( - `${successMessageEntityName} Service deleted successfully!` - ); - - cy.get( - `[data-testid="service-name-${serviceDetails.serviceName}"]` - ).should('not.exist'); + cy.get( + `[data-testid="service-name-${serviceDetails.serviceName}"]` + ).should('not.exist'); + }); }); - }); - } -); - -describe('Common cleanup for service version test', () => { - beforeEach(() => { - cy.login(); - }); - - it('Domain deletion for service version test', () => { - const token = localStorage.getItem('oidcIdToken'); - - cy.request({ - method: 'DELETE', - url: `/api/v1/domains/name/${DOMAIN_CREATION_DETAILS.name}`, - headers: { Authorization: `Bearer ${token}` }, - }).then((response) => { - expect(response.status).to.eq(200); - }); - }); + } + ); });