mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: handle the case where refresh_intervals
could be null (#35511)
* handle the case where refresh_intervals === null + add unit test * have a clean _dashboard for each test * modify check to see if refresh_intervals is an array
This commit is contained in:
parent
7109285ac9
commit
60f79a3548
@ -11,17 +11,17 @@ jest.mock('app/core/core', () => ({
|
|||||||
|
|
||||||
describe('timeSrv', () => {
|
describe('timeSrv', () => {
|
||||||
let timeSrv: TimeSrv;
|
let timeSrv: TimeSrv;
|
||||||
|
let _dashboard: any;
|
||||||
const _dashboard: any = {
|
|
||||||
time: { from: 'now-6h', to: 'now' },
|
|
||||||
getTimezone: jest.fn(() => 'browser'),
|
|
||||||
timeRangeUpdated: jest.fn(() => {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
_dashboard = {
|
||||||
|
time: { from: 'now-6h', to: 'now' },
|
||||||
|
getTimezone: jest.fn(() => 'browser'),
|
||||||
|
refresh: false,
|
||||||
|
timeRangeUpdated: jest.fn(() => {}),
|
||||||
|
};
|
||||||
timeSrv = new TimeSrv(new ContextSrvStub() as any);
|
timeSrv = new TimeSrv(new ContextSrvStub() as any);
|
||||||
timeSrv.init(_dashboard);
|
timeSrv.init(_dashboard);
|
||||||
_dashboard.refresh = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('timeRange', () => {
|
describe('timeRange', () => {
|
||||||
@ -130,6 +130,17 @@ describe('timeSrv', () => {
|
|||||||
expect(timeSrv.time.to).toEqual('now');
|
expect(timeSrv.time.to).toEqual('now');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle refresh_intervals=null when refresh is enabled', () => {
|
||||||
|
locationService.push('/d/id?refresh=30s');
|
||||||
|
|
||||||
|
timeSrv = new TimeSrv(new ContextSrvStub() as any);
|
||||||
|
|
||||||
|
_dashboard.timepicker = {
|
||||||
|
refresh_intervals: null,
|
||||||
|
};
|
||||||
|
expect(() => timeSrv.init(_dashboard)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
describe('data point windowing', () => {
|
describe('data point windowing', () => {
|
||||||
it('handles time window specfied as interval string', () => {
|
it('handles time window specfied as interval string', () => {
|
||||||
locationService.push('/d/id?time=1410337645000&time.window=10s');
|
locationService.push('/d/id?time=1410337645000&time.window=10s');
|
||||||
|
@ -156,7 +156,9 @@ export class TimeSrv {
|
|||||||
this.refresh = getRefreshFromUrl({
|
this.refresh = getRefreshFromUrl({
|
||||||
params: paramsJSON,
|
params: paramsJSON,
|
||||||
currentRefresh: this.refresh,
|
currentRefresh: this.refresh,
|
||||||
refreshIntervals: this.dashboard?.timepicker?.refresh_intervals,
|
refreshIntervals: Array.isArray(this.dashboard?.timepicker?.refresh_intervals)
|
||||||
|
? this.dashboard?.timepicker?.refresh_intervals
|
||||||
|
: undefined,
|
||||||
isAllowedIntervalFn: this.contextSrv.isAllowedInterval,
|
isAllowedIntervalFn: this.contextSrv.isAllowedInterval,
|
||||||
minRefreshInterval: config.minRefreshInterval,
|
minRefreshInterval: config.minRefreshInterval,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user