From 692a0127f8552219866548aaf422fb7298b64ee4 Mon Sep 17 00:00:00 2001 From: Kenil Date: Fri, 27 Sep 2024 15:54:52 +0530 Subject: [PATCH] added partial success tag --- .../StatusBadge.component.test.tsx | 36 +++++++++++++++++++ .../StatusBadge/StatusBadge.interface.ts | 1 + .../common/StatusBadge/status-badge.less | 5 +++ .../resources/ui/src/constants/constants.ts | 1 + .../ui/src/utils/ApplicationUtils.test.ts | 15 +++++++- .../ui/src/utils/ApplicationUtils.tsx | 3 ++ 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadge.component.test.tsx diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadge.component.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadge.component.test.tsx new file mode 100644 index 000000000000..561b79173a08 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadge.component.test.tsx @@ -0,0 +1,36 @@ +/* + * Copyright 2024 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import '@testing-library/jest-dom'; +import { render, screen } from '@testing-library/react'; +import React from 'react'; +import { STATUS_LABEL } from '../../../constants/constants'; +import { Status } from '../../../generated/entity/applications/appRunRecord'; +import StatusBadge from './StatusBadge.component'; +import { StatusBadgeProps, StatusType } from './StatusBadge.interface'; + +describe('Test StatusBadge Component', () => { + const defaultProps: StatusBadgeProps = { + dataTestId: 'pipeline-status', + label: STATUS_LABEL[Status.PartialSuccess], + status: StatusType.PartialSuccess, + }; + + it('renders the correct label', () => { + render(); + + // Check if the label text "Partial Success" is rendered + expect( + screen.getByText(STATUS_LABEL[Status.PartialSuccess]) + ).toBeInTheDocument(); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadge.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadge.interface.ts index 8056bd35ce96..f281d49156ec 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadge.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/StatusBadge.interface.ts @@ -18,6 +18,7 @@ export enum StatusType { Running = 'running', Started = 'started', Stopped = 'stopped', + PartialSuccess = 'partialSuccess', } export interface StatusBadgeProps { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/status-badge.less b/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/status-badge.less index 56561cc19ee8..4a0884506181 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/status-badge.less +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/StatusBadge/status-badge.less @@ -47,4 +47,9 @@ background-color: @grey-2; border: 1px solid @grey-3; } + &.partialSuccess { + color: @partial-success-1; + background-color: @partial-success-2; + border-color: @partial-success-1; + } } diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/constants.ts b/openmetadata-ui/src/main/resources/ui/src/constants/constants.ts index 5d716c8eff32..26c405a6a7db 100644 --- a/openmetadata-ui/src/main/resources/ui/src/constants/constants.ts +++ b/openmetadata-ui/src/main/resources/ui/src/constants/constants.ts @@ -608,4 +608,5 @@ export const STATUS_LABEL = { [Status.Started]: 'Started', [Status.Stopped]: 'Stopped', [Status.Success]: 'Success', + [Status.PartialSuccess]: 'Partial Success', }; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/ApplicationUtils.test.ts b/openmetadata-ui/src/main/resources/ui/src/utils/ApplicationUtils.test.ts index e01114a1a5a2..9644721c822f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/ApplicationUtils.test.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/ApplicationUtils.test.ts @@ -12,7 +12,12 @@ */ import { upperFirst } from 'lodash'; -import { getEntityStatsData } from './ApplicationUtils'; +import { StatusType } from '../components/common/StatusBadge/StatusBadge.interface'; +import { Status } from '../generated/entity/applications/appRunRecord'; +import { + getEntityStatsData, + getStatusTypeForApplication, +} from './ApplicationUtils'; import { MOCK_APPLICATION_ENTITY_STATS, MOCK_APPLICATION_ENTITY_STATS_DATA, @@ -30,3 +35,11 @@ describe('ApplicationUtils tests', () => { ); }); }); + +describe('getStatusTypeForApplication tests', () => { + it('should return PartialSuccess for PartialSuccess status', () => { + expect(getStatusTypeForApplication(Status.PartialSuccess)).toBe( + StatusType.PartialSuccess + ); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/ApplicationUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/ApplicationUtils.tsx index 574cac598e05..caaa95bc4ffa 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/ApplicationUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/ApplicationUtils.tsx @@ -36,6 +36,9 @@ export const getStatusTypeForApplication = (status: Status) => { case Status.Started: return StatusType.Started; + case Status.PartialSuccess: + return StatusType.PartialSuccess; + default: return StatusType.Stopped; }