Skip to content

Commit c480954

Browse files
committed
Added beta tag on header component (#27535)
* Added beta tag on header component * Added unit test for badge (cherry picked from commit 491b082)
1 parent cac588b commit c480954

3 files changed

Lines changed: 103 additions & 8 deletions

File tree

openmetadata-ui/src/main/resources/ui/src/constants/LeftSidebar.constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ export const SIDEBAR_LIST: Array<LeftSidebarItem> = [
175175
redirect_url: ROUTES.ONTOLOGY_EXPLORER,
176176
icon: LineageIcon,
177177
dataTestId: `app-bar-item-${SidebarItem.ONTOLOGY_EXPLORER}`,
178-
isBeta: true,
179178
},
180179
{
181180
key: ROUTES.TAGS,
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright 2024 Collate.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
import { render, screen } from '@testing-library/react';
14+
import React from 'react';
15+
import OntologyExplorerPage from './OntologyExplorerPage';
16+
17+
const mockOntologyExplorer = jest.fn();
18+
19+
jest.mock('@openmetadata/ui-core-components', () => ({
20+
Badge: jest
21+
.fn()
22+
.mockImplementation(({ children, 'data-testid': testId }) => (
23+
<span data-testid={testId}>{children}</span>
24+
)),
25+
Card: jest
26+
.fn()
27+
.mockImplementation(({ children }: { children: React.ReactNode }) => (
28+
<div>{children}</div>
29+
)),
30+
Divider: jest.fn().mockImplementation(() => <hr />),
31+
Skeleton: jest.fn().mockImplementation(() => <div data-testid="skeleton" />),
32+
Typography: jest
33+
.fn()
34+
.mockImplementation(
35+
({
36+
children,
37+
'data-testid': testId,
38+
}: {
39+
children: React.ReactNode;
40+
'data-testid'?: string;
41+
}) => <span data-testid={testId}>{children}</span>
42+
),
43+
}));
44+
45+
jest.mock('@untitledui/icons', () => ({
46+
Home02: () => <div>Home02</div>,
47+
}));
48+
49+
jest.mock('../../components/PageLayoutV1/PageLayoutV1', () => ({
50+
__esModule: true,
51+
default: jest.fn(({ children }: { children: React.ReactNode }) => (
52+
<div>{children}</div>
53+
)),
54+
}));
55+
56+
jest.mock(
57+
'../../components/common/TitleBreadcrumb/TitleBreadcrumb.component',
58+
() => ({
59+
__esModule: true,
60+
default: jest.fn(() => <div data-testid="breadcrumb" />),
61+
})
62+
);
63+
64+
jest.mock('../../components/OntologyExplorer', () => ({
65+
OntologyExplorer: jest.fn((props) => {
66+
mockOntologyExplorer(props);
67+
68+
return <div data-testid="ontology-explorer" />;
69+
}),
70+
}));
71+
72+
describe('OntologyExplorerPage', () => {
73+
beforeEach(() => {
74+
jest.clearAllMocks();
75+
});
76+
77+
it('renders heading with beta badge and all page elements', () => {
78+
render(<OntologyExplorerPage />);
79+
80+
expect(screen.getByTestId('heading')).toBeInTheDocument();
81+
expect(screen.getByTestId('beta-badge')).toBeInTheDocument();
82+
expect(screen.getByTestId('beta-badge')).toHaveTextContent('label.beta');
83+
expect(screen.getByTestId('breadcrumb')).toBeInTheDocument();
84+
expect(screen.getByTestId('ontology-explorer')).toBeInTheDocument();
85+
});
86+
});

openmetadata-ui/src/main/resources/ui/src/pages/OntologyExplorerPage/OntologyExplorerPage.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
import {
15+
Badge,
1516
Card,
1617
Divider,
1718
Skeleton,
@@ -57,13 +58,22 @@ const OntologyExplorerPage: React.FC = () => {
5758
/>
5859

5960
<Card className="tw:p-5">
60-
<Typography
61-
as="span"
62-
data-testid="heading"
63-
size="text-md"
64-
weight="semibold">
65-
{t('label.ontology-explorer')}
66-
</Typography>
61+
<div className="tw:flex tw:items-center tw:gap-2">
62+
<Typography
63+
as="span"
64+
data-testid="heading"
65+
size="text-md"
66+
weight="semibold">
67+
{t('label.ontology-explorer')}
68+
</Typography>
69+
<Badge
70+
color="blue-light"
71+
data-testid="beta-badge"
72+
size="sm"
73+
type="pill-color">
74+
{t('label.beta')}
75+
</Badge>
76+
</div>
6777
<div
6878
className="tw:mt-1 tw:flex tw:flex-wrap tw:items-center tw:gap-2"
6979
data-testid="ontology-explorer-stats">

0 commit comments

Comments
 (0)