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 { 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,

View File

@ -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;
};