Commit 7289e6e5 by Dominik Prokop

Addedd assertions about raw time range when panel time overriden

parent c3fdc1a0
......@@ -33,6 +33,8 @@ describe('applyPanelTimeOverrides', () => {
expect(overrides.timeRange.from.toISOString()).toBe(moment([2019, 1, 11, 12]).toISOString());
expect(overrides.timeRange.to.toISOString()).toBe(fakeCurrentDate.toISOString());
expect(overrides.timeRange.raw.from).toBe('now-2h');
expect(overrides.timeRange.raw.to).toBe('now');
});
it('should apply time shift', () => {
......@@ -48,6 +50,8 @@ describe('applyPanelTimeOverrides', () => {
expect(overrides.timeRange.from.toISOString()).toBe(expectedFromDate.toISOString());
expect(overrides.timeRange.to.toISOString()).toBe(expectedToDate.toISOString());
expect((overrides.timeRange.raw.from as moment.Moment).toISOString()).toEqual(expectedFromDate.toISOString());
expect((overrides.timeRange.raw.to as moment.Moment).toISOString()).toEqual(expectedToDate.toISOString());
});
it('should apply both relative time and time shift', () => {
......@@ -64,5 +68,7 @@ describe('applyPanelTimeOverrides', () => {
expect(overrides.timeRange.from.toISOString()).toBe(expectedFromDate.toISOString());
expect(overrides.timeRange.to.toISOString()).toBe(expectedToDate.toISOString());
expect((overrides.timeRange.raw.from as moment.Moment).toISOString()).toEqual(expectedFromDate.toISOString());
expect((overrides.timeRange.raw.to as moment.Moment).toISOString()).toEqual(expectedToDate.toISOString());
});
});
......@@ -142,10 +142,16 @@ export function applyPanelTimeOverrides(panel: PanelModel, timeRange: TimeRange)
const timeShift = '-' + timeShiftInterpolated;
newTimeData.timeInfo += ' timeshift ' + timeShift;
const from = dateMath.parseDateMath(timeShift, newTimeData.timeRange.from, false);
const to = dateMath.parseDateMath(timeShift, newTimeData.timeRange.to, true);
newTimeData.timeRange = {
from: dateMath.parseDateMath(timeShift, newTimeData.timeRange.from, false),
to: dateMath.parseDateMath(timeShift, newTimeData.timeRange.to, true),
raw: newTimeData.timeRange.raw,
from,
to,
raw: {
from,
to,
},
};
}
......
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