AzureMonitor: Fix filter query for empty queryType (#60252)

This commit is contained in:
Andres Martinez Gotor
2022-12-14 09:54:19 +01:00
committed by GitHub
parent 6d8bf5ac01
commit b4e76e75b1
2 changed files with 14 additions and 1 deletions

View File

@@ -34,4 +34,17 @@ describe('Azure Monitor Datasource', () => {
);
});
});
it('should not filter a valid query', () => {
const ds = new Datasource(createMockInstanceSetttings());
const query = createMockQuery();
expect(ds.filterQuery(query)).toBe(true);
});
it('should filter out a query with no query type', () => {
const ds = new Datasource(createMockInstanceSetttings());
const query = createMockQuery();
delete query.queryType;
expect(ds.filterQuery(query)).toBe(false);
});
});

View File

@@ -59,7 +59,7 @@ export default class Datasource extends DataSourceWithBackend<AzureMonitorQuery,
filterQuery(item: AzureMonitorQuery): boolean {
if (!item.queryType) {
return true;
return false;
}
const ds = this.pseudoDatasource[item.queryType];
return ds?.filterQuery?.(item) ?? true;