chore(Home): Avoid firing API requests when a custom Home is used (#29493)

This commit is contained in:
Vitor Avila 2024-07-05 16:57:25 -03:00 committed by GitHub
parent 6d2b3b8698
commit 0f60701995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View File

@ -228,3 +228,28 @@ test('Should render a submenu extension component if one is supplied', async ()
expect(screen.getByText('submenu extension')).toBeInTheDocument();
});
test('Should not make data fetch calls if `welcome.main.replacement` is defined', async () => {
const extensionsRegistry = getExtensionsRegistry();
// Clean up
extensionsRegistry.set('welcome.banner', () => null);
// Set up
extensionsRegistry.set('welcome.main.replacement', () => (
<>welcome.main.replacement extension component</>
));
setupExtensions();
await renderWelcome();
expect(
screen.getByText('welcome.main.replacement extension component'),
).toBeInTheDocument();
expect(fetchMock.calls(chartsEndpoint)).toHaveLength(0);
expect(fetchMock.calls(dashboardsEndpoint)).toHaveLength(0);
expect(fetchMock.calls(recentActivityEndpoint)).toHaveLength(0);
expect(fetchMock.calls(savedQueryEndpoint)).toHaveLength(0);
});

View File

@ -218,7 +218,7 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
}, []);
useEffect(() => {
if (!otherTabFilters) {
if (!otherTabFilters || WelcomeMainExtension) {
return;
}
const activeTab = getItem(LocalStorageKeys.HomepageActivityFilter, null);