Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Fix autorefresh in visualize editor (#41657) #41851

Merged
merged 1 commit into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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