mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-30 18:17:53 +00:00 
			
		
		
		
	Fixes: fixed failing unit tests (#844)
* fixed all failing test for UI * fixed 1 breaking change bcz of merging main branch
This commit is contained in:
		
							parent
							
								
									aec586a5fe
								
							
						
					
					
						commit
						09cc3b5dd2
					
				| @ -22,23 +22,23 @@ import FrequentlyJoinedTables from './FrequentlyJoinedTables'; | ||||
| 
 | ||||
| const mockTableList = [ | ||||
|   { | ||||
|     name: 'dim_customer', | ||||
|     fqn: 'string.1', | ||||
|     fullyQualifiedName: 'bigquery.shopify.fact_order', | ||||
|     joinCount: 150, | ||||
|     name: 'shopify/fact_order', | ||||
|   }, | ||||
|   { | ||||
|     fullyQualifiedName: 'bigquery.shopify.fact_sale', | ||||
|     joinCount: 55, | ||||
|     name: 'shopify/fact_sale', | ||||
|   }, | ||||
|   { | ||||
|     name: 'shopify/dim_product', | ||||
|     fullyQualifiedName: 'string.3', | ||||
|     joinCount: 1, | ||||
|   }, | ||||
|   { | ||||
|     name: 'fact_sale', | ||||
|     fqn: 'string.2', | ||||
|     joinCount: 1, | ||||
|   }, | ||||
|   { | ||||
|     name: 'dim_product', | ||||
|     fqn: 'string.3', | ||||
|     joinCount: 1, | ||||
|   }, | ||||
|   { | ||||
|     name: 'dim_address', | ||||
|     fqn: 'string.4', | ||||
|     name: 'shopify/dim_address', | ||||
|     fullyQualifiedName: 'string.4', | ||||
|     joinCount: 1, | ||||
|   }, | ||||
| ]; | ||||
| @ -69,9 +69,9 @@ describe('Test QueryDetails Component', () => { | ||||
| 
 | ||||
|     expect(tableData.length).toBe(4); | ||||
|     expect(tableData.map((tableName) => tableName.textContent)).toStrictEqual([ | ||||
|       'dim_address1', | ||||
|       'dim_product1', | ||||
|       'fact_sale1', | ||||
|       'shopify/fact_order150', | ||||
|       'shopify/fact_sale55', | ||||
|       'shopify/dim_address1', | ||||
|       '+ 1 more', | ||||
|     ]); | ||||
|   }); | ||||
|  | ||||
| @ -15,7 +15,7 @@ | ||||
|   * limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| import { getByTestId, render } from '@testing-library/react'; | ||||
| import { getByTestId, getByText, render } from '@testing-library/react'; | ||||
| import { TableDetail } from 'Models'; | ||||
| import React from 'react'; | ||||
| import { MemoryRouter } from 'react-router-dom'; | ||||
| @ -60,6 +60,10 @@ jest.mock('./SampleDataTable', () => { | ||||
|   return jest.fn().mockReturnValue(<p>SampleDataTable</p>); | ||||
| }); | ||||
| 
 | ||||
| jest.mock('./EntityTable', () => { | ||||
|   return jest.fn().mockReturnValue(<p>EntityTable</p>); | ||||
| }); | ||||
| 
 | ||||
| jest.mock('./SchemaTable', () => { | ||||
|   return jest | ||||
|     .fn() | ||||
| @ -86,7 +90,7 @@ describe('Test SchemaTab Component', () => { | ||||
| 
 | ||||
|     expect(searchBar).toBeInTheDocument(); | ||||
| 
 | ||||
|     const schemaTable = getByTestId(container, 'schema-table'); | ||||
|     const schemaTable = getByText(container, /EntityTable/i); | ||||
| 
 | ||||
|     expect(schemaTable).toBeInTheDocument(); | ||||
|     expect(queryByTestId('sample-data-table')).toBeNull(); | ||||
|  | ||||
| @ -43,6 +43,14 @@ jest.mock('../../components/my-data-details/ManageTab', () => { | ||||
|   return jest.fn().mockReturnValue(<p>ManageTab</p>); | ||||
| }); | ||||
| 
 | ||||
| jest.mock('../../components/dataset-lineage/EntityLineage', () => { | ||||
|   return jest.fn().mockReturnValue(<p>Lineage</p>); | ||||
| }); | ||||
| 
 | ||||
| jest.mock('../../components/my-data-details/ProfilerTable', () => { | ||||
|   return jest.fn().mockReturnValue(<p>ProfilerTable</p>); | ||||
| }); | ||||
| 
 | ||||
| jest.mock('../../components/common/description/Description', () => { | ||||
|   return jest.fn().mockReturnValue(<p>Description</p>); | ||||
| }); | ||||
| @ -60,7 +68,6 @@ jest.mock('../../utils/CommonUtils', () => ({ | ||||
| })); | ||||
| 
 | ||||
| describe('Test MyDataDetailsPage page', () => { | ||||
|   // Rewrite this test as component has actual data from api and api is not mocked here
 | ||||
|   it('Checks if the page has all the proper components rendered', () => { | ||||
|     const { container } = render(<MyDataDetailsPage />, { | ||||
|       wrapper: MemoryRouter, | ||||
| @ -71,7 +78,7 @@ describe('Test MyDataDetailsPage page', () => { | ||||
| 
 | ||||
|     expect(followButton).toBeInTheDocument(); | ||||
|     expect(relatedTables).toBeInTheDocument(); | ||||
|     // we only have 2 for now => schema and manage
 | ||||
|     expect(tabs.length).toBe(3); | ||||
|     // we have 4 for now => schema, Profiler, Lineage & manage
 | ||||
|     expect(tabs.length).toBe(4); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| @ -216,6 +216,7 @@ jest.mock('../../utils/ServiceUtils', () => ({ | ||||
|   getEntityCountByService: jest | ||||
|     .fn() | ||||
|     .mockReturnValue({ tableCount: 4, topicCount: 5, dashboardCount: 6 }), | ||||
|   getTotalEntityCountByService: jest.fn().mockReturnValue(2), | ||||
| })); | ||||
| 
 | ||||
| describe('Test MyData page', () => { | ||||
|  | ||||
| @ -48,6 +48,13 @@ const mockServiceDetails = { | ||||
|         name: 'dashboardServices', | ||||
|       }, | ||||
|     }, | ||||
|     { | ||||
|       collection: { | ||||
|         name: 'pipelineServices', | ||||
|         documentation: 'Pipeline service collection', | ||||
|         href: 'http://pipelineServices', | ||||
|       }, | ||||
|     }, | ||||
|   ], | ||||
| }; | ||||
| 
 | ||||
| @ -113,6 +120,22 @@ const mockDashboardService = { | ||||
|   }, | ||||
| }; | ||||
| 
 | ||||
| const mockPipelineService = { | ||||
|   data: { | ||||
|     data: [ | ||||
|       { | ||||
|         id: '7576944e-2921-4c15-9edc-b9bada93338a', | ||||
|         name: 'sample_airflow', | ||||
|         serviceType: 'Airflow', | ||||
|         description: 'Airflow service', | ||||
|         version: 0.1, | ||||
|         pipelineUrl: 'http://localhost:8080', | ||||
|         href: 'http://localhost:8585/api/v1/services/pipelineServices/7576944e-2921-4c15-9edc-b9bada93338a', | ||||
|       }, | ||||
|     ], | ||||
|   }, | ||||
| }; | ||||
| 
 | ||||
| jest.mock('../../axiosAPIs/serviceAPI', () => ({ | ||||
|   deleteService: jest.fn(), | ||||
|   getServiceDetails: jest | ||||
| @ -126,6 +149,9 @@ jest.mock('../../axiosAPIs/serviceAPI', () => ({ | ||||
|       case 'messagingServices': | ||||
|         return Promise.resolve(mockMessagingService); | ||||
| 
 | ||||
|       case 'pipelineServices': | ||||
|         return Promise.resolve(mockPipelineService); | ||||
| 
 | ||||
|       default: | ||||
|         return Promise.resolve(mockDashboardService); | ||||
|     } | ||||
| @ -168,9 +194,8 @@ describe('Test Service page', () => { | ||||
|     expect(tabs.length).toBe(mockServiceDetails.data.length); | ||||
|     expect(dataContainer).toBeInTheDocument(); | ||||
| 
 | ||||
|     // mockService.data.data.length + 1 because it has add service card as well
 | ||||
|     expect(dataContainer.childElementCount).toBe( | ||||
|       mockDatabaseService.data.data.length + 1 | ||||
|       mockDatabaseService.data.data.length | ||||
|     ); | ||||
|   }); | ||||
| 
 | ||||
| @ -209,7 +234,7 @@ describe('Test Service page', () => { | ||||
|     const { container } = render(<ServicesPage />, { | ||||
|       wrapper: MemoryRouter, | ||||
|     }); | ||||
|     const addService = await findByTestId(container, 'add-services'); | ||||
|     const addService = await findByTestId(container, 'add-new-user-button'); | ||||
|     fireEvent.click(addService); | ||||
| 
 | ||||
|     expect( | ||||
|  | ||||
| @ -123,6 +123,14 @@ jest.mock( | ||||
|       ) | ||||
| ); | ||||
| 
 | ||||
| jest.mock('react-router-dom', () => ({ | ||||
|   Link: jest.fn(({ children }: { children: ReactNode }) => ( | ||||
|     <span>{children}</span> | ||||
|   )), | ||||
|   useHistory: jest.fn(), | ||||
|   useParams: jest.fn().mockReturnValue({ team: 'team' }), | ||||
| })); | ||||
| 
 | ||||
| jest.mock('./AddUsersModal', () => { | ||||
|   return jest | ||||
|     .fn() | ||||
| @ -144,6 +152,10 @@ jest.mock( | ||||
|   }) | ||||
| ); | ||||
| 
 | ||||
| jest.mock('./UserCard', () => { | ||||
|   return jest.fn().mockReturnValue(<div>UserCard</div>); | ||||
| }); | ||||
| 
 | ||||
| describe('Test Teams page', () => { | ||||
|   it('Component should render', async () => { | ||||
|     const { container } = render(<TeamsPage />); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Shailesh Parmar
						Shailesh Parmar