diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/Explore.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Explore/Explore.component.tsx index 7219793445e..1aba5714372 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/Explore.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/Explore.component.tsx @@ -151,12 +151,12 @@ const Explore: React.FC = ({ }) ); - return !loading && searchQueryParam + return searchQueryParam ? items.filter((tabItem) => { return tabItem.count > 0 || tabItem.key === searchCriteria; }) : items; - }, [tab, loading, tabsInfo, tabCounts]); + }, [tab, tabsInfo, tabCounts]); const activeTabKey = useMemo(() => { if (tab) { @@ -423,7 +423,7 @@ const Explore: React.FC = ({ )} - {searchQueryParam && tabItems.length === 0 && ( + {searchQueryParam && tabItems.length === 0 && !loading && ( = ({ /> )} + {searchQueryParam && tabItems.length === 0 && loading && } ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/GlossaryVersion/GlossaryVersion.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryVersion/GlossaryVersion.test.tsx new file mode 100644 index 00000000000..2e48fd2e0c7 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/components/GlossaryVersion/GlossaryVersion.test.tsx @@ -0,0 +1,92 @@ +/* + * Copyright 2023 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 { render, screen } from '@testing-library/react'; +import React from 'react'; +import { MemoryRouter, Route } from 'react-router-dom'; +import GlossaryVersion from './GlossaryVersion.component'; + +/* eslint-disable max-len */ +const MOCK_VERSIONS_LIST = { + entityType: 'glossary', + versions: [ + '{"id":"305b0130-b9c1-4441-a0fc-6463fd019540","name":"Business_Glossary","fullyQualifiedName":"Business_Glossary","displayName":"Business Glossary","description":"Business Glossary","version":0.1,"updatedAt":1681762798036,"updatedBy":"suresh","reviewers":[],"owner":{"id":"eeca9594-abd5-4dde-bc38-8b411e821087","type":"user","name":"suresh","fullyQualifiedName":"suresh","displayName":"Suresh Srinivas","deleted":false},"tags":[],"deleted":false,"provider":"user","mutuallyExclusive":false}', + ], +}; + +const MOCK_VERSION = { + id: '305b0130-b9c1-4441-a0fc-6463fd019540', + name: 'Business_Glossary', + fullyQualifiedName: 'Business_Glossary', + displayName: 'Business Glossary', + description: 'Business Glossary', + version: 0.1, + updatedAt: 1681762798036, + updatedBy: 'suresh', + reviewers: [], + owner: { + id: 'eeca9594-abd5-4dde-bc38-8b411e821087', + type: 'user', + name: 'suresh', + fullyQualifiedName: 'suresh', + displayName: 'Suresh Srinivas', + deleted: false, + }, + tags: [], + deleted: false, + provider: 'user', + mutuallyExclusive: false, +}; + +jest.mock('rest/glossaryAPI', () => ({ + getGlossaryVersionsList: jest + .fn() + .mockImplementation(() => Promise.resolve(MOCK_VERSIONS_LIST)), + getGlossaryVersion: jest + .fn() + .mockImplementation(() => Promise.resolve(MOCK_VERSION)), +})); + +jest.mock('components/Glossary/GlossaryV1.component', () => { + return jest.fn().mockReturnValue(<>Glossary component); +}); + +describe('GlossaryVersion', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('renders glossary version', async () => { + const glossaryName = '305b0130-b9c1-4441-a0fc-6463fd019540'; + const version = '0.1'; + + render( + + + + + + ); + + // Check that the version data is displayed + expect(await screen.findByText('Glossary component')).toBeInTheDocument(); + + // Check that the version timeline is displayed + expect( + screen.getByText('label.version-plural-history') + ).toBeInTheDocument(); + + // check active version visible + expect(screen.getByText('v0.1')).toBeInTheDocument(); + }); +}); 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 0468979bacf..08558c10cb8 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 @@ -120,7 +120,6 @@ export const AuthProvider = ({ >([]); let silentSignInRetries = 0; - const handleUserCreated = (isUser: boolean) => setIsUserCreated(isUser); const onLoginHandler = () => { @@ -254,14 +253,16 @@ export const AuthProvider = ({ * This method will be called when the id token is about to expire. */ const renewIdToken = async () => { - const onRenewIdTokenHandlerPromise = onRenewIdTokenHandler(); - if (onRenewIdTokenHandlerPromise) { - await onRenewIdTokenHandlerPromise; + try { + const onRenewIdTokenHandlerPromise = onRenewIdTokenHandler(); + onRenewIdTokenHandlerPromise && (await onRenewIdTokenHandlerPromise); + } catch (error) { + console.error((error as AxiosError).message); - return localState.getOidcToken(); - } else { - throw new Error('No handler attached for Renew Token.'); + throw error; } + + return localState.getOidcToken(); }; /**