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 98888639b3fc..176229546305 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/EntityUtils.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/EntityUtils.js @@ -12,9 +12,14 @@ */ import { + DASHBOARD_SERVICE_DETAILS, DATABASE_DETAILS, DATABASE_SERVICE_DETAILS, + MESSAGING_SERVICE_DETAILS, + ML_MODEL_SERVICE_DETAILS, + PIPELINE_SERVICE_DETAILS, SCHEMA_DETAILS, + STORAGE_SERVICE_DETAILS, } from '../constants/EntityConstant'; import { uuid } from './common'; @@ -154,6 +159,107 @@ export const generateRandomTable = () => { return table; }; +export const generateRandomTopic = () => { + const topicName = `cypress-topic-${uuid()}`; + const topicDetails = { + name: topicName, + service: MESSAGING_SERVICE_DETAILS.name, + messageSchema: { + schemaText: `{"type":"object","required":["name","age","club_name"],"properties":{"name":{"type":"object","required":["first_name","last_name"], + "properties":{"first_name":{"type":"string"},"last_name":{"type":"string"}}},"age":{"type":"integer"},"club_name":{"type":"string"}}}`, + schemaType: 'JSON', + schemaFields: [ + { + name: 'default', + dataType: 'RECORD', + fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default`, + tags: [], + children: [ + { + name: 'name', + dataType: 'RECORD', + fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.name`, + tags: [], + children: [ + { + name: 'first_name', + dataType: 'STRING', + description: 'Description for schema field first_name', + fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.name.first_name`, + tags: [], + }, + { + name: 'last_name', + dataType: 'STRING', + fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.name.last_name`, + tags: [], + }, + ], + }, + { + name: 'age', + dataType: 'INT', + fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.age`, + tags: [], + }, + { + name: 'club_name', + dataType: 'STRING', + fullyQualifiedName: `${MESSAGING_SERVICE_DETAILS.name}.${topicName}.default.club_name`, + tags: [], + }, + ], + }, + ], + }, + partitions: 128, + }; + + return topicDetails; +}; + +export const generateRandomDashboard = () => { + const dashboardName = `cypress-dashboard-${uuid()}`; + + const dashboardDetails = { + name: dashboardName, + displayName: dashboardName, + service: DASHBOARD_SERVICE_DETAILS.name, + }; + + return dashboardDetails; +}; + +export const generateRandomPipeline = () => { + return { + name: `cypress-pipeline-${uuid()}`, + service: PIPELINE_SERVICE_DETAILS.name, + tasks: [{ name: 'snowflake_task' }], + }; +}; + +export const generateRandomMLModel = () => { + return { + name: `cypress-mlmodel-${uuid()}`, + service: ML_MODEL_SERVICE_DETAILS.name, + algorithm: 'Time Series', + mlFeatures: [ + { + name: 'sales', + dataType: 'numerical', + description: 'Sales amount', + }, + ], + }; +}; + +export const generateRandomContainer = () => { + return { + name: `cypress-container-${uuid()}`, + service: STORAGE_SERVICE_DETAILS.name, + }; +}; + /** * get Table by name and create query in the table */ diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Entity.ts b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Entity.ts index b103af95ea69..275ebe18a86d 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Entity.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Entity.ts @@ -223,7 +223,7 @@ export const visitEntityDetailsPage = ({ } }); - verifyResponseStatusCode('@getEntityDetails', 200); + cy.wait('@getEntityDetails'); cy.clickOutside(); cy.get('[data-testid="searchBox"]').clear(); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Owner.ts b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Owner.ts index 02693371bd37..ce8006c3a881 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Owner.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Owner.ts @@ -10,13 +10,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { interceptURL, verifyResponseStatusCode } from '../common'; +import { interceptURL, uuid, verifyResponseStatusCode } from '../common'; const userURL = '/api/v1/search/query?q=**%20AND%20isBot:false&from=0&size=0&index=user_search_index'; const teamURL = '/api/v1/search/query?q=*%20AND%20teamType:Group&from=0&size=10&index=team_search_index&sort_field=displayName.keyword&sort_order=asc'; +export const generateRandomUser = () => { + return { + firstName: `firstName-${uuid()}`, + lastName: `lastName-${uuid()}`, + email: `user${uuid()}@example.com`, + password: 'User@OMD123', + }; +}; + export const validateOwnerAndTeamCounts = () => { cy.getAllLocalStorage().then((data) => { const token = Object.values(data)[0].oidcIdToken; 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 5b7180578c76..857eb3984206 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/common.js +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/common.js @@ -683,13 +683,29 @@ export const mySqlConnectionInput = () => { export const login = (username, password) => { cy.visit('/'); + interceptURL('POST', '/api/v1/users/login', 'loginUser'); cy.get('[id="email"]').should('be.visible').clear().type(username); cy.get('[id="password"]').should('be.visible').clear().type(password); // Don't want to show any popup in the tests cy.setCookie(`STAR_OMD_USER_${username.split('@')[0]}`, 'true'); + // Get version and set cookie to hide version banner + cy.request({ + method: 'GET', + url: `api/v1/system/version`, + }).then((res) => { + const version = res.body.version; + const versionCookie = `VERSION_${version + .split('-')[0] + .replaceAll('.', '_')}`; + + cy.setCookie(versionCookie, 'true'); + window.localStorage.setItem('loggedInUsers', username.split('@')[0]); + }); + cy.get('.ant-btn').contains('Login').should('be.visible').click(); + verifyResponseStatusCode('@loginUser', 200); }; export const selectTeamHierarchy = (index) => { diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/EntitySummaryPanel.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/EntitySummaryPanel.spec.ts new file mode 100644 index 000000000000..18d95be27a01 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Features/EntitySummaryPanel.spec.ts @@ -0,0 +1,249 @@ +/* + * Copyright 2024 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. + */ +import { interceptURL, verifyResponseStatusCode } from '../../common/common'; +import { SidebarItem } from '../../constants/Entity.interface'; + +describe('Entity Summary Panel', () => { + beforeEach(() => { + cy.login(); + interceptURL( + 'GET', + '/api/v1/search/query?*&index=table_search_index*', + 'getTableEntity' + ); + cy.sidebarClick(SidebarItem.EXPLORE); + verifyResponseStatusCode('@getTableEntity', 200); + }); + + it('Table Entity', () => { + cy.get('[data-testid="Type-label"]').should('be.visible'); + cy.get('[data-testid="Queries-label"]').should('be.visible'); + cy.get('[data-testid="Columns-label"]').should('be.visible'); + cy.get('[data-testid="profiler-header"]').should('be.visible'); + cy.get('[data-testid="tags-header"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="schema-header"]') + .scrollIntoView() + .should('be.visible'); + }); + + it('Database', () => { + interceptURL( + 'GET', + '/api/v1/search/query?*index=database_search_index*', + 'getDatabaseEntity' + ); + cy.get('[data-testid="databases-tab"]').click(); + verifyResponseStatusCode('@getDatabaseEntity', 200); + cy.get('.ant-drawer-title > [data-testid="entity-link"]').should( + 'be.visible' + ); + cy.get('[data-testid="Owner-value"]').should('be.visible'); + cy.get('[data-testid="Tier-label"]').should('be.visible'); + cy.get('[data-testid="Service-label"]').should('be.visible'); + cy.get('[data-testid="Usage-label"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="tags-header"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="schema-header"]') + .scrollIntoView() + .should('be.visible'); + }); + + it('Database schema', () => { + interceptURL( + 'GET', + '/api/v1/search/query?*index=database_schema_search_index*', + 'getDatabaseSchemaEntity' + ); + cy.get('[data-testid="database schemas-tab"]').click(); + verifyResponseStatusCode('@getDatabaseSchemaEntity', 200); + cy.get('.ant-drawer-title > [data-testid="entity-link"]').should( + 'be.visible' + ); + cy.get('[data-testid="Owner-value"]').should('be.visible'); + cy.get('[data-testid="Tier-label"]').should('be.visible'); + cy.get('[data-testid="Service-label"]').should('be.visible'); + cy.get('[data-testid="Database-label"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="Usage-label"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + }); + + it('Dashboard entity', () => { + interceptURL( + 'GET', + '/api/v1/search/query?*index=dashboard_search_index*', + 'getDashboardEntity' + ); + cy.get('[data-testid="dashboards-tab"]').click(); + verifyResponseStatusCode('@getDashboardEntity', 200); + cy.get('.ant-drawer-title > [data-testid="entity-link"]').should( + 'be.visible' + ); + cy.get('[data-testid="Dashboard URL-label"]').should('be.visible'); + cy.get('[data-testid="tags-header"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="charts-header"]') + .scrollIntoView() + .should('be.visible'); + }); + + it('Dashboard data model entity', () => { + interceptURL( + 'GET', + '/api/v1/search/query?*index=dashboard_data_model_search_index*', + 'getDashboardDataModelEntity' + ); + cy.get('[data-testid="dashboard data models-tab"]').click(); + verifyResponseStatusCode('@getDashboardDataModelEntity', 200); + cy.get('.ant-drawer-title > [data-testid="entity-link"]').should( + 'be.visible' + ); + cy.get('[data-testid="Data Model URL-label"]').should('be.visible'); + cy.get('[data-testid="Service-label"]').should('be.visible'); + cy.get('[data-testid="Tier-label"]').should('be.visible'); + cy.get('[data-testid="Data Model Type-label"]').should('be.visible'); + cy.get('[data-testid="tags-header"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="column-header"]') + .scrollIntoView() + .should('be.visible'); + }); + + it('Pipeline entity', () => { + interceptURL( + 'GET', + '/api/v1/search/query?*index=pipeline_search_index*', + 'getPipelineEntity' + ); + cy.get('[data-testid="pipelines-tab"]').click(); + verifyResponseStatusCode('@getPipelineEntity', 200); + cy.get('.ant-drawer-title > [data-testid="entity-link"]').should( + 'be.visible' + ); + cy.get('[data-testid="Pipeline URL-label"]').should('be.visible'); + cy.get('[data-testid="tags-header"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="tasks-header"]') + .scrollIntoView() + .should('be.visible'); + }); + + it('Topic entity', () => { + interceptURL( + 'GET', + '/api/v1/search/query?*index=topic_search_index*', + 'getTopicEntity' + ); + cy.get('[data-testid="topics-tab"]').click(); + verifyResponseStatusCode('@getTopicEntity', 200); + cy.get('.ant-drawer-title > [data-testid="entity-link"]').should( + 'be.visible' + ); + cy.get('[data-testid="Partitions-label"]').should('be.visible'); + cy.get('[data-testid="Replication Factor-label"]').should('be.visible'); + cy.get('[data-testid="Retention Size-label"]').should('be.visible'); + cy.get('[data-testid="CleanUp Policies-label"]').should('be.visible'); + cy.get('[data-testid="Max Message Size-label"]').should('be.visible'); + cy.get('[data-testid="Schema Type-label"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="tags-header"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="schema-header"]') + .scrollIntoView() + .should('be.visible'); + }); + + it('ML Model entity', () => { + interceptURL( + 'GET', + '/api/v1/search/query?*index=mlmodel_search_index*', + 'getMLModelEntity' + ); + cy.get('[data-testid="ml models-tab"]').click(); + verifyResponseStatusCode('@getMLModelEntity', 200); + cy.get('.ant-drawer-title > [data-testid="entity-link"]').should( + 'be.visible' + ); + cy.get('[data-testid="Algorithm-label"]').should('be.visible'); + cy.get('[data-testid="Target-label"]').should('be.visible'); + cy.get('[data-testid="Server-label"]').should('be.visible'); + cy.get('[data-testid="Dashboard-label"]').should('be.visible'); + cy.get('[data-testid="tags-header"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="features-header"]') + .scrollIntoView() + .should('be.visible'); + }); + + it('Container entity', () => { + interceptURL( + 'GET', + '/api/v1/search/query?*index=container_search_index*', + 'getContainerEntity' + ); + cy.get('[data-testid="containers-tab"]').click(); + verifyResponseStatusCode('@getContainerEntity', 200); + cy.get('.ant-drawer-title > [data-testid="entity-link"]').should( + 'be.visible' + ); + cy.get('[data-testid="Objects-label"]').should('be.visible'); + cy.get('[data-testid="Service Type-label"]').should('be.visible'); + cy.get('[data-testid="Columns-label"]').should('be.visible'); + cy.get('[data-testid="tags-header"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="schema-header"]') + .scrollIntoView() + .should('be.visible'); + }); + + it('Search Index entity', () => { + interceptURL( + 'GET', + '/api/v1/search/query?*index=search_entity_search_index*', + 'getSearchIndexEntity' + ); + cy.get('[data-testid="search indexes-tab"]').click(); + verifyResponseStatusCode('@getSearchIndexEntity', 200); + cy.get('.ant-drawer-title > [data-testid="entity-link"]').should( + 'be.visible' + ); + cy.get('[data-testid="tags-header"]').scrollIntoView().should('be.visible'); + cy.get('[data-testid="description-header"]') + .scrollIntoView() + .should('be.visible'); + cy.get('[data-testid="fields-header"]') + .scrollIntoView() + .should('be.visible'); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/MyData.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/MyData.spec.ts new file mode 100644 index 000000000000..cc2e80d1a33c --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/MyData.spec.ts @@ -0,0 +1,385 @@ +/* + * Copyright 2024 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. + */ +import { + interceptURL, + login, + uuid, + verifyResponseStatusCode, +} from '../../common/common'; +import { + createSingleLevelEntity, + generateRandomContainer, + generateRandomDashboard, + generateRandomMLModel, + generateRandomPipeline, + generateRandomTable, + generateRandomTopic, + hardDeleteService, +} from '../../common/EntityUtils'; +import { createEntityTableViaREST } from '../../common/Utils/Entity'; +import { generateRandomUser } from '../../common/Utils/Owner'; +import { + DATABASE_SERVICE, + SINGLE_LEVEL_SERVICE, +} from '../../constants/EntityConstant'; +import { SERVICE_CATEGORIES } from '../../constants/service.constants'; + +const user1 = generateRandomUser(); +let user1Id = ''; +const user2 = generateRandomUser(); +let user2Id = ''; + +// generate schema for 20 tables +const tables = Array(20) + .fill(undefined) + .map(() => generateRandomTable()); + +const entities = { + table: { + request: { + url: '/api/v1/tables', + body1: generateRandomTable(), + body2: generateRandomTable(), + }, + id1: '', + id2: '', + }, + topic: { + request: { + url: '/api/v1/topics', + body1: generateRandomTopic(), + body2: generateRandomTopic(), + }, + id1: '', + id2: '', + }, + dashboard: { + request: { + url: '/api/v1/dashboards', + body1: generateRandomDashboard(), + body2: generateRandomDashboard(), + }, + id1: '', + id2: '', + }, + pipeline: { + request: { + url: '/api/v1/pipelines', + body1: generateRandomPipeline(), + body2: generateRandomPipeline(), + }, + id1: '', + id2: '', + }, + mlmodel: { + request: { + url: '/api/v1/mlmodels', + body1: generateRandomMLModel(), + body2: generateRandomMLModel(), + }, + id1: '', + id2: '', + }, + container: { + request: { + url: '/api/v1/containers', + body1: generateRandomContainer(), + body2: generateRandomContainer(), + }, + id1: '', + id2: '', + }, +}; +const team = { + name: `cy-test-team-${uuid()}`, + id: '', +}; + +const verifyEntities = ({ url }) => { + interceptURL('GET', url, 'getEntities'); + cy.get('[data-testid="pagination"] .ant-btn-default') + .scrollIntoView() + .click(); + + // change pagination size to 25 + cy.get('[role="menu"] [value="25"]').click(); + verifyResponseStatusCode('@getEntities', 200); + + // verify all tables are present + tables.forEach((table) => { + cy.get( + `[data-testid="table-data-card_${table.databaseSchema}.${table.name}"]` + ).should('be.exist'); + }); +}; + +const updateOwnerAndVerify = ({ url, body, type, entityName, newOwner }) => { + interceptURL('GET', '/api/v1/users/loggedInUser?*', 'loggedInUser'); + interceptURL( + 'GET', + '/api/v1/feed?type=Conversation&filterType=OWNER_OR_FOLLOWS&userId=*', + 'feedData' + ); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + cy.request({ + method: 'PATCH', + url, + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json-patch+json', + }, + body, + }).then(() => { + cy.get('[id*="tab-mentions"]').click(); + cy.get('[data-testid="no-data-placeholder-container"]').should( + 'be.visible' + ); + cy.get('[id*="tab-all"]').click(); + verifyResponseStatusCode('@feedData', 200); + cy.get('[data-testid="message-container"]').first().as('message'); + cy.get('@message') + .find('[data-testid="entityType"]') + .should('contain', type); + cy.get('@message') + .find('[data-testid="entitylink"]') + .should('contain', entityName); + cy.get('@message') + .find('[data-testid="viewer-container"]') + .should('contain', `Added owner: ${newOwner}`); + }); + }); +}; + +const prepareData = () => { + cy.login(); + cy.getAllLocalStorage().then((data) => { + const token = Object.values(data)[0].oidcIdToken; + SINGLE_LEVEL_SERVICE.forEach((data) => { + createSingleLevelEntity({ + token, + ...data, + entity: [], + }); + }); + // create user + cy.request({ + method: 'POST', + url: `/api/v1/users/signup`, + headers: { Authorization: `Bearer ${token}` }, + body: user1, + }).then((response) => { + user1Id = response.body.id; + + // create team + cy.request({ + method: 'GET', + url: `/api/v1/teams/name/Organization`, + headers: { Authorization: `Bearer ${token}` }, + }).then((teamResponse) => { + cy.request({ + method: 'POST', + url: `/api/v1/teams`, + headers: { Authorization: `Bearer ${token}` }, + body: { + name: team.name, + displayName: team.name, + teamType: 'Group', + parents: [teamResponse.body.id], + users: [response.body.id], + }, + }).then((teamResponse) => { + team.id = teamResponse.body.id; + }); + }); + + // create database service + createEntityTableViaREST({ + token, + ...DATABASE_SERVICE, + tables: [], + }); + + // generate 20 tables with newly created user as owner + tables.forEach((table) => { + cy.request({ + method: 'POST', + url: `/api/v1/tables`, + headers: { Authorization: `Bearer ${token}` }, + body: { ...table, owner: { id: response.body.id, type: 'user' } }, + }).then((tableResponse) => { + cy.request({ + method: 'PUT', + url: `/api/v1/tables/${tableResponse.body.id}/followers`, + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json', + }, + body: JSON.stringify(response.body.id), + }); + }); + }); + }); + + cy.request({ + method: 'POST', + url: `/api/v1/users/signup`, + headers: { Authorization: `Bearer ${token}` }, + body: user2, + }).then((response) => { + user2Id = response.body.id; + }); + + Object.entries(entities).forEach(([key, value]) => { + cy.request({ + method: 'POST', + headers: { Authorization: `Bearer ${token}` }, + url: value.request.url, + body: value.request.body1, + }).then((response) => { + entities[key].id1 = response.body.id; + }); + cy.request({ + method: 'POST', + headers: { Authorization: `Bearer ${token}` }, + url: value.request.url, + body: value.request.body2, + }).then((response) => { + entities[key].id2 = response.body.id; + }); + }); + }); + cy.logout(); +}; + +const cleanUp = () => { + 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, + }); + }); + [user1Id, user2Id].forEach((id) => { + cy.request({ + method: 'DELETE', + url: `/api/v1/users/${id}?hardDelete=true&recursive=false`, + headers: { Authorization: `Bearer ${token}` }, + }); + }); + cy.request({ + method: 'DELETE', + url: `/api/v1/teams/${team.id}?hardDelete=true&recursive=true`, + headers: { Authorization: `Bearer ${token}` }, + }); + }); +}; + +describe('My Data page', () => { + before(prepareData); + after(cleanUp); + + it('Verify my data widget', () => { + // login with newly created user + login(user1.email, user1.password); + cy.get('[data-testid="my-data-widget"]').scrollIntoView(); + + // verify total count + cy.get('[data-testid="my-data-total-count"]') + .invoke('text') + .should('eq', '(20)'); + cy.get( + '[data-testid="my-data-widget"] [data-testid="view-all-link"]' + ).click(); + verifyEntities({ + url: '/api/v1/search/query?q=*&index=all&from=0&size=25', + }); + + cy.logout(); + }); + + it('Verify following widget', () => { + // login with newly created user + login(user1.email, user1.password); + cy.get('[data-testid="following-widget"]').scrollIntoView(); + + // verify total count + cy.get('[data-testid="following-data-total-count"]') + .invoke('text') + .should('eq', '(20)'); + cy.get('[data-testid="following-data"]').click(); + verifyEntities({ + url: '/api/v1/search/query?q=*followers:*&index=all&from=0&size=25', + }); + cy.logout(); + }); + + it('Verify user as owner feed widget', () => { + // login with newly created user + login(user2.email, user2.password); + cy.get('[data-testid="no-data-placeholder-container"]') + .scrollIntoView() + .should( + 'contain', + // eslint-disable-next-line max-len + "Right now, there are no updates in the data assets you own or follow. Haven't explored yet? Dive in and claim ownership or follow the data assets that interest you to stay informed about their latest activities!" + ); + + Object.entries(entities).forEach(([key, value]) => { + updateOwnerAndVerify({ + url: `${value.request.url}/${value.id1}`, + body: [ + { + op: 'add', + path: '/owner', + value: { id: user2Id, type: 'user' }, + }, + ], + type: key, + entityName: value.request.body1.name, + newOwner: `${user2.firstName}${user2.lastName}`, + }); + }); + cy.logout(); + }); + + it('Verify team as owner feed widget', () => { + // login with newly created user + login(user1.email, user1.password); + + Object.entries(entities).forEach(([key, value]) => { + updateOwnerAndVerify({ + url: `${value.request.url}/${value.id2}`, + body: [ + { + op: 'add', + path: '/owner', + value: { id: team.id, type: 'team' }, + }, + ], + type: key, + entityName: value.request.body2.name, + newOwner: team.name, + }); + }); + cy.logout(); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts new file mode 100644 index 000000000000..24e417d336b4 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/SearchIndexApplication.spec.ts @@ -0,0 +1,118 @@ +/* + * Copyright 2024 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. + */ +import { interceptURL, verifyResponseStatusCode } from '../../common/common'; +import { GlobalSettingOptions } from '../../constants/settings.constant'; + +const visitSearchApplicationPage = () => { + interceptURL( + 'GET', + '/api/v1/apps/name/SearchIndexingApplication?fields=*', + 'getSearchIndexingApplication' + ); + cy.get( + '[data-testid="search-indexing-application-card"] [data-testid="config-btn"]' + ).click(); + verifyResponseStatusCode('@getSearchIndexingApplication', 200); +}; + +describe('Search Index Application', () => { + beforeEach(() => { + cy.login(); + + interceptURL('GET', '/api/v1/apps?limit=*', 'getApplications'); + + cy.settingClick(GlobalSettingOptions.APPLICATIONS); + + verifyResponseStatusCode('@getApplications', 200); + }); + + it('Edit application', () => { + interceptURL('PATCH', '/api/v1/apps/*', 'updateApplication'); + visitSearchApplicationPage(); + cy.get('[data-testid="edit-button"]').click(); + cy.get('#cronType').click(); + cy.get('[title="Day"]').click(); + cy.get('[data-testid="hour-options"]').click(); + cy.get('[title="01"]').click(); + cy.get('.ant-modal-body [data-testid="deploy-button"]').click(); + verifyResponseStatusCode('@updateApplication', 200); + cy.get('[data-testid="cron-string"]').should('contain', 'At 01:00 AM'); + + cy.get('[data-testid="configuration"]').click(); + + cy.get('#root\\/batchSize').type('0'); + cy.get('form [title="Chart"] [role="img"]').click(); + + cy.get('[data-testid="submit-btn"]').click(); + verifyResponseStatusCode('@updateApplication', 200); + }); + + it('Uninstall application', () => { + interceptURL('GET', '/api/v1/apps?limit=*', 'getApplications'); + interceptURL( + 'DELETE', + '/api/v1/apps/name/SearchIndexingApplication?hardDelete=true', + 'deleteApplication' + ); + visitSearchApplicationPage(); + cy.get('[data-testid="manage-button"]').click(); + cy.get('[data-testid="uninstall-button-title"]').click(); + cy.get('[data-testid="save-button"]').click(); + verifyResponseStatusCode('@deleteApplication', 200); + verifyResponseStatusCode('@getApplications', 200); + cy.get('[data-testid="search-indexing-application-card"]').should( + 'not.exist' + ); + }); + + it('Install application', () => { + interceptURL('GET', '/api/v1/apps/marketplace?limit=*', 'getMarketPlace'); + interceptURL('POST', '/api/v1/apps', 'installApplication'); + cy.get('[data-testid="add-application"]').click(); + verifyResponseStatusCode('@getMarketPlace', 200); + cy.get( + '[data-testid="search-indexing-application-card"] [data-testid="config-btn"]' + ).click(); + cy.get('[data-testid="install-application"]').click(); + cy.get('[data-testid="save-button"]').scrollIntoView().click(); + cy.get('[data-testid="submit-btn"]').scrollIntoView().click(); + cy.get('#cronType').click(); + cy.get('[title="Day"]').click(); + cy.get('[data-testid="cron-type"]').should('contain', 'Day'); + cy.get('[data-testid="deploy-button"]').click(); + verifyResponseStatusCode('@installApplication', 201); + verifyResponseStatusCode('@getApplications', 200); + cy.get('[data-testid="search-indexing-application-card"]').should( + 'be.visible' + ); + }); + + it('Run application', () => { + interceptURL( + 'GET', + '/api/v1/apps/name/SearchIndexingApplication?fields=*', + 'getSearchIndexingApplication' + ); + interceptURL( + 'POST', + '/api/v1/apps/trigger/SearchIndexingApplication', + 'triggerPipeline' + ); + cy.get( + '[data-testid="search-indexing-application-card"] [data-testid="config-btn"]' + ).click(); + verifyResponseStatusCode('@getSearchIndexingApplication', 200); + cy.get('[data-testid="run-now-button"]').click(); + verifyResponseStatusCode('@triggerPipeline', 200); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx index 43060c33aebc..2e33d17e9848 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx @@ -603,7 +603,6 @@ export const entityDisplayName = (entityType: string, entityFQN: string) => { EntityType.STORAGE_SERVICE, EntityType.SEARCH_SERVICE, EntityType.TYPE, - EntityType.MLMODEL, ].includes(entityType as EntityType) ) { displayName = getPartialNameFromFQN(entityFQN, ['service']);