mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-30 11:56:01 +00:00
fix: refresh token no handler attached error (#11234)
* fix: refresh token no handler attached error * fix: explore component tab flicker * fix: revert trySilentSignIn changes * fix: throw error if renew promise not available * fix: add unit tests for glossary version component
This commit is contained in:
parent
4603fbc91c
commit
dfcd7c7029
@ -151,12 +151,12 @@ const Explore: React.FC<ExploreProps> = ({
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
return !loading && searchQueryParam
|
return searchQueryParam
|
||||||
? items.filter((tabItem) => {
|
? items.filter((tabItem) => {
|
||||||
return tabItem.count > 0 || tabItem.key === searchCriteria;
|
return tabItem.count > 0 || tabItem.key === searchCriteria;
|
||||||
})
|
})
|
||||||
: items;
|
: items;
|
||||||
}, [tab, loading, tabsInfo, tabCounts]);
|
}, [tab, tabsInfo, tabCounts]);
|
||||||
|
|
||||||
const activeTabKey = useMemo(() => {
|
const activeTabKey = useMemo(() => {
|
||||||
if (tab) {
|
if (tab) {
|
||||||
@ -423,7 +423,7 @@ const Explore: React.FC<ExploreProps> = ({
|
|||||||
</Row>
|
</Row>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{searchQueryParam && tabItems.length === 0 && (
|
{searchQueryParam && tabItems.length === 0 && !loading && (
|
||||||
<Space
|
<Space
|
||||||
align="center"
|
align="center"
|
||||||
className="w-full h-full flex-center"
|
className="w-full h-full flex-center"
|
||||||
@ -436,6 +436,7 @@ const Explore: React.FC<ExploreProps> = ({
|
|||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
)}
|
)}
|
||||||
|
{searchQueryParam && tabItems.length === 0 && loading && <Loader />}
|
||||||
</PageLayoutV1>
|
</PageLayoutV1>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -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(
|
||||||
|
<MemoryRouter
|
||||||
|
initialEntries={[`/glossary/${glossaryName}/versions/${version}`]}>
|
||||||
|
<Route path="/glossary/:glossaryName/versions/:version">
|
||||||
|
<GlossaryVersion isGlossary />
|
||||||
|
</Route>
|
||||||
|
</MemoryRouter>
|
||||||
|
);
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
});
|
||||||
|
});
|
@ -120,7 +120,6 @@ export const AuthProvider = ({
|
|||||||
>([]);
|
>([]);
|
||||||
|
|
||||||
let silentSignInRetries = 0;
|
let silentSignInRetries = 0;
|
||||||
|
|
||||||
const handleUserCreated = (isUser: boolean) => setIsUserCreated(isUser);
|
const handleUserCreated = (isUser: boolean) => setIsUserCreated(isUser);
|
||||||
|
|
||||||
const onLoginHandler = () => {
|
const onLoginHandler = () => {
|
||||||
@ -254,14 +253,16 @@ export const AuthProvider = ({
|
|||||||
* This method will be called when the id token is about to expire.
|
* This method will be called when the id token is about to expire.
|
||||||
*/
|
*/
|
||||||
const renewIdToken = async () => {
|
const renewIdToken = async () => {
|
||||||
const onRenewIdTokenHandlerPromise = onRenewIdTokenHandler();
|
try {
|
||||||
if (onRenewIdTokenHandlerPromise) {
|
const onRenewIdTokenHandlerPromise = onRenewIdTokenHandler();
|
||||||
await onRenewIdTokenHandlerPromise;
|
onRenewIdTokenHandlerPromise && (await onRenewIdTokenHandlerPromise);
|
||||||
|
} catch (error) {
|
||||||
|
console.error((error as AxiosError).message);
|
||||||
|
|
||||||
return localState.getOidcToken();
|
throw error;
|
||||||
} else {
|
|
||||||
throw new Error('No handler attached for Renew Token.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return localState.getOidcToken();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user