Dashboard: Fix loading custom home dashboard (#25447)

* Dashboard: Fix loading custom home dashboard

* Updated and added test
This commit is contained in:
Torkel Ödegaard 2020-06-08 17:15:56 +02:00 committed by GitHub
parent c53435f7a7
commit 8474794aaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -201,7 +201,6 @@ describeInitScenario('Initializing home dashboard', ctx => {
ctx.setup(() => {
ctx.args.routeInfo = DashboardRouteInfo.Home;
ctx.backendSrv.get.mockResolvedValue({
meta: {},
redirectUri: '/u/123/my-home',
});
});
@ -212,6 +211,17 @@ describeInitScenario('Initializing home dashboard', ctx => {
});
});
describeInitScenario('Initializing home dashboard cancelled', ctx => {
ctx.setup(() => {
ctx.args.routeInfo = DashboardRouteInfo.Home;
ctx.backendSrv.get.mockResolvedValue([]);
});
it('Should abort init process', () => {
expect(ctx.actions.length).toBe(1);
});
});
describeInitScenario('Initializing existing dashboard', ctx => {
const mockQueries = [
{

View File

@ -69,7 +69,7 @@ async function fetchDashboard(
const dashDTO: DashboardDTO = await backendSrv.get('/api/dashboards/home');
// if above all is cancelled it will return an array
if (!dashDTO.meta) {
if (Array.isArray(dashDTO)) {
return null;
}