ui: updated testCaseResult api from put to patch (#13117)

This commit is contained in:
Shailesh Parmar 2023-09-08 17:21:47 +05:30 committed by GitHub
parent 5de688bf9c
commit 2b2ec04bc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 11 deletions

View File

@ -27,6 +27,7 @@ import { TestCaseStatusModal } from 'components/DataQuality/TestCaseStatusModal/
import ConfirmationModal from 'components/Modals/ConfirmationModal/ConfirmationModal'; import ConfirmationModal from 'components/Modals/ConfirmationModal/ConfirmationModal';
import { usePermissionProvider } from 'components/PermissionProvider/PermissionProvider'; import { usePermissionProvider } from 'components/PermissionProvider/PermissionProvider';
import { ResourceEntity } from 'components/PermissionProvider/PermissionProvider.interface'; import { ResourceEntity } from 'components/PermissionProvider/PermissionProvider.interface';
import { compare } from 'fast-json-patch';
import { TestCaseStatus } from 'generated/configuration/testResultNotificationConfiguration'; import { TestCaseStatus } from 'generated/configuration/testResultNotificationConfiguration';
import { Operation } from 'generated/entity/policies/policy'; import { Operation } from 'generated/entity/policies/policy';
import { isUndefined, sortBy } from 'lodash'; import { isUndefined, sortBy } from 'lodash';
@ -34,7 +35,7 @@ import QueryString from 'qs';
import React, { useMemo, useState } from 'react'; import React, { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom'; 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 { formatDate, formatDateTime } from 'utils/date-time/DateTimeUtils';
import { getEntityName } from 'utils/EntityUtils'; import { getEntityName } from 'utils/EntityUtils';
import { checkPermission } from 'utils/PermissionsUtils'; import { checkPermission } from 'utils/PermissionsUtils';
@ -115,14 +116,19 @@ const DataQualityTab: React.FC<DataQualityTabProps> = ({
}; };
const handleStatusSubmit = async (data: TestCaseFailureStatus) => { const handleStatusSubmit = async (data: TestCaseFailureStatus) => {
if (selectedTestCase?.data) { if (selectedTestCase?.data?.testCaseResult) {
const timestamp = selectedTestCase.data?.testCaseResult.timestamp ?? 0;
const updatedResult: TestCaseResult = { const updatedResult: TestCaseResult = {
...selectedTestCase.data?.testCaseResult, ...selectedTestCase.data?.testCaseResult,
testCaseFailureStatus: data, testCaseFailureStatus: data,
}; };
const testCaseFqn = selectedTestCase.data?.fullyQualifiedName ?? ''; const testCaseFqn = selectedTestCase.data?.fullyQualifiedName ?? '';
const patch = compare(
selectedTestCase.data.testCaseResult,
updatedResult
);
try { try {
await putTestCaseResult(testCaseFqn, updatedResult); await patchTestCaseResult({ testCaseFqn, patch, timestamp });
onTestCaseResultUpdate?.({ onTestCaseResultUpdate?.({
...selectedTestCase.data, ...selectedTestCase.data,

View File

@ -273,14 +273,23 @@ export const restoreTestSuite = async (id: string) => {
// Test Result // Test Result
export const putTestCaseResult = async ( export const patchTestCaseResult = async ({
testCaseFqn: string, testCaseFqn,
data: TestCaseResult timestamp,
) => { patch,
const response = await APIClient.put< }: {
TestCaseResult, testCaseFqn: string;
AxiosResponse<TestSuite> timestamp: number;
>(`${testCaseUrl}/${testCaseFqn}/testCaseResult`, data); 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; return response.data;
}; };