-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass timetravel timestamp to cortex in deeplink
Closes #2753
- Loading branch information
Showing
2 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
client/app/scripts/components/node-details/__tests__/node-details-health-link-item-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import moment from 'moment'; | ||
|
||
import { appendTime } from '../node-details-health-link-item'; | ||
|
||
|
||
describe('NodeDetailsHealthLinkItem', () => { | ||
describe('appendTime', () => { | ||
const time = moment.unix(1496275200); | ||
|
||
it('returns url for empty url or time', () => { | ||
expect(appendTime('', time)).toEqual(''); | ||
expect(appendTime('foo', null)).toEqual('foo'); | ||
expect(appendTime('', null)).toEqual(''); | ||
}); | ||
|
||
it('appends as json for cloud link', () => { | ||
const url = appendTime('/prom/:orgid/notebook/new/%7B%22cells%22%3A%5B%7B%22queries%22%3A%5B%22go_goroutines%22%5D%7D%5D%7D', time); | ||
expect(url).toContain(time.unix()); | ||
|
||
const payload = JSON.parse(decodeURIComponent(url.substr(url.indexOf('new/') + 4))); | ||
expect(payload.time.queryEnd).toEqual(time.unix()); | ||
}); | ||
|
||
it('appends as GET parameter', () => { | ||
expect(appendTime('http://example.test?q=foo', time)).toEqual('http://example.test?q=foo&time=1496275200'); | ||
expect(appendTime('http://example.test/q=foo/', time)).toEqual('http://example.test/q=foo/?time=1496275200'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters