mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-26 16:22:09 +00:00 
			
		
		
		
	UI: Fixed issue: TestSuite descriptions are unable to update and also unable to create a test suite when edit tests permission is given#7507 (#7557)
This commit is contained in:
		
							parent
							
								
									209aecc4a0
								
							
						
					
					
						commit
						9ee96deec4
					
				| @ -101,7 +101,7 @@ export const NEW_TEST_SUITE = { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const NEW_TABLE_TEST_CASE = { | export const NEW_TABLE_TEST_CASE = { | ||||||
|   type: 'TableColumnNameToExist', |   type: 'tableColumnNameToExist', | ||||||
|   field: 'id', |   field: 'id', | ||||||
|   description: 'New table test case for TableColumnNameToExist', |   description: 'New table test case for TableColumnNameToExist', | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -22,7 +22,11 @@ const columnTestName = `${NEW_COLUMN_TEST_CASE.column}_${NEW_COLUMN_TEST_CASE.ty | |||||||
| 
 | 
 | ||||||
| const goToProfilerTab = () => { | const goToProfilerTab = () => { | ||||||
|   // click on the 1st result and go to entity details page and follow the entity
 |   // click on the 1st result and go to entity details page and follow the entity
 | ||||||
|   interceptURL('GET', '/api/v1/feed*', 'getEntityDetails'); |   interceptURL( | ||||||
|  |     'GET', | ||||||
|  |     '/api/v1/tables/name/*?fields=columns,usageSummary,followers,joins,tags,owner,dataModel,profile,tests,tableConstraints,extension&include=all', | ||||||
|  |     'getEntityDetails' | ||||||
|  |   ); | ||||||
|   cy.get('[data-testid="table-link"]') |   cy.get('[data-testid="table-link"]') | ||||||
|     .first() |     .first() | ||||||
|     .contains(TEAM_ENTITY, { matchCase: false }) |     .contains(TEAM_ENTITY, { matchCase: false }) | ||||||
| @ -162,11 +166,16 @@ describe('Data Quality and Profiler should work properly', () => { | |||||||
|     // wait for ingestion to run
 |     // wait for ingestion to run
 | ||||||
|     cy.clock(); |     cy.clock(); | ||||||
|     cy.wait(10000); |     cy.wait(10000); | ||||||
| 
 |     interceptURL( | ||||||
|  |       'GET', | ||||||
|  |       '/api/v1/testCase?fields=testCaseResult,testDefinition,testSuite&testSuiteId=*&limit=10', | ||||||
|  |       'testCase' | ||||||
|  |     ); | ||||||
|     cy.get('[data-testid="view-service-button"]') |     cy.get('[data-testid="view-service-button"]') | ||||||
|       .should('be.visible') |       .should('be.visible') | ||||||
|       .click({ force: true }); |       .click({ force: true }); | ||||||
| 
 | 
 | ||||||
|  |     verifyResponseStatusCode('@testCase', 200); | ||||||
|     cy.contains(`${TEAM_ENTITY}_${NEW_TABLE_TEST_CASE.type}`).should( |     cy.contains(`${TEAM_ENTITY}_${NEW_TABLE_TEST_CASE.type}`).should( | ||||||
|       'be.visible' |       'be.visible' | ||||||
|     ); |     ); | ||||||
|  | |||||||
| @ -19,9 +19,11 @@ import React, { useMemo, useState } from 'react'; | |||||||
| import { Link } from 'react-router-dom'; | import { Link } from 'react-router-dom'; | ||||||
| import { ReactComponent as ArrowDown } from '../../../assets/svg/arrow-down.svg'; | import { ReactComponent as ArrowDown } from '../../../assets/svg/arrow-down.svg'; | ||||||
| import { ReactComponent as ArrowRight } from '../../../assets/svg/arrow-right.svg'; | import { ReactComponent as ArrowRight } from '../../../assets/svg/arrow-right.svg'; | ||||||
|  | import { useAuthContext } from '../../../authentication/auth-provider/AuthProvider'; | ||||||
| import { getTableTabPath } from '../../../constants/constants'; | import { getTableTabPath } from '../../../constants/constants'; | ||||||
| import { NO_PERMISSION_FOR_ACTION } from '../../../constants/HelperTextUtil'; | import { NO_PERMISSION_FOR_ACTION } from '../../../constants/HelperTextUtil'; | ||||||
| import { TestCase, TestCaseResult } from '../../../generated/tests/testCase'; | import { TestCase, TestCaseResult } from '../../../generated/tests/testCase'; | ||||||
|  | import { useAuth } from '../../../hooks/authHooks'; | ||||||
| import { getEntityName, getNameFromFQN } from '../../../utils/CommonUtils'; | import { getEntityName, getNameFromFQN } from '../../../utils/CommonUtils'; | ||||||
| import { getTestSuitePath } from '../../../utils/RouterUtils'; | import { getTestSuitePath } from '../../../utils/RouterUtils'; | ||||||
| import SVGIcons, { Icons } from '../../../utils/SvgUtils'; | import SVGIcons, { Icons } from '../../../utils/SvgUtils'; | ||||||
| @ -37,10 +39,13 @@ import TestSummary from './TestSummary'; | |||||||
| const DataQualityTab: React.FC<DataQualityTabProps> = ({ | const DataQualityTab: React.FC<DataQualityTabProps> = ({ | ||||||
|   testCases, |   testCases, | ||||||
|   onTestUpdate, |   onTestUpdate, | ||||||
|   hasAccess, |  | ||||||
| }) => { | }) => { | ||||||
|   const [selectedTestCase, setSelectedTestCase] = useState<TestCase>(); |   const [selectedTestCase, setSelectedTestCase] = useState<TestCase>(); | ||||||
|   const [editTestCase, setEditTestCase] = useState<TestCase>(); |   const [editTestCase, setEditTestCase] = useState<TestCase>(); | ||||||
|  |   const { isAdminUser } = useAuth(); | ||||||
|  |   const { isAuthDisabled } = useAuthContext(); | ||||||
|  | 
 | ||||||
|  |   const hasAccess = isAdminUser || isAuthDisabled; | ||||||
| 
 | 
 | ||||||
|   const columns: ColumnsType<TestCase> = useMemo(() => { |   const columns: ColumnsType<TestCase> = useMemo(() => { | ||||||
|     return [ |     return [ | ||||||
| @ -140,28 +145,6 @@ const DataQualityTab: React.FC<DataQualityTabProps> = ({ | |||||||
|         render: (_, record) => { |         render: (_, record) => { | ||||||
|           return ( |           return ( | ||||||
|             <Row align="middle"> |             <Row align="middle"> | ||||||
|               <Tooltip |  | ||||||
|                 placement="bottomLeft" |  | ||||||
|                 title={hasAccess ? 'Delete' : NO_PERMISSION_FOR_ACTION}> |  | ||||||
|                 <Button |  | ||||||
|                   className="flex-center" |  | ||||||
|                   data-testid={`delete-${record.name}`} |  | ||||||
|                   disabled={!hasAccess} |  | ||||||
|                   icon={ |  | ||||||
|                     <SVGIcons |  | ||||||
|                       alt="Delete" |  | ||||||
|                       className="tw-h-4" |  | ||||||
|                       icon={Icons.DELETE} |  | ||||||
|                     /> |  | ||||||
|                   } |  | ||||||
|                   type="text" |  | ||||||
|                   onClick={(e) => { |  | ||||||
|                     // preventing expand/collapse on click of delete button
 |  | ||||||
|                     e.stopPropagation(); |  | ||||||
|                     setSelectedTestCase(record); |  | ||||||
|                   }} |  | ||||||
|                 /> |  | ||||||
|               </Tooltip> |  | ||||||
|               <Tooltip |               <Tooltip | ||||||
|                 placement="bottomRight" |                 placement="bottomRight" | ||||||
|                 title={hasAccess ? 'Edit' : NO_PERMISSION_FOR_ACTION}> |                 title={hasAccess ? 'Edit' : NO_PERMISSION_FOR_ACTION}> | ||||||
| @ -185,6 +168,28 @@ const DataQualityTab: React.FC<DataQualityTabProps> = ({ | |||||||
|                   }} |                   }} | ||||||
|                 /> |                 /> | ||||||
|               </Tooltip> |               </Tooltip> | ||||||
|  |               <Tooltip | ||||||
|  |                 placement="bottomLeft" | ||||||
|  |                 title={hasAccess ? 'Delete' : NO_PERMISSION_FOR_ACTION}> | ||||||
|  |                 <Button | ||||||
|  |                   className="flex-center" | ||||||
|  |                   data-testid={`delete-${record.name}`} | ||||||
|  |                   disabled={!hasAccess} | ||||||
|  |                   icon={ | ||||||
|  |                     <SVGIcons | ||||||
|  |                       alt="Delete" | ||||||
|  |                       className="tw-h-4" | ||||||
|  |                       icon={Icons.DELETE} | ||||||
|  |                     /> | ||||||
|  |                   } | ||||||
|  |                   type="text" | ||||||
|  |                   onClick={(e) => { | ||||||
|  |                     // preventing expand/collapse on click of delete button
 | ||||||
|  |                     e.stopPropagation(); | ||||||
|  |                     setSelectedTestCase(record); | ||||||
|  |                   }} | ||||||
|  |                 /> | ||||||
|  |               </Tooltip> | ||||||
|             </Row> |             </Row> | ||||||
|           ); |           ); | ||||||
|         }, |         }, | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { Space, Tooltip } from 'antd'; | import { Space, Tooltip } from 'antd'; | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
|  | import { useAuthContext } from '../../authentication/auth-provider/AuthProvider'; | ||||||
| import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; | import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; | ||||||
|  | import { useAuth } from '../../hooks/authHooks'; | ||||||
| import { IcDeleteColored } from '../../utils/SvgUtils'; | import { IcDeleteColored } from '../../utils/SvgUtils'; | ||||||
| import { Button } from '../buttons/Button/Button'; | import { Button } from '../buttons/Button/Button'; | ||||||
| import DeleteWidgetModal from '../common/DeleteWidget/DeleteWidgetModal'; | import DeleteWidgetModal from '../common/DeleteWidget/DeleteWidgetModal'; | ||||||
| @ -20,8 +22,12 @@ const TestSuiteDetails = ({ | |||||||
|   testSuiteDescription, |   testSuiteDescription, | ||||||
|   descriptionHandler, |   descriptionHandler, | ||||||
|   handleDescriptionUpdate, |   handleDescriptionUpdate, | ||||||
|   permissions, |  | ||||||
| }: TestSuiteDetailsProps) => { | }: TestSuiteDetailsProps) => { | ||||||
|  |   const { isAdminUser } = useAuth(); | ||||||
|  |   const { isAuthDisabled } = useAuthContext(); | ||||||
|  | 
 | ||||||
|  |   const hasAccess = isAdminUser || isAuthDisabled; | ||||||
|  | 
 | ||||||
|   return ( |   return ( | ||||||
|     <> |     <> | ||||||
|       <Space |       <Space | ||||||
| @ -32,11 +38,10 @@ const TestSuiteDetails = ({ | |||||||
|           data-testid="test-suite-breadcrumb" |           data-testid="test-suite-breadcrumb" | ||||||
|           titleLinks={slashedBreadCrumb} |           titleLinks={slashedBreadCrumb} | ||||||
|         /> |         /> | ||||||
|         <Tooltip |         <Tooltip title={hasAccess ? 'Delete' : NO_PERMISSION_FOR_ACTION}> | ||||||
|           title={permissions.Delete ? 'Delete' : NO_PERMISSION_FOR_ACTION}> |  | ||||||
|           <Button |           <Button | ||||||
|             data-testid="test-suite-delete" |             data-testid="test-suite-delete" | ||||||
|             disabled={!permissions.Delete} |             disabled={!hasAccess} | ||||||
|             size="small" |             size="small" | ||||||
|             theme="primary" |             theme="primary" | ||||||
|             variant="outlined" |             variant="outlined" | ||||||
| @ -66,11 +71,7 @@ const TestSuiteDetails = ({ | |||||||
|           <span className="tw-flex" key={index}> |           <span className="tw-flex" key={index}> | ||||||
|             <EntitySummaryDetails |             <EntitySummaryDetails | ||||||
|               data={info} |               data={info} | ||||||
|               updateOwner={ |               updateOwner={hasAccess ? handleUpdateOwner : undefined} | ||||||
|                 permissions.EditAll || permissions.EditOwner |  | ||||||
|                   ? handleUpdateOwner |  | ||||||
|                   : undefined |  | ||||||
|               } |  | ||||||
|             /> |             /> | ||||||
|           </span> |           </span> | ||||||
|         ))} |         ))} | ||||||
| @ -81,7 +82,7 @@ const TestSuiteDetails = ({ | |||||||
|           className="test-suite-description" |           className="test-suite-description" | ||||||
|           description={testSuiteDescription || ''} |           description={testSuiteDescription || ''} | ||||||
|           entityName={testSuite?.displayName ?? testSuite?.name} |           entityName={testSuite?.displayName ?? testSuite?.name} | ||||||
|           hasEditAccess={permissions.EditDescription || permissions.EditAll} |           hasEditAccess={hasAccess} | ||||||
|           isEdit={isDescriptionEditable} |           isEdit={isDescriptionEditable} | ||||||
|           onCancel={() => descriptionHandler(false)} |           onCancel={() => descriptionHandler(false)} | ||||||
|           onDescriptionEdit={() => descriptionHandler(true)} |           onDescriptionEdit={() => descriptionHandler(true)} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Shailesh Parmar
						Shailesh Parmar