chore(homepage): separate out api calls to make homepage load more dynamically (#13500)

* separate out api calls

* add new loading states

* remove consoles

* update tests

* fix types and lint

* make code more robust and add test

* address comments

* address comments

* fix lint
This commit is contained in:
Phillip Kelley-Dotson
2021-03-22 15:10:42 -07:00
committed by GitHub
parent 54b2bda2b0
commit bbc306c64f
10 changed files with 284 additions and 163 deletions

View File

@@ -67,7 +67,10 @@ fetchMock.get(savedQueryEndpoint, {
result: [],
});
fetchMock.get(recentActivityEndpoint, {});
fetchMock.get(recentActivityEndpoint, {
Created: [],
Viewed: [],
});
fetchMock.get(chartInfoEndpoint, {
permissions: [],
@@ -122,10 +125,14 @@ describe('Welcome', () => {
expect(wrapper.find('CollapsePanel')).toHaveLength(8);
});
it('calls batch method on page load', () => {
it('calls api methods in parallel on page load', () => {
const chartCall = fetchMock.calls(/chart\/\?q/);
const savedQueryCall = fetchMock.calls(/saved_query\/\?q/);
const recentCall = fetchMock.calls(/superset\/recent_activity\/*/);
const dashboardCall = fetchMock.calls(/dashboard\/\?q/);
expect(chartCall).toHaveLength(2);
expect(dashboardCall).toHaveLength(2);
expect(chartCall).toHaveLength(1);
expect(recentCall).toHaveLength(1);
expect(savedQueryCall).toHaveLength(1);
expect(dashboardCall).toHaveLength(1);
});
});