Skip to content

Commit

Permalink
ui: updated testCaseResult api from put to patch (open-metadata#13117)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaileshParmar11 authored Sep 8, 2023
1 parent 5de688b commit 2b2ec04
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ 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';
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';
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 17 additions & 8 deletions openmetadata-ui/src/main/resources/ui/src/rest/testAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 2b2ec04

Please sign in to comment.