Commit 8474794a by Torkel Ödegaard Committed by GitHub

Dashboard: Fix loading custom home dashboard (#25447)

* Dashboard: Fix loading custom home dashboard

* Updated and added test
parent c53435f7
......@@ -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 = [
{
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment