Dashboards: Unify angular auto-migration code (#63915)

This commit is contained in:
Ryan McKinley
2023-03-27 08:11:45 -07:00
committed by GitHub
parent f948482386
commit 36e8ca7f13
9 changed files with 68 additions and 81 deletions

View File

@@ -85,7 +85,9 @@ it('handles a default datasource in a template variable', async () => {
],
},
};
const dashboardModel = new DashboardModel(dashboard, {}, () => dashboard.templating.list);
const dashboardModel = new DashboardModel(dashboard, undefined, {
getVariablesFromState: () => dashboard.templating.list,
});
const exporter = new DashboardExporter();
const exported: any = await exporter.makeExportable(dashboardModel);
expect(exported.templating.list[0].datasource.uid).toBe('${DS_GFDB}');
@@ -105,7 +107,9 @@ it('If a panel queries has no datasource prop ignore it', async () => {
},
],
};
const dashboardModel = new DashboardModel(dashboard, {}, () => []);
const dashboardModel = new DashboardModel(dashboard, undefined, {
getVariablesFromState: () => [],
});
const exporter = new DashboardExporter();
const exported: any = await exporter.makeExportable(dashboardModel);
expect(exported.panels[0].datasource).toEqual({ uid: '${DS_OTHER}', type: 'other' });
@@ -230,7 +234,13 @@ describe('given dashboard with repeated panels', () => {
info: { version: '1.1.2' },
} as PanelPluginMeta;
dash = new DashboardModel(dash, {}, () => dash.templating.list);
dash = new DashboardModel(
dash,
{},
{
getVariablesFromState: () => dash.templating.list,
}
);
// init library panels
dash.getPanelById(17).initLibraryPanel({