Skip to content

Commit

Permalink
chore(Home): Avoid firing API requests when a custom Home is used (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitor-Avila committed Jul 5, 2024
1 parent 6d2b3b8 commit 0f60701
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions superset-frontend/src/pages/Home/Home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
2 changes: 1 addition & 1 deletion superset-frontend/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
}, []);

useEffect(() => {
if (!otherTabFilters) {
if (!otherTabFilters || WelcomeMainExtension) {
return;
}
const activeTab = getItem(LocalStorageKeys.HomepageActivityFilter, null);
Expand Down

0 comments on commit 0f60701

Please sign in to comment.