Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Jun 9, 2017
1 parent 96ba1c4 commit 0e3d49f
Show file tree
Hide file tree
Showing 27 changed files with 113 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
id="gaugeType"
class="kuiSelect kuiSideBarSelect"
ng-model="vis.params.gauge.gaugeType"
ng-options="mode for mode in vis.type.params.gaugeTypes"
ng-options="mode for mode in collections.gaugeTypes"
></select>
</div>
</div>
Expand Down Expand Up @@ -183,7 +183,7 @@
id="colorSchema"
class="kuiSelect kuiSideBarSelect"
ng-model="vis.params.gauge.colorSchema"
ng-options="mode for mode in vis.type.params.colorSchemas"
ng-options="mode for mode in collections.colorSchemas"
></select>
</div>
<div class="text-info text-center" ng-show="customColors" ng-click="resetColors()">reset colors</div>
Expand Down Expand Up @@ -255,7 +255,7 @@
id="gaugeColorMode"
class="kuiSelect kuiSideBarSelect"
ng-model="vis.params.gauge.gaugeColorMode"
ng-options="mode for mode in vis.type.params.gaugeColorMode"
ng-options="mode for mode in collections.gaugeColorMode"
></select>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.directive('gaugeOptions', function () {
template: gaugeOptionsTemplate,
replace: true,
link: function ($scope) {

$scope.collections = $scope.vis.type.editorConfig.collections;
$scope.showColorRange = true;

$scope.$watch('vis.params.gauge.gaugeType', type => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
id="colorSchema"
class="kuiSelect kuiSideBarSelect"
ng-model="vis.params.colorSchema"
ng-options="mode for mode in vis.editorConfig.collections.colorSchemas"
ng-options="mode for mode in collections.colorSchemas"
></select>
</div>
<div
Expand Down Expand Up @@ -39,7 +39,7 @@
id="axisScale"
class="kuiSelect kuiSideBarSelect"
ng-model="valueAxis.scale.type"
ng-options="mode for mode in vis.editorConfig.collections.scales"
ng-options="mode for mode in collections.scales"
></select>
</div>
</div>
Expand Down Expand Up @@ -141,15 +141,15 @@
ng-click="removeRange($index)"
class="kuiButton kuiButton--danger kuiButton--small"
>
<span class="kuiIcon fa-times"><span>
<span class="kuiIcon fa-times"></span>
</button>
</td>
</tr>
</table>

<div class="hintbox" ng-show="!vis.params.colorsRange.length">
<p>
<span class="kuiIcon fa-danger text-danger"><span>
<span class="kuiIcon fa-danger text-danger"></span>
<strong>Required:</strong> You must specify at least one range.
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ module.directive('heatmapOptions', function () {
template: heatmapOptionsTemplate,
replace: true,
link: function ($scope) {

$scope.collections = $scope.vis.type.editorConfig.collections;

const verticalRotation = 270;
$scope.showColorRange = false;
$scope.showLabels = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('point series editor', function () {
function makeConfig() {
return {
type: 'line',
params: lineVisType.params.defaults,
params: lineVisType.visConfig.defaults,
aggs: [
{ type: 'count', schema: 'metric', params: { field: 'bytes' } },
{ type: 'terms', schema: 'segment', params: { field: 'machine.os' } },
Expand Down
2 changes: 2 additions & 0 deletions src/core_plugins/kibana/public/dashboard/panel/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@
saved-obj="savedObj"
app-state="appState"
ui-state="uiState"
data-shared-item
data-title="{{savedObj.title}}"
data-description="{{savedObj.description}}"
render-counter
class="panel-content">
</visualize>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('markdown vis controller', function () {
beforeEach(ngMock.module('kibana/markdown_vis'));
beforeEach(ngMock.inject(function ($rootScope, $controller) {
$scope = $rootScope.$new();
$scope.renderComplete = () => {};
const $element = $('<div>');
$controller('KbnMarkdownVisController', { $scope, $element });
$scope.$digest();
Expand Down
5 changes: 5 additions & 0 deletions src/core_plugins/metrics/public/components/vis_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ class VisEditor extends Component {
</div>
);
}

return null;
}

componentDidMount() {
this.props.renderComplete();
}

}

VisEditor.propTypes = {
Expand Down
58 changes: 0 additions & 58 deletions src/core_plugins/metrics/public/lib/__tests__/add_scope.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
import createBrushHandler from '../create_brush_handler';
import sinon from 'sinon';
import moment from 'moment';
import { expect } from 'chai';

describe('createBrushHandler', () => {

let evalAsyncStub;
let $scope;
let timefilter;
let fn;
let range;

beforeEach(() => {
evalAsyncStub = sinon.stub().yields();
$scope = { $evalAsync: evalAsyncStub };
timefilter = { time: {} };
fn = createBrushHandler($scope, timefilter);
timefilter = { time: {}, update: () => {} };
fn = createBrushHandler(timefilter);
range = { xaxis: { from: '2017-01-01T00:00:00Z', to: '2017-01-01T00:10:00Z' } };
fn(range);
});

it('returns brushHandler() that calls $scope.$evalAsync()', () => {
expect(evalAsyncStub.calledOnce).to.equal(true);
});

it('returns brushHandler() that updates timefilter', () => {
expect(timefilter.time.from).to.equal(moment(range.xaxis.from).toISOString());
expect(timefilter.time.to).to.equal(moment(range.xaxis.to).toISOString());
Expand Down
6 changes: 3 additions & 3 deletions src/core_plugins/region_map/public/region_map_vis_params.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
id="regionMap"
class="kuiSelect kuiSideBarSelect"
ng-model="vis.params.selectedLayer"
ng-options="layer.name for layer in vis.type.params.vectorLayers"
ng-options="layer.name for layer in collections.vectorLayers"
ng-change="onLayerChange()"
ng-init="vis.params.selectedLayer=vis.type.params.vectorLayers[0]"
ng-init="vis.params.selectedLayer=collections.vectorLayers[0]"
></select>
</div>
</div>
Expand Down Expand Up @@ -51,7 +51,7 @@
id="colorSchema"
class="kuiSelect kuiSideBarSelect"
ng-model="vis.params.colorSchema"
ng-options="mode for mode in vis.type.params.colorSchemas"
ng-options="mode for mode in collections.colorSchemas"
></select>
</div>
</div>
Expand Down
10 changes: 6 additions & 4 deletions src/core_plugins/region_map/public/region_map_vis_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ uiModules.get('kibana/region_map')
template: regionMapVisParamsTemplate,
link: function ($scope) {

$scope.collections = $scope.vis.type.editorConfig.collections;

$scope.onLayerChange = onLayerChange;
serviceSettings.getFileLayers()
.then(function (layersFromService) {

const newVectorLayers = $scope.vis.type.params.vectorLayers.slice();
const newVectorLayers = $scope.collections.vectorLayers.slice();
for (let i = 0; i < layersFromService.length; i += 1) {
const layerFromService = layersFromService[i];
const alreadyAdded = newVectorLayers.some((layer) =>_.eq(layerFromService, layer));
Expand All @@ -26,10 +28,10 @@ uiModules.get('kibana/region_map')
}
}

$scope.vis.type.params.vectorLayers = newVectorLayers;
$scope.collections.vectorLayers = newVectorLayers;

if ($scope.vis.type.params.vectorLayers[0] && !$scope.vis.params.selectedLayer) {
$scope.vis.params.selectedLayer = $scope.vis.type.params.vectorLayers[0];
if ($scope.collections.vectorLayers[0] && !$scope.vis.params.selectedLayer) {
$scope.vis.params.selectedLayer = $scope.collections.vectorLayers[0];
onLayerChange();
}

Expand Down
34 changes: 21 additions & 13 deletions src/core_plugins/table_vis/public/__tests__/_table_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ describe('Integration', function () {
$rootScope.vis = vis;
$rootScope.esResponse = esResponse;
$rootScope.uiState = require('fixtures/mock_ui_state');
$el = $('<visualize vis="vis" es-resp="esResponse" ui-state="uiState">');
$el = $('<visualization vis="vis" vis-data="esResponse" ui-state="uiState">');
$compile($el)($rootScope);
$rootScope.$apply();

}

function OneRangeVis(params) {
Expand Down Expand Up @@ -89,20 +90,25 @@ describe('Integration', function () {
it('passes the table groups to the kbnAggTableGroup directive', function () {
init(new OneRangeVis(), fixtures.oneRangeBucket);

const $atg = $el.find('kbn-agg-table-group').first();
expect($atg.size()).to.be(1);
expect($atg.attr('group')).to.be('tableGroups');
expect($atg.isolateScope().group).to.be($atg.scope().tableGroups);
$rootScope.$on('renderComplete', () => {
const $atg = $el.find('kbn-agg-table-group').first();
expect($atg.size()).to.be(1);
expect($atg.attr('group')).to.be('tableGroups');
expect($atg.isolateScope().group).to.be($atg.scope().tableGroups);
});

});

it('displays an error if the search had no hits', function () {
init(new OneRangeVis(), { hits: { total: 0, hits: [] } });

expect($el.find('kbn-agg-table-group').size()).to.be(0);
$rootScope.$on('renderComplete', () => {
expect($el.find('kbn-agg-table-group').size()).to.be(0);

const $err = $el.find('.table-vis-error');
expect($err.size()).to.be(1);
expect($err.text().trim()).to.be('No results found');
const $err = $el.find('.table-vis-error');
expect($err.size()).to.be(1);
expect($err.text().trim()).to.be('No results found');
});
});

it('displays an error if the search hits, but didn\'t create any rows', function () {
Expand All @@ -121,10 +127,12 @@ describe('Integration', function () {

init(new ThreeTermVis(visParams), resp);

expect($el.find('kbn-agg-table-group').size()).to.be(0);
$rootScope.$on('renderComplete', () => {
expect($el.find('kbn-agg-table-group').size()).to.be(0);

const $err = $el.find('.table-vis-error');
expect($err.size()).to.be(1);
expect($err.text().trim()).to.be('No results found');
const $err = $el.find('.table-vis-error');
expect($err.size()).to.be(1);
expect($err.text().trim()).to.be('No results found');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('Controller', function () {

$rootScope.vis = vis;
$rootScope.uiState = new AppState({ uiState: {} }).makeStateful('uiState');
$rootScope.renderComplete = () => {};
$rootScope.newScope = function (scope) { $scope = scope; };

$el = $('<div>')
Expand Down
4 changes: 2 additions & 2 deletions src/core_plugins/tile_map/public/__tests__/geohash_layer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import expect from 'expect.js';
import { KibanaMap } from 'ui/vis_maps/kibana_map';
import { GeohashLayer } from 'ui/vis_maps/geohash_layer';
import { KibanaMap } from '../kibana_map';
import { GeohashLayer } from '../geohash_layer';
import { GeoHashSampleData } from './geohash_sample_data';

describe('kibana_map tests', function () {
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/tile_map/public/__tests__/kibana_map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import expect from 'expect.js';
import { KibanaMap } from 'ui/vis_maps/kibana_map';
import { KibanaMap } from '../kibana_map';

describe('kibana_map tests', function () {

Expand Down
Loading

0 comments on commit 0e3d49f

Please sign in to comment.