Skip to content

Commit

Permalink
Revert "correctly passing saved filters and query to all response han…
Browse files Browse the repository at this point in the history
…dlers (#32749) (#32964)"

This reverts commit 46801c3.
  • Loading branch information
spalger committed Mar 12, 2019
1 parent 8b15d42 commit 35e2b80
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const kibanaContext = () => ({
}

if (context.filters) {
filters = filters.concat(context.filters).filter(f => !f.meta.disabled);
filters = filters.concat(context.filters);
}

const timeRange = args.timeRange ? JSON.parse(args.timeRange) : context.timeRange;
Expand Down
12 changes: 3 additions & 9 deletions src/legacy/ui/public/visualize/loader/visualize_data_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,17 @@ export class VisualizeDataLoader {
// add necessary params to vis object (dimensions, bucket, metric, etc)
const visParams = getVisParams(this.vis, { timeRange: params.timeRange });

const filters = params.filters || [];
const savedFilters = params.searchSource.getField('filter') || [];

const query = params.query || params.searchSource.getField('query');

// searchSource is only there for courier request handler
const requestHandlerResponse = await this.requestHandler({
partialRows: this.vis.params.partialRows || this.vis.type.requiresPartialRows,
metricsAtAllLevels: this.vis.isHierarchical(),
visParams,
...params,
query,
filters: filters.concat(savedFilters).filter(f => !f.meta.disabled),
filters: params.filters ? params.filters.filter(filter => !filter.meta.disabled) : undefined,
});

// No need to call the response handler when there have been no data nor has there been changes
// in the vis-state (response handler does not depend on uiState)
// No need to call the response handler when there have been no data nor has been there changes
// in the vis-state (response handler does not depend on uiStat
const canSkipResponseHandler =
this.previousRequestHandlerResponse &&
this.previousRequestHandlerResponse === requestHandlerResponse &&
Expand Down
60 changes: 19 additions & 41 deletions test/functional/apps/visualize/_vega_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@
import expect from 'expect.js';

export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['common', 'header', 'timePicker', 'visualize']);
const filterBar = getService('filterBar');
const inspector = getService('inspector');
const log = getService('log');

const fromTime = '2015-09-19 06:31:44.000';
const toTime = '2015-09-23 18:31:44.000';
const inspector = getService('inspector');
const PageObjects = getPageObjects(['common', 'visualize', 'header']);

describe('visualize app', () => {
before(async () => {
Expand All @@ -37,46 +33,28 @@ export default function ({ getService, getPageObjects }) {
});

describe('vega chart', () => {
describe('initial render', () => {
it('should not have inspector enabled', async function () {
await inspector.expectIsNotEnabled();
});

it.skip('should have some initial vega spec text', async function () {
const vegaSpec = await PageObjects.visualize.getVegaSpec();
expect(vegaSpec).to.contain('{').and.to.contain('data');
expect(vegaSpec.length).to.be.above(500);
});

it('should have view and control containers', async function () {
const view = await PageObjects.visualize.getVegaViewContainer();
expect(view).to.be.ok();
const size = await view.getSize();
expect(size).to.have.property('width').and.to.have.property('height');
expect(size.width).to.be.above(0);
expect(size.height).to.be.above(0);

const controls = await PageObjects.visualize.getVegaControlContainer();
expect(controls).to.be.ok();
});
it('should not have inspector enabled', async function () {
await inspector.expectIsNotEnabled();
});

describe('with filters', () => {
before(async () => {
log.debug('setAbsoluteRange');
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
});
it.skip('should have some initial vega spec text', async function () {
const vegaSpec = await PageObjects.visualize.getVegaSpec();
expect(vegaSpec).to.contain('{').and.to.contain('data');
expect(vegaSpec.length).to.be.above(500);
});

afterEach(async () => {
await filterBar.removeAllFilters();
});
it('should have view and control containers', async function () {
const view = await PageObjects.visualize.getVegaViewContainer();
expect(view).to.be.ok();
const size = await view.getSize();
expect(size).to.have.property('width').and.to.have.property('height');
expect(size.width).to.be.above(0);
expect(size.height).to.be.above(0);

it('should render different data in response to filter change', async function () {
await PageObjects.visualize.expectVisToMatchScreenshot('vega_chart');
await filterBar.addFilter('@tags.raw', 'is', 'error');
await PageObjects.visualize.expectVisToMatchScreenshot('vega_chart_filtered');
});
const controls = await PageObjects.visualize.getVegaControlContainer();
expect(controls).to.be.ok();
});

});
});
}
36 changes: 1 addition & 35 deletions test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import { VisualizeConstants } from '../../../src/legacy/core_plugins/kibana/publ
import Bluebird from 'bluebird';
import expect from 'expect.js';

export function VisualizePageProvider({ getService, getPageObjects, updateBaselines }) {
export function VisualizePageProvider({ getService, getPageObjects }) {
const browser = getService('browser');
const config = getService('config');
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const find = getService('find');
const log = getService('log');
const inspector = getService('inspector');
const screenshot = getService('screenshots');
const table = getService('table');
const globalNav = getService('globalNav');
const PageObjects = getPageObjects(['common', 'header']);
Expand Down Expand Up @@ -743,39 +742,6 @@ export function VisualizePageProvider({ getService, getPageObjects, updateBaseli
return await Promise.all(getChartTypesPromises);
}

/**
* Removes chrome and takes a small screenshot of a vis to compare against a baseline.
* @param {string} name The name of the baseline image.
* @param {object} opts Options object.
* @param {number} opts.threshold Threshold for allowed variance when comparing images.
*/
async expectVisToMatchScreenshot(name, opts = { threshold: 0.05 }) {
log.debug(`expectVisToMatchScreenshot(${name})`);

// Collapse sidebar and inject some CSS to hide the nav so we have a focused screenshot
await this.clickEditorSidebarCollapse();
await this.waitForVisualizationRenderingStabilized();
await browser.execute(`
var el = document.createElement('style');
el.id = '__data-test-style';
el.innerHTML = '[data-test-subj="headerGlobalNav"] { display: none; } ';
el.innerHTML += '[data-test-subj="top-nav"] { display: none; } ';
el.innerHTML += '[data-test-subj="experimentalVisInfo"] { display: none; } ';
document.body.appendChild(el);
`);

const percentDifference = await screenshot.compareAgainstBaseline(name, updateBaselines);

// Reset the chart to its original state
await browser.execute(`
var el = document.getElementById('__data-test-style');
document.body.removeChild(el);
`);
await this.clickEditorSidebarCollapse();
await this.waitForVisualizationRenderingStabilized();
expect(percentDifference).to.be.lessThan(opts.threshold);
}

/*
** This method gets the chart data and scales it based on chart height and label.
** Returns an array of height values
Expand Down
Binary file removed test/functional/screenshots/baseline/vega_chart.png
Binary file not shown.
Binary file not shown.

0 comments on commit 35e2b80

Please sign in to comment.