mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge branch 'master' into external-plugins
Conflicts: public/app/plugins/panels/table/editor.ts public/views/index.html
This commit is contained in:
24
public/test/core/utils/flatten_specs.ts
Normal file
24
public/test/core/utils/flatten_specs.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {describe, beforeEach, it, sinon, expect} from 'test/lib/common'
|
||||
|
||||
import flatten = require('app/core/utils/flatten')
|
||||
|
||||
describe("flatten", () => {
|
||||
|
||||
it('should return flatten object', () => {
|
||||
var flattened = flatten({
|
||||
level1: 'level1-value',
|
||||
deeper: {
|
||||
level2: 'level2-value',
|
||||
deeper: {
|
||||
level3: 'level3-value'
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
|
||||
expect(flattened['level1']).to.be('level1-value');
|
||||
expect(flattened['deeper.level2']).to.be('level2-value');
|
||||
expect(flattened['deeper.deeper.level3']).to.be('level3-value');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -68,6 +68,27 @@ define([
|
||||
describeValueFormat('wps', 789000000, 1000000, -1, '789M wps');
|
||||
describeValueFormat('iops', 11000000000, 1000000000, -1, '11B iops');
|
||||
|
||||
describeValueFormat('s', 24, 1, 0, '24 s');
|
||||
describeValueFormat('s', 246, 1, 0, '4.1 min');
|
||||
describeValueFormat('s', 24567, 100, 0, '6.82 hour');
|
||||
describeValueFormat('s', 24567890, 10000, 0, '40.62 week');
|
||||
describeValueFormat('s', 24567890000, 1000000, 0, '778.53 year');
|
||||
|
||||
describeValueFormat('m', 24, 1, 0, '24 min');
|
||||
describeValueFormat('m', 246, 10, 0, '4.1 hour');
|
||||
describeValueFormat('m', 6545, 10, 0, '4.55 day');
|
||||
describeValueFormat('m', 24567, 100, 0, '2.44 week');
|
||||
describeValueFormat('m', 24567892, 10000, 0, '46.7 year');
|
||||
|
||||
describeValueFormat('h', 21, 1, 0, '21 hour');
|
||||
describeValueFormat('h', 145, 1, 0, '6.04 day');
|
||||
describeValueFormat('h', 1234, 100, 0, '7.3 week');
|
||||
describeValueFormat('h', 9458, 1000, 0, '1.08 year');
|
||||
|
||||
describeValueFormat('d', 3, 1, 0, '3 day');
|
||||
describeValueFormat('d', 245, 100, 0, '35 week');
|
||||
describeValueFormat('d', 2456, 10, 0, '6.73 year');
|
||||
|
||||
describe('kbn.toFixed and negative decimals', function() {
|
||||
it('should treat as zero decimals', function() {
|
||||
var str = kbn.toFixed(186.123, -2);
|
||||
|
||||
@@ -204,7 +204,7 @@ define([
|
||||
});
|
||||
|
||||
it('dashboard schema version should be set to latest', function() {
|
||||
expect(model.schemaVersion).to.be(7);
|
||||
expect(model.schemaVersion).to.be(8);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -248,5 +248,90 @@ define([
|
||||
expect(clone.meta).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when loading dashboard with old influxdb query schema', function() {
|
||||
var model;
|
||||
var target;
|
||||
|
||||
beforeEach(function() {
|
||||
model = _dashboardSrv.create({
|
||||
rows: [{
|
||||
panels: [{
|
||||
type: 'graph',
|
||||
targets: [{
|
||||
"alias": "$tag_datacenter $tag_source $col",
|
||||
"column": "value",
|
||||
"measurement": "logins.count",
|
||||
"fields": [
|
||||
{
|
||||
"func": "mean",
|
||||
"name": "value",
|
||||
"mathExpr": "*2",
|
||||
"asExpr": "value"
|
||||
},
|
||||
{
|
||||
"name": "one-minute",
|
||||
"func": "mean",
|
||||
"mathExpr": "*3",
|
||||
"asExpr": "one-minute"
|
||||
}
|
||||
],
|
||||
"tags": [],
|
||||
"fill": "previous",
|
||||
"function": "mean",
|
||||
"groupBy": [
|
||||
{
|
||||
"interval": "auto",
|
||||
"type": "time"
|
||||
},
|
||||
{
|
||||
"key": "source",
|
||||
"type": "tag"
|
||||
},
|
||||
{
|
||||
"type": "tag",
|
||||
"key": "datacenter"
|
||||
}
|
||||
],
|
||||
}]
|
||||
}]
|
||||
}]
|
||||
});
|
||||
|
||||
target = model.rows[0].panels[0].targets[0];
|
||||
});
|
||||
|
||||
it('should update query schema', function() {
|
||||
expect(target.fields).to.be(undefined);
|
||||
expect(target.select.length).to.be(2);
|
||||
expect(target.select[0].length).to.be(4);
|
||||
expect(target.select[0][0].type).to.be('field');
|
||||
expect(target.select[0][1].type).to.be('mean');
|
||||
expect(target.select[0][2].type).to.be('math');
|
||||
expect(target.select[0][3].type).to.be('alias');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when creating dashboard model with missing list for annoations or templating', function() {
|
||||
var model;
|
||||
|
||||
beforeEach(function() {
|
||||
model = _dashboardSrv.create({
|
||||
annotations: {
|
||||
enable: true,
|
||||
},
|
||||
templating: {
|
||||
enable: true
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should add empty list', function() {
|
||||
expect(model.annotations.list.length).to.be(0);
|
||||
expect(model.templating.list.length).to.be(0);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,13 +78,20 @@ define([
|
||||
});
|
||||
|
||||
describe('setTime', function() {
|
||||
it('should return disable refresh for absolute times', function() {
|
||||
it('should return disable refresh if refresh is disabled for any range', function() {
|
||||
_dashboard.refresh = false;
|
||||
|
||||
ctx.service.setTime({from: '2011-01-01', to: '2015-01-01' });
|
||||
expect(_dashboard.refresh).to.be(false);
|
||||
});
|
||||
|
||||
it('should restore refresh for absolute time range', function() {
|
||||
_dashboard.refresh = '30s';
|
||||
|
||||
ctx.service.setTime({from: '2011-01-01', to: '2015-01-01' });
|
||||
expect(_dashboard.refresh).to.be('30s');
|
||||
});
|
||||
|
||||
it('should restore refresh after relative time range is set', function() {
|
||||
_dashboard.refresh = '10s';
|
||||
ctx.service.setTime({from: moment([2011,1,1]), to: moment([2015,1,1])});
|
||||
|
||||
Reference in New Issue
Block a user