mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 02:29:03 +00:00 
			
		
		
		
	fix(cypress): fix restore, advance search & data insight (#14684)
This commit is contained in:
		
							parent
							
								
									241f3c68d7
								
							
						
					
					
						commit
						99b8e7988d
					
				| @ -445,6 +445,36 @@ export const deleteEntity = (entityName: string, endPoint: EntityType) => { | |||||||
| 
 | 
 | ||||||
|   deletedEntityCommonChecks({ entityType: endPoint, deleted: true }); |   deletedEntityCommonChecks({ entityType: endPoint, deleted: true }); | ||||||
| 
 | 
 | ||||||
|  |   if (endPoint === EntityType.Table) { | ||||||
|  |     interceptURL( | ||||||
|  |       'GET', | ||||||
|  |       '/api/v1/tables?databaseSchema=*&include=deleted', | ||||||
|  |       'queryDeletedTables' | ||||||
|  |     ); | ||||||
|  |     interceptURL( | ||||||
|  |       'GET', | ||||||
|  |       '/api/v1/databaseSchemas/name/*?fields=*&include=all', | ||||||
|  |       'getDatabaseSchemas' | ||||||
|  |     ); | ||||||
|  | 
 | ||||||
|  |     cy.get('[data-testid="breadcrumb-link"]').last().click(); | ||||||
|  |     verifyResponseStatusCode('@getDatabaseSchemas', 200); | ||||||
|  | 
 | ||||||
|  |     cy.get('[data-testid="show-deleted"]') | ||||||
|  |       .scrollIntoView() | ||||||
|  |       .click({ waitForAnimations: true }); | ||||||
|  | 
 | ||||||
|  |     verifyResponseStatusCode('@queryDeletedTables', 200); | ||||||
|  | 
 | ||||||
|  |     cy.get('[data-testid="table"] [data-testid="count"]').should( | ||||||
|  |       'contain', | ||||||
|  |       '1' | ||||||
|  |     ); | ||||||
|  | 
 | ||||||
|  |     cy.get('.ant-table-row > :nth-child(1)').should('contain', entityName); | ||||||
|  |     cy.get('.ant-table-row > :nth-child(1)').contains(entityName).click(); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   restoreEntity(); |   restoreEntity(); | ||||||
|   cy.reload(); |   cy.reload(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,172 +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. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| import { |  | ||||||
|   interceptURL, |  | ||||||
|   toastNotification, |  | ||||||
|   verifyResponseStatusCode, |  | ||||||
|   visitEntityDetailsPage, |  | ||||||
| } from '../../common/common'; |  | ||||||
| import { createEntityTable, hardDeleteService } from '../../common/EntityUtils'; |  | ||||||
| import { DATA_ASSETS, DELETE_TERM } from '../../constants/constants'; |  | ||||||
| import { DATABASE_SERVICE } from '../../constants/EntityConstant'; |  | ||||||
| import { SERVICE_CATEGORIES } from '../../constants/service.constants'; |  | ||||||
| 
 |  | ||||||
| const ENTITY_TABLE = { |  | ||||||
|   term: DATABASE_SERVICE.entity.name, |  | ||||||
|   displayName: DATABASE_SERVICE.entity.name, |  | ||||||
|   entity: DATA_ASSETS.tables, |  | ||||||
|   serviceName: DATABASE_SERVICE.service.name, |  | ||||||
|   schemaName: DATABASE_SERVICE.schema.name, |  | ||||||
|   entityType: 'Table', |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| describe('Restore entity functionality should work properly', () => { |  | ||||||
|   before(() => { |  | ||||||
|     cy.login(); |  | ||||||
|     cy.getAllLocalStorage().then((data) => { |  | ||||||
|       const token = Object.values(data)[0].oidcIdToken; |  | ||||||
| 
 |  | ||||||
|       createEntityTable({ |  | ||||||
|         token, |  | ||||||
|         ...DATABASE_SERVICE, |  | ||||||
|         tables: [DATABASE_SERVICE.entity], |  | ||||||
|       }); |  | ||||||
|     }); |  | ||||||
|   }); |  | ||||||
| 
 |  | ||||||
|   after(() => { |  | ||||||
|     cy.login(); |  | ||||||
|     cy.getAllLocalStorage().then((data) => { |  | ||||||
|       const token = Object.values(data)[0].oidcIdToken; |  | ||||||
| 
 |  | ||||||
|       hardDeleteService({ |  | ||||||
|         token, |  | ||||||
|         serviceFqn: ENTITY_TABLE.serviceName, |  | ||||||
|         serviceType: SERVICE_CATEGORIES.DATABASE_SERVICES, |  | ||||||
|       }); |  | ||||||
|     }); |  | ||||||
|   }); |  | ||||||
| 
 |  | ||||||
|   beforeEach(() => { |  | ||||||
|     cy.login(); |  | ||||||
|     interceptURL( |  | ||||||
|       'GET', |  | ||||||
|       'api/v1/search/query?q=*&index=*&from=0&size=10&deleted=true&query_filter=*&sort_field=updatedAt&sort_order=desc', |  | ||||||
|       'showDeletedTables' |  | ||||||
|     ); |  | ||||||
|     interceptURL( |  | ||||||
|       'GET', |  | ||||||
|       'api/v1/search/query?q=*&index=*&from=0&size=10&deleted=false&query_filter=*&sort_field=updatedAt&sort_order=desc', |  | ||||||
|       'nonDeletedTables' |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
| 
 |  | ||||||
|   it('Soft Delete entity table', () => { |  | ||||||
|     visitEntityDetailsPage({ |  | ||||||
|       term: ENTITY_TABLE.term, |  | ||||||
|       serviceName: ENTITY_TABLE.serviceName, |  | ||||||
|       entity: ENTITY_TABLE.entity, |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="manage-button"]').click(); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="delete-button-title"]').click(); |  | ||||||
| 
 |  | ||||||
|     cy.get('.ant-modal-header').should( |  | ||||||
|       'contain', |  | ||||||
|       `Delete ${ENTITY_TABLE.displayName}` |  | ||||||
|     ); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="soft-delete-option"]').click(); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="confirm-button"]').should('be.disabled'); |  | ||||||
|     cy.get('[data-testid="confirmation-text-input"]').type(DELETE_TERM); |  | ||||||
| 
 |  | ||||||
|     interceptURL( |  | ||||||
|       'DELETE', |  | ||||||
|       'api/v1/tables/*?hardDelete=false&recursive=true', |  | ||||||
|       'softDeleteTable' |  | ||||||
|     ); |  | ||||||
|     cy.get('[data-testid="confirm-button"]').should('not.be.disabled'); |  | ||||||
|     cy.get('[data-testid="confirm-button"]').click(); |  | ||||||
|     verifyResponseStatusCode('@softDeleteTable', 200); |  | ||||||
| 
 |  | ||||||
|     toastNotification('Table deleted successfully!', false); |  | ||||||
|   }); |  | ||||||
| 
 |  | ||||||
|   it('Check Soft Deleted entity table', () => { |  | ||||||
|     cy.get('[data-testid="app-bar-item-explore"]').click(); |  | ||||||
|     cy.get('[data-testid="tables-tab"]').click(); |  | ||||||
| 
 |  | ||||||
|     verifyResponseStatusCode('@nonDeletedTables', 200); |  | ||||||
|     cy.get('[data-testid="show-deleted"]').should('exist').click(); |  | ||||||
|     verifyResponseStatusCode('@showDeletedTables', 200); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="entity-header-display-name"]') |  | ||||||
|       .contains(ENTITY_TABLE.displayName) |  | ||||||
|       .click(); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="entity-header-display-name"]').should( |  | ||||||
|       'contain', |  | ||||||
|       ENTITY_TABLE.displayName |  | ||||||
|     ); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="deleted-badge"]') |  | ||||||
|       .scrollIntoView() |  | ||||||
|       .should('be.visible'); |  | ||||||
|   }); |  | ||||||
| 
 |  | ||||||
|   it("Check Soft Deleted table in it's Schema", () => { |  | ||||||
|     cy.get('[data-testid="app-bar-item-explore"]').click(); |  | ||||||
|     cy.get('[data-testid="tables-tab"]').click(); |  | ||||||
|     verifyResponseStatusCode('@nonDeletedTables', 200); |  | ||||||
|     cy.get('[data-testid="show-deleted"]').click(); |  | ||||||
|     verifyResponseStatusCode('@showDeletedTables', 200); |  | ||||||
|     cy.get('[data-testid="entity-header-display-name"]') |  | ||||||
|       .contains(ENTITY_TABLE.displayName) |  | ||||||
|       .click(); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="deleted-badge"]').should('be.visible'); |  | ||||||
|     interceptURL( |  | ||||||
|       'GET', |  | ||||||
|       '/api/v1/databaseSchemas/name/*?fields=*&include=all', |  | ||||||
|       'getDatabaseSchemas' |  | ||||||
|     ); |  | ||||||
|     cy.get('[data-testid="breadcrumb"]') |  | ||||||
|       .scrollIntoView() |  | ||||||
|       .contains(ENTITY_TABLE.schemaName) |  | ||||||
|       .click(); |  | ||||||
|     verifyResponseStatusCode('@getDatabaseSchemas', 200); |  | ||||||
|     interceptURL( |  | ||||||
|       'GET', |  | ||||||
|       '/api/v1/tables?databaseSchema=*&include=deleted', |  | ||||||
|       'queryDeletedTables' |  | ||||||
|     ); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="show-deleted"]').scrollIntoView(); |  | ||||||
|     cy.get('[data-testid="show-deleted"]').click({ waitForAnimations: true }); |  | ||||||
| 
 |  | ||||||
|     verifyResponseStatusCode('@queryDeletedTables', 200); |  | ||||||
| 
 |  | ||||||
|     cy.get('[data-testid="table"] [data-testid="count"]').should( |  | ||||||
|       'contain', |  | ||||||
|       '1' |  | ||||||
|     ); |  | ||||||
| 
 |  | ||||||
|     cy.get('.ant-table-row > :nth-child(1)').should( |  | ||||||
|       'contain', |  | ||||||
|       ENTITY_TABLE.displayName |  | ||||||
|     ); |  | ||||||
|   }); |  | ||||||
| }); |  | ||||||
| @ -64,15 +64,12 @@ describe(`Advanced search quick filters should work properly for assets`, () => | |||||||
|         const querySearchURL = `/api/v1/search/query?*index=${ |         const querySearchURL = `/api/v1/search/query?*index=${ | ||||||
|           asset.searchIndex |           asset.searchIndex | ||||||
|         }*query_filter=*should*${filter.key}*${encodeURI( |         }*query_filter=*should*${filter.key}*${encodeURI( | ||||||
|           Cypress._.toLower(filter.selectOption1) |           Cypress._.toLower(filter.selectOption1).replace(' ', '+') | ||||||
|         )}*`;
 |         )}*`;
 | ||||||
| 
 | 
 | ||||||
|         interceptURL('GET', querySearchURL, 'querySearchAPI'); |         interceptURL('GET', querySearchURL, 'querySearchAPI'); | ||||||
| 
 | 
 | ||||||
|         cy.get('[data-testid="update-btn"]') |         cy.get('[data-testid="update-btn"]').click(); | ||||||
|           .should('exist') |  | ||||||
|           .and('be.visible') |  | ||||||
|           .click(); |  | ||||||
| 
 | 
 | ||||||
|         verifyResponseStatusCode('@querySearchAPI', 200); |         verifyResponseStatusCode('@querySearchAPI', 200); | ||||||
|       }); |       }); | ||||||
|  | |||||||
| @ -55,10 +55,6 @@ export const COMMON_DROPDOWN_ITEMS = [ | |||||||
|     label: t('label.service-type'), |     label: t('label.service-type'), | ||||||
|     key: 'serviceType', |     key: 'serviceType', | ||||||
|   }, |   }, | ||||||
|   { |  | ||||||
|     label: t('label.column'), |  | ||||||
|     key: 'columns.name.keyword', |  | ||||||
|   }, |  | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
| export const TABLE_DROPDOWN_ITEMS = [ | export const TABLE_DROPDOWN_ITEMS = [ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Chirag Madlani
						Chirag Madlani