mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 02:29:03 +00:00 
			
		
		
		
	ui: updated testCaseResult api from put to patch (#13117)
This commit is contained in:
		
							parent
							
								
									5de688bf9c
								
							
						
					
					
						commit
						2b2ec04bc9
					
				| @ -27,6 +27,7 @@ import { TestCaseStatusModal } from 'components/DataQuality/TestCaseStatusModal/ | ||||
| import ConfirmationModal from 'components/Modals/ConfirmationModal/ConfirmationModal'; | ||||
| import { usePermissionProvider } from 'components/PermissionProvider/PermissionProvider'; | ||||
| import { ResourceEntity } from 'components/PermissionProvider/PermissionProvider.interface'; | ||||
| import { compare } from 'fast-json-patch'; | ||||
| import { TestCaseStatus } from 'generated/configuration/testResultNotificationConfiguration'; | ||||
| import { Operation } from 'generated/entity/policies/policy'; | ||||
| import { isUndefined, sortBy } from 'lodash'; | ||||
| @ -34,7 +35,7 @@ import QueryString from 'qs'; | ||||
| import React, { useMemo, useState } from 'react'; | ||||
| import { useTranslation } from 'react-i18next'; | ||||
| import { Link } from 'react-router-dom'; | ||||
| import { putTestCaseResult, removeTestCaseFromTestSuite } from 'rest/testAPI'; | ||||
| import { patchTestCaseResult, removeTestCaseFromTestSuite } from 'rest/testAPI'; | ||||
| import { formatDate, formatDateTime } from 'utils/date-time/DateTimeUtils'; | ||||
| import { getEntityName } from 'utils/EntityUtils'; | ||||
| import { checkPermission } from 'utils/PermissionsUtils'; | ||||
| @ -115,14 +116,19 @@ const DataQualityTab: React.FC<DataQualityTabProps> = ({ | ||||
|   }; | ||||
| 
 | ||||
|   const handleStatusSubmit = async (data: TestCaseFailureStatus) => { | ||||
|     if (selectedTestCase?.data) { | ||||
|     if (selectedTestCase?.data?.testCaseResult) { | ||||
|       const timestamp = selectedTestCase.data?.testCaseResult.timestamp ?? 0; | ||||
|       const updatedResult: TestCaseResult = { | ||||
|         ...selectedTestCase.data?.testCaseResult, | ||||
|         testCaseFailureStatus: data, | ||||
|       }; | ||||
|       const testCaseFqn = selectedTestCase.data?.fullyQualifiedName ?? ''; | ||||
|       const patch = compare( | ||||
|         selectedTestCase.data.testCaseResult, | ||||
|         updatedResult | ||||
|       ); | ||||
|       try { | ||||
|         await putTestCaseResult(testCaseFqn, updatedResult); | ||||
|         await patchTestCaseResult({ testCaseFqn, patch, timestamp }); | ||||
| 
 | ||||
|         onTestCaseResultUpdate?.({ | ||||
|           ...selectedTestCase.data, | ||||
|  | ||||
| @ -273,14 +273,23 @@ export const restoreTestSuite = async (id: string) => { | ||||
| 
 | ||||
| // Test Result
 | ||||
| 
 | ||||
| export const putTestCaseResult = async ( | ||||
|   testCaseFqn: string, | ||||
|   data: TestCaseResult | ||||
| ) => { | ||||
|   const response = await APIClient.put< | ||||
|     TestCaseResult, | ||||
|     AxiosResponse<TestSuite> | ||||
|   >(`${testCaseUrl}/${testCaseFqn}/testCaseResult`, data); | ||||
| export const patchTestCaseResult = async ({ | ||||
|   testCaseFqn, | ||||
|   timestamp, | ||||
|   patch, | ||||
| }: { | ||||
|   testCaseFqn: string; | ||||
|   timestamp: number; | ||||
|   patch: Operation[]; | ||||
| }) => { | ||||
|   const configOptions = { | ||||
|     headers: { 'Content-type': 'application/json-patch+json' }, | ||||
|   }; | ||||
|   const response = await APIClient.patch<Operation[], AxiosResponse<TestSuite>>( | ||||
|     `${testCaseUrl}/${testCaseFqn}/testCaseResult/${timestamp}`, | ||||
|     patch, | ||||
|     configOptions | ||||
|   ); | ||||
| 
 | ||||
|   return response.data; | ||||
| }; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Shailesh Parmar
						Shailesh Parmar