mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 02:29:03 +00:00 
			
		
		
		
	UI : Fix Test cases breaking issue while editing (#10095)
* Fix Test cases while edit * Added cypress for null test type * fix unit test issue
This commit is contained in:
		
							parent
							
								
									852edc74d3
								
							
						
					
					
						commit
						942b553edc
					
				| @ -170,6 +170,12 @@ export const NEW_COLUMN_TEST_CASE = { | |||||||
|   description: 'New table test case for columnValueLengthsToBeBetween', |   description: 'New table test case for columnValueLengthsToBeBetween', | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | export const NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE = { | ||||||
|  |   column: 'id', | ||||||
|  |   type: 'columnValuesToBeNotNull', | ||||||
|  |   description: 'New table test case for columnValuesToBeNotNull', | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| export const NEW_TEAM = { | export const NEW_TEAM = { | ||||||
|   team_1: { |   team_1: { | ||||||
|     name: 'account', |     name: 'account', | ||||||
|  | |||||||
| @ -33,6 +33,7 @@ import { | |||||||
|   DELETE_TERM, |   DELETE_TERM, | ||||||
|   MYDATA_SUMMARY_OPTIONS, |   MYDATA_SUMMARY_OPTIONS, | ||||||
|   NEW_COLUMN_TEST_CASE, |   NEW_COLUMN_TEST_CASE, | ||||||
|  |   NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE, | ||||||
|   NEW_TABLE_TEST_CASE, |   NEW_TABLE_TEST_CASE, | ||||||
|   NEW_TEST_SUITE, |   NEW_TEST_SUITE, | ||||||
|   SERVICE_TYPE, |   SERVICE_TYPE, | ||||||
| @ -42,6 +43,7 @@ import { | |||||||
| const serviceType = 'Mysql'; | const serviceType = 'Mysql'; | ||||||
| const serviceName = `${serviceType}-ct-test-${uuid()}`; | const serviceName = `${serviceType}-ct-test-${uuid()}`; | ||||||
| const columnTestName = `${NEW_COLUMN_TEST_CASE.column}_${NEW_COLUMN_TEST_CASE.type}`; | const columnTestName = `${NEW_COLUMN_TEST_CASE.column}_${NEW_COLUMN_TEST_CASE.type}`; | ||||||
|  | const nonTeamTypeColumnTestName = `${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.column}_${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.type}`; | ||||||
| 
 | 
 | ||||||
| const goToProfilerTab = () => { | const goToProfilerTab = () => { | ||||||
|   interceptURL( |   interceptURL( | ||||||
| @ -325,6 +327,49 @@ describe('Data Quality and Profiler should work properly', () => { | |||||||
|       'contain', |       'contain', | ||||||
|       'id_columnValueLengthsToBeBetween' |       'id_columnValueLengthsToBeBetween' | ||||||
|     ); |     ); | ||||||
|  | 
 | ||||||
|  |     // Creating new test case and selecting Null team type
 | ||||||
|  | 
 | ||||||
|  |     goToProfilerTab(); | ||||||
|  |     cy.get('[data-testid="profiler-tab-left-panel"]') | ||||||
|  |       .contains('Column Profile') | ||||||
|  |       .should('be.visible') | ||||||
|  |       .click(); | ||||||
|  | 
 | ||||||
|  |     cy.get('[data-testid="add-test-id"]') | ||||||
|  |       .scrollIntoView() | ||||||
|  |       .should('be.visible') | ||||||
|  |       .click(); | ||||||
|  | 
 | ||||||
|  |     // selecting existing test suite
 | ||||||
|  |     cy.get('#selectTestSuite_testSuiteId').should('exist').click(); | ||||||
|  |     cy.contains(NEW_TEST_SUITE.name).should('be.visible').click(); | ||||||
|  |     cy.get('[data-testid="next-button"]') | ||||||
|  |       .scrollIntoView() | ||||||
|  |       .should('be.visible') | ||||||
|  |       .click(); | ||||||
|  | 
 | ||||||
|  |     cy.get('#tableTestForm_testTypeId').scrollIntoView().click(); | ||||||
|  |     cy.get(`[title="${NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.type}"]`) | ||||||
|  |       .scrollIntoView() | ||||||
|  |       .should('be.visible') | ||||||
|  |       .click(); | ||||||
|  |     cy.get(descriptionBox) | ||||||
|  |       .scrollIntoView() | ||||||
|  |       .type(NEW_COLUMN_TEST_CASE_WITH_NULL_TYPE.description); | ||||||
|  | 
 | ||||||
|  |     cy.get('[data-testid="submit-test"]') | ||||||
|  |       .scrollIntoView() | ||||||
|  |       .should('be.visible') | ||||||
|  |       .click(); | ||||||
|  | 
 | ||||||
|  |     cy.get('[data-testid="success-line"]') | ||||||
|  |       .contains( | ||||||
|  |         'has been created successfully. This will be picked up in the next run.' | ||||||
|  |       ) | ||||||
|  |       .should('be.visible'); | ||||||
|  |     cy.get('[data-testid="view-service-button"]').scrollIntoView().click(); | ||||||
|  |     cy.get('.ant-table-row').should('contain', 'id_columnValuesToBeNotNull'); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Edit column test case should work properly', () => { |   it('Edit column test case should work properly', () => { | ||||||
| @ -358,6 +403,14 @@ describe('Data Quality and Profiler should work properly', () => { | |||||||
|       .wait(200); |       .wait(200); | ||||||
|     cy.get(`[data-testid="${columnTestName}"]`).should('be.visible').click(); |     cy.get(`[data-testid="${columnTestName}"]`).should('be.visible').click(); | ||||||
|     cy.contains('minLength: 4').scrollIntoView().should('exist'); |     cy.contains('minLength: 4').scrollIntoView().should('exist'); | ||||||
|  | 
 | ||||||
|  |     // Editing Non Team Type Test Case
 | ||||||
|  |     cy.get(`[data-testid="${nonTeamTypeColumnTestName}"]`).should('be.visible'); | ||||||
|  |     cy.get(`[data-testid="edit-${nonTeamTypeColumnTestName}"]`) | ||||||
|  |       .scrollIntoView() | ||||||
|  |       .should('be.visible') | ||||||
|  |       .click(); | ||||||
|  |     cy.get('.ant-modal-footer').contains('Cancel').click(); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('Delete Column Test Case should work properly', () => { |   it('Delete Column Test Case should work properly', () => { | ||||||
| @ -373,8 +426,9 @@ describe('Data Quality and Profiler should work properly', () => { | |||||||
|       .should('be.visible') |       .should('be.visible') | ||||||
|       .click(); |       .click(); | ||||||
| 
 | 
 | ||||||
|     cy.get(`[data-testid="${columnTestName}"]`).should('be.visible'); |     [columnTestName, nonTeamTypeColumnTestName].map((test) => { | ||||||
|     cy.get(`[data-testid="delete-${columnTestName}"]`) |       cy.get(`[data-testid="${test}"]`).should('be.visible'); | ||||||
|  |       cy.get(`[data-testid="delete-${test}"]`) | ||||||
|         .scrollIntoView() |         .scrollIntoView() | ||||||
|         .should('be.visible') |         .should('be.visible') | ||||||
|         .click(); |         .click(); | ||||||
| @ -395,6 +449,8 @@ describe('Data Quality and Profiler should work properly', () => { | |||||||
|       verifyResponseStatusCode('@deleteTest', 200); |       verifyResponseStatusCode('@deleteTest', 200); | ||||||
|       verifyResponseStatusCode('@getTestCase', 200); |       verifyResponseStatusCode('@getTestCase', 200); | ||||||
|       toastNotification('Test Case deleted successfully!'); |       toastNotification('Test Case deleted successfully!'); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|     cy.get('[class="ant-empty-description"]') |     cy.get('[class="ant-empty-description"]') | ||||||
|       .invoke('text') |       .invoke('text') | ||||||
|       .should('eq', 'No data'); |       .should('eq', 'No data'); | ||||||
|  | |||||||
| @ -69,7 +69,7 @@ const EditTestCaseModal: React.FC<EditTestCaseModalProps> = ({ | |||||||
| 
 | 
 | ||||||
|   const GenerateParamsField = useCallback(() => { |   const GenerateParamsField = useCallback(() => { | ||||||
|     if (selectedDefinition && selectedDefinition.parameterDefinition) { |     if (selectedDefinition && selectedDefinition.parameterDefinition) { | ||||||
|       const name = selectedDefinition.parameterDefinition[0].name; |       const name = selectedDefinition.parameterDefinition[0]?.name; | ||||||
|       if (name === 'sqlExpression') { |       if (name === 'sqlExpression') { | ||||||
|         return ( |         return ( | ||||||
|           <Form.Item |           <Form.Item | ||||||
| @ -166,7 +166,7 @@ const EditTestCaseModal: React.FC<EditTestCaseModalProps> = ({ | |||||||
|       (acc, curr) => ({ |       (acc, curr) => ({ | ||||||
|         ...acc, |         ...acc, | ||||||
|         [curr.name || '']: |         [curr.name || '']: | ||||||
|           selectedDefinition?.parameterDefinition?.[0].dataType === |           selectedDefinition?.parameterDefinition?.[0]?.dataType === | ||||||
|           TestDataType.Array |           TestDataType.Array | ||||||
|             ? (JSON.parse(curr.value || '[]') as string[]).map((val) => ({ |             ? (JSON.parse(curr.value || '[]') as string[]).map((val) => ({ | ||||||
|                 value: val, |                 value: val, | ||||||
|  | |||||||
| @ -63,7 +63,7 @@ jest.mock('../containers/PageLayout', () => { | |||||||
|   return jest |   return jest | ||||||
|     .fn() |     .fn() | ||||||
|     .mockImplementation(({ children }) => ( |     .mockImplementation(({ children }) => ( | ||||||
|       <div data-testid="page-container">{children}</div> |       <div data-testid="page-layout-v1">{children}</div> | ||||||
|     )); |     )); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| @ -107,7 +107,7 @@ describe('Test ProfilerDashboardPage component', () => { | |||||||
|         wrapper: MemoryRouter, |         wrapper: MemoryRouter, | ||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
|     const pageContainer = await screen.findByTestId('page-container'); |     const pageContainer = await screen.findByTestId('page-layout-v1'); | ||||||
|     const profilerSwitch = await screen.findByTestId('profiler-switch'); |     const profilerSwitch = await screen.findByTestId('profiler-switch'); | ||||||
|     const EntityPageInfo = await screen.findByText('EntityPageInfo component'); |     const EntityPageInfo = await screen.findByText('EntityPageInfo component'); | ||||||
|     const ProfilerTab = await screen.findByText('ProfilerTab component'); |     const ProfilerTab = await screen.findByText('ProfilerTab component'); | ||||||
| @ -132,7 +132,7 @@ describe('Test ProfilerDashboardPage component', () => { | |||||||
|         wrapper: MemoryRouter, |         wrapper: MemoryRouter, | ||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
|     const pageContainer = await screen.findByTestId('page-container'); |     const pageContainer = await screen.findByTestId('page-layout-v1'); | ||||||
|     const profilerSwitch = await screen.findByTestId('profiler-switch'); |     const profilerSwitch = await screen.findByTestId('profiler-switch'); | ||||||
|     const EntityPageInfo = await screen.findByText('EntityPageInfo component'); |     const EntityPageInfo = await screen.findByText('EntityPageInfo component'); | ||||||
|     const ProfilerTab = screen.queryByText('ProfilerTab component'); |     const ProfilerTab = screen.queryByText('ProfilerTab component'); | ||||||
| @ -159,7 +159,7 @@ describe('Test ProfilerDashboardPage component', () => { | |||||||
|         wrapper: MemoryRouter, |         wrapper: MemoryRouter, | ||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
|     const pageContainer = await screen.findByTestId('page-container'); |     const pageContainer = await screen.findByTestId('page-layout-v1'); | ||||||
|     const profilerSwitch = await screen.findByTestId('profiler-switch'); |     const profilerSwitch = await screen.findByTestId('profiler-switch'); | ||||||
|     const EntityPageInfo = await screen.findByText('EntityPageInfo component'); |     const EntityPageInfo = await screen.findByText('EntityPageInfo component'); | ||||||
|     const ProfilerTab = await screen.findByText('ProfilerTab component'); |     const ProfilerTab = await screen.findByText('ProfilerTab component'); | ||||||
| @ -225,7 +225,7 @@ describe('Test ProfilerDashboardPage component', () => { | |||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     const pageContainer = await screen.findByTestId('page-container'); |     const pageContainer = await screen.findByTestId('page-layout-v1'); | ||||||
|     const addTest = await screen.findByTestId('add-test'); |     const addTest = await screen.findByTestId('add-test'); | ||||||
| 
 | 
 | ||||||
|     expect(pageContainer).toBeInTheDocument(); |     expect(pageContainer).toBeInTheDocument(); | ||||||
|  | |||||||
| @ -25,6 +25,7 @@ import { | |||||||
| import { RadioChangeEvent } from 'antd/lib/radio'; | import { RadioChangeEvent } from 'antd/lib/radio'; | ||||||
| import { SwitchChangeEventHandler } from 'antd/lib/switch'; | import { SwitchChangeEventHandler } from 'antd/lib/switch'; | ||||||
| import { AxiosError } from 'axios'; | import { AxiosError } from 'axios'; | ||||||
|  | import PageLayoutV1 from 'components/containers/PageLayoutV1'; | ||||||
| import { EntityTags, ExtraInfo } from 'Models'; | import { EntityTags, ExtraInfo } from 'Models'; | ||||||
| import React, { useEffect, useMemo, useState } from 'react'; | import React, { useEffect, useMemo, useState } from 'react'; | ||||||
| import { useHistory, useParams } from 'react-router-dom'; | import { useHistory, useParams } from 'react-router-dom'; | ||||||
| @ -71,7 +72,6 @@ import { | |||||||
| import { showErrorToast } from '../../utils/ToastUtils'; | import { showErrorToast } from '../../utils/ToastUtils'; | ||||||
| import EntityPageInfo from '../common/entityPageInfo/EntityPageInfo'; | import EntityPageInfo from '../common/entityPageInfo/EntityPageInfo'; | ||||||
| import { TitleBreadcrumbProps } from '../common/title-breadcrumb/title-breadcrumb.interface'; | import { TitleBreadcrumbProps } from '../common/title-breadcrumb/title-breadcrumb.interface'; | ||||||
| import PageLayout from '../containers/PageLayout'; |  | ||||||
| import { usePermissionProvider } from '../PermissionProvider/PermissionProvider'; | import { usePermissionProvider } from '../PermissionProvider/PermissionProvider'; | ||||||
| import { | import { | ||||||
|   OperationPermission, |   OperationPermission, | ||||||
| @ -454,7 +454,7 @@ const ProfilerDashboard: React.FC<ProfilerDashboardProps> = ({ | |||||||
|   }, [table]); |   }, [table]); | ||||||
| 
 | 
 | ||||||
|   return ( |   return ( | ||||||
|     <PageLayout> |     <PageLayoutV1> | ||||||
|       <Row gutter={[16, 16]}> |       <Row gutter={[16, 16]}> | ||||||
|         <Col span={24}> |         <Col span={24}> | ||||||
|           <EntityPageInfo |           <EntityPageInfo | ||||||
| @ -575,7 +575,7 @@ const ProfilerDashboard: React.FC<ProfilerDashboardProps> = ({ | |||||||
|           </Col> |           </Col> | ||||||
|         )} |         )} | ||||||
|       </Row> |       </Row> | ||||||
|     </PageLayout> |     </PageLayoutV1> | ||||||
|   ); |   ); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -38,7 +38,11 @@ const PageLayoutV1: FC<PageLayoutProp> = ({ | |||||||
|   center = false, |   center = false, | ||||||
| }: PageLayoutProp) => { | }: PageLayoutProp) => { | ||||||
|   return ( |   return ( | ||||||
|     <Row className={className} gutter={[16, 16]} style={pageContainerStyles}> |     <Row | ||||||
|  |       className={className} | ||||||
|  |       data-testid="page-layout-v1" | ||||||
|  |       gutter={[16, 16]} | ||||||
|  |       style={pageContainerStyles}> | ||||||
|       {leftPanel && ( |       {leftPanel && ( | ||||||
|         <Col |         <Col | ||||||
|           className="page-layout-v1-vertical-scroll" |           className="page-layout-v1-vertical-scroll" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Ashish Gupta
						Ashish Gupta