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

Update dashboard snapshot tests #19420

Merged
merged 6 commits into from
May 29, 2018
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
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/_dashboard_filter_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function ({ getService, getPageObjects }) {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerIn63DataRange();
await PageObjects.dashboard.setTimepickerInDataRange();
});

it('are not selected by default', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/dashboard/_dashboard_filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function ({ getService, getPageObjects }) {
describe('adding a filter that excludes all data', async () => {
before(async () => {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerIn63DataRange();
await PageObjects.dashboard.setTimepickerInDataRange();
await dashboardAddPanel.addEveryVisualization('"Filter Bytes Test"');
await dashboardAddPanel.addEverySavedSearch('"Filter Bytes Test"');
await dashboardAddPanel.closeAddPanel();
Expand Down Expand Up @@ -147,7 +147,7 @@ export default function ({ getService, getPageObjects }) {

it('visualization saved with a query filters data', async () => {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerIn63DataRange();
await PageObjects.dashboard.setTimepickerInDataRange();

await dashboardAddPanel.addVisualization('Rendering-Test:-animal-sounds-pie');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down
47 changes: 18 additions & 29 deletions test/functional/apps/dashboard/_dashboard_snapshots.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,66 @@
import expect from 'expect.js';

import { AREA_CHART_VIS_NAME } from '../../page_objects/dashboard_page';


export default function ({ getService, getPageObjects, updateBaselines }) {
const dashboardVisualizations = getService('dashboardVisualizations');
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize', 'common']);
const screenshot = getService('screenshots');
const remote = getService('remote');
const dashboardPanelActions = getService('dashboardPanelActions');
const testSubjects = getService('testSubjects');
const dashboardAddPanel = getService('dashboardAddPanel');

describe('dashboard snapshots', function describeIndexTests() {
before(async function () {
await PageObjects.dashboard.initTests();
await PageObjects.dashboard.preserveCrossAppState();
// We use a really small window to minimize differences across os's and browsers.
await remote.setWindowSize(1000, 500);
});

after(async function () {
// avoids any 'Object with id x not found' errors when switching tests.
await PageObjects.header.clickVisualize();
await PageObjects.visualize.gotoLandingPage();
await PageObjects.header.clickDashboard();
await PageObjects.dashboard.gotoDashboardLandingPage();
await remote.setWindowSize(1300, 900);
});

// This one won't work because of https://github.com/elastic/kibana/issues/15501. See if we can get it to work
// once TSVB has timezone support.
// Skip until https://github.com/elastic/kibana/issues/19471 is fixed
it.skip('compare TSVB snapshot', async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerInDataRange();
await dashboardVisualizations.createAndAddTSVBVisualization('TSVB');
await testSubjects.click('toastCloseButton');
await PageObjects.dashboard.setTimepickerInLogstashDataRange();
await dashboardAddPanel.addVisualization('Rendering Test: tsvb-ts');
await PageObjects.common.closeToast();

await PageObjects.dashboard.saveDashboard('tsvb');
await testSubjects.click('saveDashboardSuccess toastCloseButton');
await PageObjects.common.closeToast();

await PageObjects.dashboard.clickFullScreenMode();
await dashboardPanelActions.toggleExpandPanel();

await PageObjects.dashboard.waitForRenderComplete();
// Render complete flag doesn't handle resizes from expanding.
await PageObjects.common.sleep(2000);
const percentSimilar = await screenshot.compareAgainstBaseline('tsvb_dashboard', updateBaselines);

await PageObjects.dashboard.clickExitFullScreenLogoButton();

expect(percentSimilar).to.be(0);
expect(percentSimilar).to.be.lessThan(0.05);
});

it('compare area chart snapshot', async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.addVisualizations([AREA_CHART_VIS_NAME]);
await testSubjects.click('addVisualizationToDashboardSuccess toastCloseButton');

await PageObjects.dashboard.setTimepickerInLogstashDataRange();
await dashboardAddPanel.addVisualization('Rendering Test: area with not filter');
await PageObjects.common.closeToast();
await PageObjects.dashboard.saveDashboard('area');
await testSubjects.click('saveDashboardSuccess toastCloseButton');
await PageObjects.common.closeToast();

await PageObjects.dashboard.clickFullScreenMode();
await dashboardPanelActions.toggleExpandPanel();

await PageObjects.dashboard.waitForRenderComplete();
// The need for this should have been removed with https://github.com/elastic/kibana/pull/15574 but the
// test failed when removed because the visualization hadn't settled.
await PageObjects.common.sleep(1000);

// Render complete flag doesn't handle resizes from expanding.
await PageObjects.common.sleep(2000);
const percentSimilar = await screenshot.compareAgainstBaseline('area_chart', updateBaselines);

await PageObjects.dashboard.clickExitFullScreenLogoButton();

// Testing some OS/browser differnces were shown to cause .009 percent difference.
// Testing some OS/browser differences were shown to cause .009 percent difference.
expect(percentSimilar).to.be.lessThan(0.05);
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/functional/apps/dashboard/_dashboard_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.gotoDashboardLandingPage();

await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.setTimepickerInHistoricalDataRange();

await dashboardAddPanel.addVisualization(AREA_CHART_VIS_NAME);
await PageObjects.dashboard.saveDashboard('Overridden colors');
Expand All @@ -51,7 +51,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.gotoDashboardLandingPage();

await PageObjects.header.clickDiscover();
await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.setTimepickerInHistoricalDataRange();
await PageObjects.discover.clickFieldListItemAdd('bytes');
await PageObjects.discover.saveSearch('my search');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -101,7 +101,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.gotoDashboardLandingPage();

await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.setTimepickerInHistoricalDataRange();

await dashboardAddPanel.addVisualization('Visualization TileMap');
await PageObjects.dashboard.saveDashboard('No local edits');
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/_dashboard_time_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.addVisualizations([PIE_CHART_VIS_NAME]);
await dashboardExpect.pieSliceCount(0);

await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.setTimepickerInHistoricalDataRange();
await dashboardExpect.pieSliceCount(10);
});

Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/_panel_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ({ getService, getPageObjects }) {
describe('panel edit controls', function () {
before(async () => {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.setTimepickerInHistoricalDataRange();
await dashboardAddPanel.addVisualization(PIE_CHART_VIS_NAME);
});

Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/dashboard/_view_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function ({ getService, getPageObjects }) {
});

it('when a filter is deleted', async function () {
await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.setTimepickerInHistoricalDataRange();
await PageObjects.dashboard.filterOnPieSlice();
await PageObjects.dashboard.saveDashboard(dashboardName);

Expand Down Expand Up @@ -219,7 +219,7 @@ export default function ({ getService, getPageObjects }) {

it('when a dashboard has a filter and remains unchanged', async function () {
await PageObjects.dashboard.gotoDashboardEditMode(dashboardName);
await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.setTimepickerInHistoricalDataRange();
await PageObjects.dashboard.filterOnPieSlice();
await PageObjects.dashboard.saveDashboard(dashboardName);
await PageObjects.dashboard.clickEdit();
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function ({ getService, loadTestFile, getPageObjects }) {
await PageObjects.dashboard.initTests({
kibanaIndex: 'dashboard/current/kibana',
dataIndex: 'dashboard/current/data',
defaultIndex: 'logstash-*'
defaultIndex: 'logstash-*',
});
await PageObjects.dashboard.preserveCrossAppState();
});
Expand All @@ -34,6 +34,7 @@ export default function ({ getService, loadTestFile, getPageObjects }) {
loadTestFile(require.resolve('./_dashboard_filtering'));
loadTestFile(require.resolve('./_panel_expand_toggle'));
loadTestFile(require.resolve('./_dashboard_grid'));
loadTestFile(require.resolve('./_dashboard_snapshots'));
});

// Each of these tests call initTests themselves, the way it was originally written. The above tests only load
Expand All @@ -44,7 +45,6 @@ export default function ({ getService, loadTestFile, getPageObjects }) {

loadTestFile(require.resolve('./_dashboard_time_picker'));
loadTestFile(require.resolve('./_bwc_shared_urls'));
loadTestFile(require.resolve('./_dashboard_snapshots'));
loadTestFile(require.resolve('./_panel_controls'));
loadTestFile(require.resolve('./_view_edit'));
loadTestFile(require.resolve('./_dashboard_state'));
Expand Down
25 changes: 16 additions & 9 deletions test/functional/page_objects/common_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export function CommonPageProvider({ getService, getPageObjects }) {
.then(function (defaultIndex) {
if (appName === 'discover' || appName === 'visualize' || appName === 'dashboard') {
if (!defaultIndex) {
// https://github.com/elastic/kibana/issues/7496
// Even though most tests are using esClient to set the default index, sometimes Kibana clobbers
// that change. If we got here, fix it.
// https://github.com/elastic/kibana/issues/7496
// Even though most tests are using esClient to set the default index, sometimes Kibana clobbers
// that change. If we got here, fix it.
log.debug(' >>>>>>>> WARNING Navigating to [' + appName + '] with defaultIndex=' + defaultIndex);
log.debug(' >>>>>>>> Setting defaultIndex to "logstash-*""');
return kibanaServer.uiSettings.update({
Expand Down Expand Up @@ -108,14 +108,14 @@ export function CommonPageProvider({ getService, getPageObjects }) {
// Browsers don't show the ':port' if it's 80 or 443 so we have to
// remove that part so we can get a match in the tests.
const navSuccessful = new RegExp(appUrl.replace(':80', '').replace(':443', '')
+ '.{0,' + maxAdditionalLengthOnNavUrl + '}$')
+ '.{0,' + maxAdditionalLengthOnNavUrl + '}$')
.test(currentUrl);

if (!navSuccessful) {
const msg = 'App failed to load: ' + appName +
' in ' + defaultFindTimeout + 'ms' +
' appUrl = ' + appUrl +
' currentUrl = ' + currentUrl;
' in ' + defaultFindTimeout + 'ms' +
' appUrl = ' + appUrl +
' currentUrl = ' + currentUrl;
log.debug(msg);
throw new Error(msg);
}
Expand All @@ -130,7 +130,7 @@ export function CommonPageProvider({ getService, getPageObjects }) {
.then(function (currentUrl) {
let lastUrl = currentUrl;
return retry.try(function () {
// give the app time to update the URL
// give the app time to update the URL
return self.sleep(501)
.then(function () {
return remote.getCurrentUrl();
Expand Down Expand Up @@ -284,11 +284,18 @@ export function CommonPageProvider({ getService, getPageObjects }) {
});
}

async closeToast() {
const toast = await find.byCssSelector('.euiToast');
await remote.moveMouseTo(toast);
await find.clickByCssSelector('.euiToast__closeButton');
}

async clearAllToasts() {
const toasts = await find.allByCssSelector('.euiToast');
for (const toastElement of toasts) {
try {
const closeBtn = await toastElement.findByCssSelector('euiToast__closeButton');
await remote.moveMouseTo(toastElement);
const closeBtn = await toastElement.findByCssSelector('.euiToast__closeButton');
await closeBtn.click();
} catch (err) {
// ignore errors, toast clear themselves after timeout
Expand Down
10 changes: 8 additions & 2 deletions test/functional/page_objects/dashboard_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,24 @@ export function DashboardPageProvider({ getService, getPageObjects }) {
await dashboardAddPanel.addVisualizations(visualizations);
}

async setTimepickerInDataRange() {
async setTimepickerInHistoricalDataRange() {
const fromTime = '2015-09-19 06:31:44.000';
const toTime = '2015-09-23 18:31:44.000';
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
}

async setTimepickerIn63DataRange() {
async setTimepickerInDataRange() {
const fromTime = '2018-01-01 00:00:00.000';
const toTime = '2018-04-13 00:00:00.000';
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
}

async setTimepickerInLogstashDataRange() {
const fromTime = '2018-04-09 00:00:00.000';
const toTime = '2018-04-13 00:00:00.000';
await PageObjects.header.setAbsoluteRange(fromTime, toTime);
}

async setSaveAsNewCheckBox(checked) {
log.debug('saveAsNewCheckbox: ' + checked);
const saveAsNewCheckbox = await testSubjects.find('saveAsNewCheckbox');
Expand Down
Binary file modified test/functional/screenshots/baseline/area_chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/functional/screenshots/baseline/tsvb_dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/functional/services/dashboard/visualizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function DashboardVisualizationProvider({ getService, getPageObjects }) {
log.debug(`createSavedSearch(${name})`);
await PageObjects.header.clickDiscover();

await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.setTimepickerInHistoricalDataRange();

if (query) {
await queryBar.setQuery(query);
Expand Down
3 changes: 3 additions & 0 deletions test/functional/services/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export function FindProvider({ getService }) {
log.debug(`clickByPartialLinkText(${linkText})`);
await retry.try(async () => {
const element = await this.byPartialLinkText(linkText, timeout);
await remote.moveMouseTo(element);
await element.click();
});
}
Expand All @@ -158,6 +159,7 @@ export function FindProvider({ getService }) {
log.debug(`clickByLinkText(${linkText})`);
await retry.try(async () => {
const element = await this.byLinkText(linkText, timeout);
await remote.moveMouseTo(element);
await element.click();
});
}
Expand All @@ -166,6 +168,7 @@ export function FindProvider({ getService }) {
log.debug(`clickByCssSelector(${selector})`);
await retry.try(async () => {
const element = await this.byCssSelector(selector, timeout);
await remote.moveMouseTo(element);
await element.click();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function ({ getService, getPageObjects }) {
});

it('can filter on a visualization', async () => {
await PageObjects.dashboard.setTimepickerInDataRange();
await PageObjects.dashboard.setTimepickerInHistoricalDataRange();
await PageObjects.dashboard.filterOnPieSlice();
const filters = await PageObjects.dashboard.getFilters();
expect(filters.length).to.equal(1);
Expand Down