Skip to content

Commit

Permalink
Fix autorefresh in visualize editor (#41657) (#41851)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers authored Jul 24, 2019
1 parent b9fd8ba commit b0dfc80
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ function VisEditor(
Promise,
config,
kbnBaseUrl,
localStorage
localStorage,
// unused but required to initialize auto refresh :-\
/* eslint-disable no-unused-vars */
courier,
) {
const queryFilter = Private(FilterBarQueryFilterProvider);
const getUnhashableStates = Private(getUnhashableStatesProvider);
Expand Down
32 changes: 31 additions & 1 deletion test/functional/apps/visualize/_line_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function ({ getService, getPageObjects }) {
const log = getService('log');
const inspector = getService('inspector');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common', 'visualize', 'timePicker']);

describe('line charts', function () {
Expand Down Expand Up @@ -103,13 +104,42 @@ export default function ({ getService, getPageObjects }) {
});

it('should show correct data, ordered by Term', async function () {

const expectedChartData = [['png', '1,373'], ['php', '445'], ['jpg', '9,109'], ['gif', '918'], ['css', '2,159']];

await inspector.open();
await inspector.expectTableData(expectedChartData);
});

it('should request new data when autofresh is enabled', async () => {
// enable autorefresh
const interval = 3;
await PageObjects.timePicker.openQuickSelectTimeMenu();
await PageObjects.timePicker.inputValue('superDatePickerRefreshIntervalInput', interval.toString());
await testSubjects.click('superDatePickerToggleRefreshButton');
await PageObjects.timePicker.closeQuickSelectTimeMenu();

// check inspector panel request stats for timestamp
await inspector.open();
await inspector.openInspectorRequestsView();
const requestStatsBefore = await inspector.getTableData();
const requestTimestampBefore = requestStatsBefore.filter(r => r[0].includes('Request timestamp'))[0][1];

// pause to allow time for autorefresh to fire another request
await PageObjects.common.sleep(interval * 1000 * 1.5);

// get the latest timestamp from request stats
const requestStatsAfter = await inspector.getTableData();
const requestTimestampAfter = requestStatsAfter.filter(r => r[0].includes('Request timestamp'))[0][1];
log.debug(`Timestamp before: ${requestTimestampBefore}, Timestamp after: ${requestTimestampAfter}`);

// cleanup
await inspector.close();
await PageObjects.timePicker.pauseAutoRefresh();

// if autorefresh is working, timestamps should be different
expect(requestTimestampBefore).not.to.equal(requestTimestampAfter);
});

it('should be able to save and load', async function () {
await PageObjects.visualize.saveVisualizationExpectSuccessAndBreadcrumb(vizName1);
await PageObjects.visualize.waitForVisualizationSavedToastGone();
Expand Down

0 comments on commit b0dfc80

Please sign in to comment.