diff --git a/openmetadata-ui/src/main/resources/ui/.eslintrc.yaml b/openmetadata-ui/src/main/resources/ui/.eslintrc.yaml index b29f9821f68..69daa657571 100644 --- a/openmetadata-ui/src/main/resources/ui/.eslintrc.yaml +++ b/openmetadata-ui/src/main/resources/ui/.eslintrc.yaml @@ -55,6 +55,8 @@ rules: - error - smart + no-console: 2 + # Require a whitespace at the beginning of a comment spaced-comment: - error diff --git a/openmetadata-ui/src/main/resources/ui/.prettierrc.yaml b/openmetadata-ui/src/main/resources/ui/.prettierrc.yaml index dc3b29f71e8..513ac9f45f7 100644 --- a/openmetadata-ui/src/main/resources/ui/.prettierrc.yaml +++ b/openmetadata-ui/src/main/resources/ui/.prettierrc.yaml @@ -15,4 +15,3 @@ tabWidth: 2 jsxBracketSameLine: true htmlWhitespaceSensitivity: 'strict' singleQuote: true -endOfLine: 'auto' diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.component.tsx deleted file mode 100644 index 2671acdccc2..00000000000 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.component.tsx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2022 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 { useForm } from 'antd/lib/form/Form'; -import AddGlossaryTermForm from 'components/AddGlossaryTermForm/AddGlossaryTermForm.component'; -import { t } from 'i18next'; -import React from 'react'; -import { PageLayoutType } from '../../enums/layout.enum'; -import TitleBreadcrumb from '../common/title-breadcrumb/title-breadcrumb.component'; -import PageLayout from '../containers/PageLayout'; -import { AddGlossaryTermProps } from './AddGlossaryTerm.interface'; - -const AddGlossaryTerm = ({ - glossaryData, - onCancel, - slashedBreadcrumb, - isLoading, -}: AddGlossaryTermProps) => { - const fetchRightPanel = () => { - return ( - <> -
- {t('label.configure-entity', { - entity: t('label.glossary-term'), - })} -
-
- {t('message.configure-glossary-term-description')} -
- - ); - }; - const [form] = useForm(); - - return ( - } - layout={PageLayoutType['2ColRTL']} - pageTitle={t('label.add-entity', { entity: t('label.glossary-term') })} - rightPanel={fetchRightPanel()}> -
-
- {t('label.add-entity', { - entity: t('label.glossary-term'), - })} -
- console.debug(data)} - /> -
-
- ); -}; - -export default AddGlossaryTerm; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.interface.ts deleted file mode 100644 index 9ff28e25052..00000000000 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.interface.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2022 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 { CreateGlossaryTerm } from '../../generated/api/data/createGlossaryTerm'; -import { Glossary } from '../../generated/entity/data/glossary'; -import { GlossaryTerm } from '../../generated/entity/data/glossaryTerm'; -import { TitleBreadcrumbProps } from '../common/title-breadcrumb/title-breadcrumb.interface'; - -export interface AddGlossaryTermProps { - parentGlossaryData: GlossaryTerm | undefined; - glossaryData: Glossary; - isLoading: boolean; - onSave: (value: CreateGlossaryTerm) => void; - onCancel: () => void; - slashedBreadcrumb: TitleBreadcrumbProps['titleLinks']; -} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.test.tsx deleted file mode 100644 index 1a99611b509..00000000000 --- a/openmetadata-ui/src/main/resources/ui/src/components/AddGlossaryTerm/AddGlossaryTerm.test.tsx +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2022 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 { fireEvent, getByTestId, render } from '@testing-library/react'; -import React, { forwardRef } from 'react'; -import { - mockedGlossaries, - mockedGlossaryTerms, -} from '../../mocks/Glossary.mock'; -import AddGlossaryTerm from './AddGlossaryTerm.component'; - -jest.mock('rest/glossaryAPI', () => ({ - addGlossaries: jest.fn().mockImplementation(() => Promise.resolve()), -})); - -jest.mock('../common/rich-text-editor/RichTextEditorPreviewer', () => { - return jest.fn().mockReturnValue(

RichTextEditorPreviewer

); -}); - -jest.mock('../common/rich-text-editor/RichTextEditorPreviewer', () => { - return forwardRef( - jest.fn().mockImplementation(({ initialValue }, ref) => { - return
{initialValue}RichTextEditorPreviewer
; - }) - ); -}); - -jest.mock('../common/rich-text-editor/RichTextEditor', () => { - return forwardRef( - jest.fn().mockImplementation(({ initialValue }) => { - return ( -
{ - return { - getEditorContent: input, - }; - }}> - {initialValue}RichTextEditor -
- ); - }) - ); -}); - -jest.mock('../containers/PageLayout', () => - jest.fn().mockImplementation(({ children }) =>
{children}
) -); - -const mockOnCancel = jest.fn(); -const mockOnSave = jest.fn(); - -const mockProps = { - allowAccess: true, - glossaryData: mockedGlossaries[0], - parentGlossaryData: mockedGlossaryTerms[0], - isLoading: false, - onCancel: mockOnCancel, - onSave: mockOnSave, - slashedBreadcrumb: [], -}; - -describe('Test AddGlossaryTerm component', () => { - it('AddGlossaryTerm component should render', async () => { - const { container } = render(); - - const addGlossaryTermForm = getByTestId(container, 'add-glossary-term'); - - expect(addGlossaryTermForm).toBeInTheDocument(); - }); - - it('should be able to cancel', () => { - const { container } = render(); - - const cancelButton = getByTestId(container, 'cancel-glossary-term'); - - expect(cancelButton).toBeInTheDocument(); - - fireEvent.click( - cancelButton, - new MouseEvent('click', { - bubbles: true, - cancelable: true, - }) - ); - - expect(mockOnCancel).toHaveBeenCalled(); - }); -}); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.tsx index ca5a6f1d263..8afc027682f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Assets/AssetsSelectionModal/AssetSelectionModal.tsx @@ -72,8 +72,8 @@ export const AssetSelectionModal = ({ setTotalCount(res.hits.total.value ?? 0); setItems(page === 1 ? hits : (prevItems) => [...prevItems, ...hits]); setPageNumber(page); - } catch (error) { - console.error(error); + } catch (_) { + // Nothing here } finally { setIsLoading(false); } @@ -166,8 +166,8 @@ export const AssetSelectionModal = ({ await Promise.all(patchAPIPromises); onSave && onSave(); onCancel(); - } catch (error) { - console.error(error); + } catch (_) { + // Nothing here } finally { setIsLoading(false); } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/GlossaryTermReferencesModal.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/GlossaryTermReferencesModal.component.tsx index 66e209d5529..32232be9b4e 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/GlossaryTermReferencesModal.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/GlossaryTermReferencesModal.component.tsx @@ -37,8 +37,8 @@ const GlossaryTermReferencesModal = ({ try { await form.validateFields(); onSave(obj.references); - } catch (error) { - console.log(error); + } catch (_) { + // Nothing here } }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/tabs/AssetsTabs.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/tabs/AssetsTabs.component.tsx index 22fdd104553..0ff6fe4dba1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/tabs/AssetsTabs.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryTerms/tabs/AssetsTabs.component.tsx @@ -181,8 +181,8 @@ const AssetsTabs = forwardRef( // Select first card to show summary right panel hits[0] && setSelectedCard(hits[0]._source as SourceType); - } catch (error) { - console.error(error); + } catch (_) { + // Nothing here } }, [activeFilter, currentPage] diff --git a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryVersion/GlossaryVersion.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryVersion/GlossaryVersion.component.tsx index c7a6d3a38c6..cdc6e702fca 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryVersion/GlossaryVersion.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryVersion/GlossaryVersion.component.tsx @@ -18,7 +18,7 @@ import { LOADING_STATE } from 'enums/common.enum'; import { Glossary } from 'generated/entity/data/glossary'; import { GlossaryTerm } from 'generated/entity/data/glossaryTerm'; import { EntityHistory } from 'generated/type/entityHistory'; -import { mockFn, mockFnGlossary } from 'mocks/Glossary.mock'; +import { noop } from 'lodash'; import React, { useEffect, useState } from 'react'; import { useHistory, useParams } from 'react-router-dom'; import { @@ -91,16 +91,17 @@ const GlossaryVersion = ({ isGlossary = false }: GlossaryVersionProps) => { return (
+ {/* TODO: Need to implement version component for Glossary */} Promise.resolve()} + onGlossaryDelete={noop} + onGlossaryTermDelete={noop} + onGlossaryTermUpdate={() => Promise.resolve()} />
= ({ try { await form.validateFields(); onSave(obj); - } catch (error) { - console.log(error); + } catch (_) { + // Nothing here } }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/app-bar/Appbar.tsx b/openmetadata-ui/src/main/resources/ui/src/components/app-bar/Appbar.tsx index 0efe8993116..93f18a67661 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/app-bar/Appbar.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/app-bar/Appbar.tsx @@ -90,8 +90,6 @@ const Appbar: React.FC = (): JSX.Element => { }; const handleSearchChange = (value: string) => { - console.debug(`handleSearchChange value=${value}`); - setSearchValue(value); value ? setIsOpen(true) : setIsOpen(false); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/authentication/auth-provider/AuthProvider.tsx b/openmetadata-ui/src/main/resources/ui/src/components/authentication/auth-provider/AuthProvider.tsx index 08558c10cb8..31032617eba 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/authentication/auth-provider/AuthProvider.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/authentication/auth-provider/AuthProvider.tsx @@ -257,7 +257,11 @@ export const AuthProvider = ({ const onRenewIdTokenHandlerPromise = onRenewIdTokenHandler(); onRenewIdTokenHandlerPromise && (await onRenewIdTokenHandlerPromise); } catch (error) { - console.error((error as AxiosError).message); + // eslint-disable-next-line no-console + console.error( + `Error while refreshing token: `, + (error as AxiosError).message + ); throw error; } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TierCard/TierCard.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/TierCard/TierCard.test.tsx index 7289d96d95c..66c8b1308c5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TierCard/TierCard.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TierCard/TierCard.test.tsx @@ -11,14 +11,7 @@ * limitations under the License. */ -import { - act, - findAllByText, - findByTestId, - fireEvent, - getByText, - render, -} from '@testing-library/react'; +import { findByTestId, render } from '@testing-library/react'; import React from 'react'; import TierCard from './TierCard'; @@ -39,7 +32,9 @@ const mockTierData = [ ]; jest.mock('rest/tagAPI', () => ({ - getTags: jest.fn().mockResolvedValue({ data: mockTierData }), + getTags: jest + .fn() + .mockImplementation(() => Promise.resolve({ data: mockTierData })), })); jest.mock('../../cardlist/CardListItem/CardWithListItem', () => ({ @@ -60,32 +55,15 @@ jest.mock('antd', () => ({ Popover: jest .fn() - .mockImplementation(({ children }) => ( -
{children}
+ .mockImplementation(({ content }) => ( +
{content}
)), })); const MockOnUpdate = jest.fn(); const MockOnRemove = jest.fn(); -describe.skip('Test TierCard Component', () => { - it('Component should render', async () => { - const { container } = render( - - - - ); - - act(() => { - fireEvent.click(getByText(container, 'test')); - }); - - expect(await findAllByText(container, 'CardListItem')).toBeInTheDocument(); - }); - +describe('Test TierCard Component', () => { it('Component should have card', async () => { const { container } = render( { expect(await findByTestId(container, 'cards')).toBeInTheDocument(); }); - - it('Card should have Clear button if item selected', async () => { - const { container } = render( - - ); - - expect(await findByTestId(container, 'remove-tier')).toBeInTheDocument(); - }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/UserSelectableList/UserSelectableList.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/UserSelectableList/UserSelectableList.component.tsx index d9cd495e3dd..632c6578c35 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/UserSelectableList/UserSelectableList.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/UserSelectableList/UserSelectableList.component.tsx @@ -81,8 +81,6 @@ export const UserSelectableList = ({ return { data: filterData, paging }; } catch (error) { - console.error(error); - return { data: [], paging: { total: 0 } }; } } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/UserTeamSelectableList/UserTeamSelectableList.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/UserTeamSelectableList/UserTeamSelectableList.component.tsx index 469d770d65d..29c6ecfcc6f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/UserTeamSelectableList/UserTeamSelectableList.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/UserTeamSelectableList/UserTeamSelectableList.component.tsx @@ -91,8 +91,6 @@ export const UserTeamSelectableList = ({ return { data: filterData, paging }; } catch (error) { - console.error(error); - return { data: [], paging: { total: 0 } }; } } @@ -160,8 +158,6 @@ export const UserTeamSelectableList = ({ }, }; } catch (error) { - console.error(error); - return { data: [], paging: { total: 0 } }; } } diff --git a/openmetadata-ui/src/main/resources/ui/src/mocks/Glossary.mock.ts b/openmetadata-ui/src/main/resources/ui/src/mocks/Glossary.mock.ts index 2a10f884041..43208845b74 100644 --- a/openmetadata-ui/src/main/resources/ui/src/mocks/Glossary.mock.ts +++ b/openmetadata-ui/src/main/resources/ui/src/mocks/Glossary.mock.ts @@ -12,7 +12,6 @@ */ import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; -import { Glossary } from 'generated/entity/data/glossary'; import { Status } from '../generated/entity/data/glossaryTerm'; export const mockedAssetData = { @@ -21,14 +20,6 @@ export const mockedAssetData = { total: 0, }; -export const mockFnGlossary = async (value: Glossary) => { - console.debug('On back', value); -}; - -export const mockFn = () => { - console.debug('mock fn'); -}; - export const mockedGlossaryTerms = [ { id: 'a5a97523-2229-41e5-abbe-65f61a534c34', diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossaryTermPage/AddGlossaryTermPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossaryTermPage/AddGlossaryTermPage.component.tsx deleted file mode 100644 index 1877db7c241..00000000000 --- a/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossaryTermPage/AddGlossaryTermPage.component.tsx +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2022 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 { AxiosError } from 'axios'; -import AddGlossaryTerm from 'components/AddGlossaryTerm/AddGlossaryTerm.component'; -import { TitleBreadcrumbProps } from 'components/common/title-breadcrumb/title-breadcrumb.interface'; -import PageContainerV1 from 'components/containers/PageContainerV1'; -import Loader from 'components/Loader/Loader'; -import { ERROR_MESSAGE } from 'constants/constants'; -import { CreateGlossaryTerm } from 'generated/api/data/createGlossaryTerm'; -import { cloneDeep, get, isUndefined } from 'lodash'; -import React, { useEffect, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { useHistory, useParams } from 'react-router-dom'; -import { - addGlossaryTerm, - getGlossariesByName, - getGlossaryTermByFQN, -} from 'rest/glossaryAPI'; -import { getIsErrorMatch } from 'utils/CommonUtils'; -import { Glossary } from '../../generated/entity/data/glossary'; -import { GlossaryTerm } from '../../generated/entity/data/glossaryTerm'; -import { getGlossaryPath } from '../../utils/RouterUtils'; -import { showErrorToast } from '../../utils/ToastUtils'; - -const AddGlossaryTermPage = () => { - const { glossaryName, glossaryTermsFQN } = - useParams<{ [key: string]: string }>(); - const { t } = useTranslation(); - const history = useHistory(); - const [isDataLoading, setIsDataLoading] = useState(true); - const [isLoading, setIsLoading] = useState(false); - const [glossaryData, setGlossaryData] = useState(); - const [slashedBreadcrumb, setSlashedBreadcrumb] = useState< - TitleBreadcrumbProps['titleLinks'] - >([]); - - const [parentGlossaryData, setParentGlossaryData] = useState(); - - const handleCancel = () => { - history.goBack(); - }; - - const handleSaveFailure = ( - error: AxiosError | string, - fallbackText?: string - ) => { - showErrorToast(error, fallbackText); - }; - - const onSave = async (data: CreateGlossaryTerm) => { - setIsLoading(true); - try { - await addGlossaryTerm(data); - history.goBack(); - } catch (error) { - handleSaveFailure( - getIsErrorMatch(error as AxiosError, ERROR_MESSAGE.alreadyExist) - ? t('server.entity-already-exist', { - entity: t('label.glossary-term'), - name: data.name, - }) - : (error as AxiosError), - t('server.add-entity-error', { entity: t('label.glossary-term') }) - ); - } finally { - setIsLoading(false); - } - }; - - const fetchGlossaryData = async () => { - try { - const res = await getGlossariesByName(glossaryName, [ - 'tags', - 'owner', - 'reviewers', - ]); - setGlossaryData(res); - } catch (err) { - showErrorToast( - err as AxiosError, - t('server.entity-fetch-error', { - entity: t('label.glossary'), - }) - ); - } finally { - setIsDataLoading(false); - } - }; - - const fetchGlossaryTermsByName = (name: string) => { - getGlossaryTermByFQN(name, [ - 'children', - 'relatedTerms', - 'reviewers', - 'tags', - ]) - .then((res) => { - if (res) { - setParentGlossaryData(res); - } else { - setParentGlossaryData(undefined); - showErrorToast( - t('server.entity-fetch-error', { - entity: t('label.glossary-term'), - }) - ); - } - }) - .catch((err: AxiosError) => { - setParentGlossaryData(undefined); - const errMsg = get(err, 'response.data.message', ''); - showErrorToast( - errMsg || - t('server.entity-fetch-error', { - entity: t('label.glossary-term'), - }) - ); - }); - }; - - useEffect(() => { - fetchGlossaryData(); - }, [glossaryName]); - - useEffect(() => { - if (glossaryTermsFQN) { - fetchGlossaryTermsByName(glossaryTermsFQN); - } - }, [glossaryTermsFQN]); - - useEffect(() => { - let breadcrumb = []; - - if (isUndefined(glossaryTermsFQN)) { - breadcrumb.push({ - name: glossaryName, - url: getGlossaryPath(glossaryName), - }); - } else { - breadcrumb = glossaryTermsFQN.split('.').map((fqn, i, arr) => { - const cloneArr = cloneDeep(arr); - if (i === 0) { - return { - name: glossaryName, - url: getGlossaryPath(glossaryName), - }; - } - - return { - name: fqn, - url: getGlossaryPath(cloneArr.splice(0, i + 1).join('.')), - }; - }); - } - - setSlashedBreadcrumb([ - { - name: t('label.glossary'), - url: getGlossaryPath(), - }, - ...breadcrumb, - { - name: t('label.add-entity', { entity: t('label.glossary-term') }), - url: '', - activeTitle: true, - }, - ]); - }, [glossaryTermsFQN, glossaryName]); - - return ( - - {isDataLoading ? ( - - ) : ( -
- -
- )} -
- ); -}; - -export default AddGlossaryTermPage; diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossaryTermPage/AddGlossaryTermPage.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossaryTermPage/AddGlossaryTermPage.test.tsx deleted file mode 100644 index 355409402a3..00000000000 --- a/openmetadata-ui/src/main/resources/ui/src/pages/AddGlossaryTermPage/AddGlossaryTermPage.test.tsx +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2022 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 { findByText, fireEvent, render } from '@testing-library/react'; -import React from 'react'; -import { getGlossaryPath } from '../../utils/RouterUtils'; -import AddGlossaryTermPage from './AddGlossaryTermPage.component'; - -const mockRedirect = jest.fn((fqn) => fqn); - -jest.mock('react-router', () => ({ - ...jest.requireActual('react-router'), - useHistory: () => ({ - push: jest.fn(), - goBack: jest.fn(), - }), - useParams: jest.fn().mockImplementation(() => ({ - glossaryName: 'GlossaryName', - glossaryTermsFQN: '', - })), -})); - -jest.mock('components/AddGlossaryTerm/AddGlossaryTerm.component', () => { - return jest.fn().mockImplementation(({ onCancel, onSave }) => ( -
- AddGlossaryTerm.component -
- )); -}); - -jest.mock('../../utils/RouterUtils', () => ({ - getGlossaryPath: jest.fn(), -})); - -jest.mock('rest/glossaryAPI', () => ({ - addGlossaryTerm: jest.fn().mockImplementation(() => Promise.resolve()), - getGlossariesByName: jest.fn().mockImplementation(() => Promise.resolve()), - getGlossaryTermByFQN: jest.fn().mockImplementation(() => Promise.resolve()), -})); - -describe('Test AddGlossaryTerm component page', () => { - it('AddGlossaryTerm component page should render', async () => { - const { container } = render(); - - const addGlossaryTerm = await findByText( - container, - /AddGlossaryTerm.component/i - ); - - expect(addGlossaryTerm).toBeInTheDocument(); - }); - - it('Redirect to Glossary on cancel', async () => { - (getGlossaryPath as jest.Mock).mockImplementationOnce(mockRedirect); - const { findByTestId } = render(); - - const addGlossaryTerm = await findByTestId('add-glossary-term'); - - fireEvent.click( - addGlossaryTerm, - new MouseEvent('click', { bubbles: true, cancelable: true }) - ); - - expect(mockRedirect).toHaveBeenCalledWith('GlossaryName'); - }); -}); diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.test.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.test.tsx index 3d32326c536..7320f0b6f8c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/DatasetDetailsPage/DatasetDetailsPage.test.tsx @@ -403,9 +403,6 @@ describe('Test DatasetDetails page', () => { 'entityLineageHandler' ); - console.log('path here'); - screen.debug(container); - expect(container).toBeInTheDocument(); expect(versionButton).toBeInTheDocument(); expect(followButton).toBeInTheDocument();