mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 10:39:30 +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 = [ | const mockTableList = [ | ||||||
|   { |   { | ||||||
|     name: 'dim_customer', |     fullyQualifiedName: 'bigquery.shopify.fact_order', | ||||||
|     fqn: 'string.1', |     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, |     joinCount: 1, | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|     name: 'fact_sale', |     name: 'shopify/dim_address', | ||||||
|     fqn: 'string.2', |     fullyQualifiedName: 'string.4', | ||||||
|     joinCount: 1, |  | ||||||
|   }, |  | ||||||
|   { |  | ||||||
|     name: 'dim_product', |  | ||||||
|     fqn: 'string.3', |  | ||||||
|     joinCount: 1, |  | ||||||
|   }, |  | ||||||
|   { |  | ||||||
|     name: 'dim_address', |  | ||||||
|     fqn: 'string.4', |  | ||||||
|     joinCount: 1, |     joinCount: 1, | ||||||
|   }, |   }, | ||||||
| ]; | ]; | ||||||
| @ -69,9 +69,9 @@ describe('Test QueryDetails Component', () => { | |||||||
| 
 | 
 | ||||||
|     expect(tableData.length).toBe(4); |     expect(tableData.length).toBe(4); | ||||||
|     expect(tableData.map((tableName) => tableName.textContent)).toStrictEqual([ |     expect(tableData.map((tableName) => tableName.textContent)).toStrictEqual([ | ||||||
|       'dim_address1', |       'shopify/fact_order150', | ||||||
|       'dim_product1', |       'shopify/fact_sale55', | ||||||
|       'fact_sale1', |       'shopify/dim_address1', | ||||||
|       '+ 1 more', |       '+ 1 more', | ||||||
|     ]); |     ]); | ||||||
|   }); |   }); | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ | |||||||
|   * limitations under the License. |   * limitations under the License. | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| import { getByTestId, render } from '@testing-library/react'; | import { getByTestId, getByText, render } from '@testing-library/react'; | ||||||
| import { TableDetail } from 'Models'; | import { TableDetail } from 'Models'; | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
| import { MemoryRouter } from 'react-router-dom'; | import { MemoryRouter } from 'react-router-dom'; | ||||||
| @ -60,6 +60,10 @@ jest.mock('./SampleDataTable', () => { | |||||||
|   return jest.fn().mockReturnValue(<p>SampleDataTable</p>); |   return jest.fn().mockReturnValue(<p>SampleDataTable</p>); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | jest.mock('./EntityTable', () => { | ||||||
|  |   return jest.fn().mockReturnValue(<p>EntityTable</p>); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
| jest.mock('./SchemaTable', () => { | jest.mock('./SchemaTable', () => { | ||||||
|   return jest |   return jest | ||||||
|     .fn() |     .fn() | ||||||
| @ -86,7 +90,7 @@ describe('Test SchemaTab Component', () => { | |||||||
| 
 | 
 | ||||||
|     expect(searchBar).toBeInTheDocument(); |     expect(searchBar).toBeInTheDocument(); | ||||||
| 
 | 
 | ||||||
|     const schemaTable = getByTestId(container, 'schema-table'); |     const schemaTable = getByText(container, /EntityTable/i); | ||||||
| 
 | 
 | ||||||
|     expect(schemaTable).toBeInTheDocument(); |     expect(schemaTable).toBeInTheDocument(); | ||||||
|     expect(queryByTestId('sample-data-table')).toBeNull(); |     expect(queryByTestId('sample-data-table')).toBeNull(); | ||||||
|  | |||||||
| @ -43,6 +43,14 @@ jest.mock('../../components/my-data-details/ManageTab', () => { | |||||||
|   return jest.fn().mockReturnValue(<p>ManageTab</p>); |   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', () => { | jest.mock('../../components/common/description/Description', () => { | ||||||
|   return jest.fn().mockReturnValue(<p>Description</p>); |   return jest.fn().mockReturnValue(<p>Description</p>); | ||||||
| }); | }); | ||||||
| @ -60,7 +68,6 @@ jest.mock('../../utils/CommonUtils', () => ({ | |||||||
| })); | })); | ||||||
| 
 | 
 | ||||||
| describe('Test MyDataDetailsPage page', () => { | 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', () => { |   it('Checks if the page has all the proper components rendered', () => { | ||||||
|     const { container } = render(<MyDataDetailsPage />, { |     const { container } = render(<MyDataDetailsPage />, { | ||||||
|       wrapper: MemoryRouter, |       wrapper: MemoryRouter, | ||||||
| @ -71,7 +78,7 @@ describe('Test MyDataDetailsPage page', () => { | |||||||
| 
 | 
 | ||||||
|     expect(followButton).toBeInTheDocument(); |     expect(followButton).toBeInTheDocument(); | ||||||
|     expect(relatedTables).toBeInTheDocument(); |     expect(relatedTables).toBeInTheDocument(); | ||||||
|     // we only have 2 for now => schema and manage
 |     // we have 4 for now => schema, Profiler, Lineage & manage
 | ||||||
|     expect(tabs.length).toBe(3); |     expect(tabs.length).toBe(4); | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
|  | |||||||
| @ -216,6 +216,7 @@ jest.mock('../../utils/ServiceUtils', () => ({ | |||||||
|   getEntityCountByService: jest |   getEntityCountByService: jest | ||||||
|     .fn() |     .fn() | ||||||
|     .mockReturnValue({ tableCount: 4, topicCount: 5, dashboardCount: 6 }), |     .mockReturnValue({ tableCount: 4, topicCount: 5, dashboardCount: 6 }), | ||||||
|  |   getTotalEntityCountByService: jest.fn().mockReturnValue(2), | ||||||
| })); | })); | ||||||
| 
 | 
 | ||||||
| describe('Test MyData page', () => { | describe('Test MyData page', () => { | ||||||
|  | |||||||
| @ -48,6 +48,13 @@ const mockServiceDetails = { | |||||||
|         name: 'dashboardServices', |         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', () => ({ | jest.mock('../../axiosAPIs/serviceAPI', () => ({ | ||||||
|   deleteService: jest.fn(), |   deleteService: jest.fn(), | ||||||
|   getServiceDetails: jest |   getServiceDetails: jest | ||||||
| @ -126,6 +149,9 @@ jest.mock('../../axiosAPIs/serviceAPI', () => ({ | |||||||
|       case 'messagingServices': |       case 'messagingServices': | ||||||
|         return Promise.resolve(mockMessagingService); |         return Promise.resolve(mockMessagingService); | ||||||
| 
 | 
 | ||||||
|  |       case 'pipelineServices': | ||||||
|  |         return Promise.resolve(mockPipelineService); | ||||||
|  | 
 | ||||||
|       default: |       default: | ||||||
|         return Promise.resolve(mockDashboardService); |         return Promise.resolve(mockDashboardService); | ||||||
|     } |     } | ||||||
| @ -168,9 +194,8 @@ describe('Test Service page', () => { | |||||||
|     expect(tabs.length).toBe(mockServiceDetails.data.length); |     expect(tabs.length).toBe(mockServiceDetails.data.length); | ||||||
|     expect(dataContainer).toBeInTheDocument(); |     expect(dataContainer).toBeInTheDocument(); | ||||||
| 
 | 
 | ||||||
|     // mockService.data.data.length + 1 because it has add service card as well
 |  | ||||||
|     expect(dataContainer.childElementCount).toBe( |     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 />, { |     const { container } = render(<ServicesPage />, { | ||||||
|       wrapper: MemoryRouter, |       wrapper: MemoryRouter, | ||||||
|     }); |     }); | ||||||
|     const addService = await findByTestId(container, 'add-services'); |     const addService = await findByTestId(container, 'add-new-user-button'); | ||||||
|     fireEvent.click(addService); |     fireEvent.click(addService); | ||||||
| 
 | 
 | ||||||
|     expect( |     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', () => { | jest.mock('./AddUsersModal', () => { | ||||||
|   return jest |   return jest | ||||||
|     .fn() |     .fn() | ||||||
| @ -144,6 +152,10 @@ jest.mock( | |||||||
|   }) |   }) | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
|  | jest.mock('./UserCard', () => { | ||||||
|  |   return jest.fn().mockReturnValue(<div>UserCard</div>); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
| describe('Test Teams page', () => { | describe('Test Teams page', () => { | ||||||
|   it('Component should render', async () => { |   it('Component should render', async () => { | ||||||
|     const { container } = render(<TeamsPage />); |     const { container } = render(<TeamsPage />); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Shailesh Parmar
						Shailesh Parmar