Skip to content

Commit

Permalink
Fix screenshots with minimal sleep calls. Remove a couple unnecessary…
Browse files Browse the repository at this point in the history
… promise chains in visualizePage.

Fixes #5932
  • Loading branch information
LeeDr committed Jan 19, 2016
1 parent 967cc0c commit c0d049c
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 73 deletions.
39 changes: 17 additions & 22 deletions test/functional/apps/visualize/_area_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ define(function (require) {
});

bdd.describe('area charts', function indexPatternCreation() {
var testSubName = 'AreaChart';
var vizName1 = 'Visualization ' + testSubName;

bdd.it('should save and load, take screenshot', function pageHeader() {

var testSubName = 'AreaChart';
var vizName1 = 'Visualization ' + testSubName;

bdd.it('should save and load', function pageHeader() {
return visualizePage.saveVisualization(vizName1)
.then(function (message) {
common.debug('Saved viz message = ' + message);
Expand All @@ -114,24 +112,17 @@ define(function (require) {
.then(function loadSavedVisualization() {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function getSpinnerDone() {
common.debug('Waiting...');
return headerPage.getSpinnerDone();
})
.then(function waitForVisualization() {
.then(function () {
return visualizePage.waitForVisualization();
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
.then(function sleep() {
return common.sleep(2000);
})
.catch(common.handleError(this));
});



bdd.it('should show correct chart', function pageHeader() {

bdd.it('should show correct chart, take screenshot', function pageHeader() {
var chartHeight = 0;
var xAxisLabels = [ '2015-09-20 00:00', '2015-09-21 00:00',
'2015-09-22 00:00', '2015-09-23 00:00'
Expand All @@ -141,10 +132,12 @@ define(function (require) {
683, 1361, 1415, 707, 177, 27, 32, 175, 707, 1408, 1355, 726, 201, 29
];

return visualizePage.getXAxisLabels()
.then(function (labels) {
common.debug('X-Axis labels = ' + labels);
expect(labels).to.eql(xAxisLabels);
return common.tryForTime(5000, function () {
return visualizePage.getXAxisLabels()
.then(function compareLabels(labels) {
common.debug('X-Axis labels = ' + labels);
expect(labels).to.eql(xAxisLabels);
});
})
.then(function getYAxisLabels() {
return visualizePage.getYAxisLabels();
Expand All @@ -154,20 +147,22 @@ define(function (require) {
expect(labels).to.eql(yAxisLabels);
})
.then(function getAreaChartData() {
//return common.tryForTime(500, function () {
return visualizePage.getAreaChartData();
})
.then(function (paths) {
common.debug('expectedAreaChartData = ' + expectedAreaChartData);
common.debug('actual chart data = ' + paths);
expect(paths).to.eql(expectedAreaChartData);
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});


bdd.it('should show correct data', function pageHeader() {

var expectedTableData = [ 'September 20th 2015, 00:00:00.000 37',
'September 20th 2015, 03:00:00.000 202',
'September 20th 2015, 06:00:00.000 740',
Expand Down
5 changes: 4 additions & 1 deletion test/functional/apps/visualize/_data_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ define(function (require) {
common.debug('Saved viz message = ' + message);
expect(message).to.be('Visualization Editor: Saved Visualization \"' + vizName1 + '\"');
})
.then(function testVisualizeWaitForToastMessageGone() {
return visualizePage.waitForToastMessageGone();
})
.then(function () {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function waitForVisualization() {
.then(function () {
return visualizePage.waitForVisualization();
})
.then(function takeScreenshot() {
Expand Down
18 changes: 9 additions & 9 deletions test/functional/apps/visualize/_line_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ define(function (require) {
});

bdd.describe('line charts', function indexPatternCreation() {
var testSubName = 'LineChart';
var vizName1 = 'Visualization ' + testSubName;

bdd.it('should be able to save and load, take screenshot', function pageHeader() {
bdd.it('should be able to save and load', function pageHeader() {

var testSubName = 'LineChart';
common.debug('Start of test' + testSubName + 'Visualization');
var vizName1 = 'Visualization ' + testSubName;
var remote = this.remote;

return visualizePage.saveVisualization(vizName1)
Expand All @@ -107,16 +107,11 @@ define(function (require) {
.then(function waitForVisualization() {
return visualizePage.waitForVisualization();
})
.then(function takeScreenshot() {
// take a snapshot just as an example.
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});


bdd.it('should show correct chart', function pageHeader() {
bdd.it('should show correct chart, take screenshot', function pageHeader() {

var remote = this.remote;

Expand All @@ -138,6 +133,11 @@ define(function (require) {
common.debug('Done');
});
})
.then(function takeScreenshot() {
// take a snapshot just as an example.
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});

Expand Down
41 changes: 19 additions & 22 deletions test/functional/apps/visualize/_pie_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ define(function (require) {


bdd.describe('pie chart', function indexPatternCreation() {
var testSubName = 'PieChart';
var vizName1 = 'Visualization ' + testSubName;


bdd.it('should save and load, take screenshot', function pageHeader() {
var testSubName = 'PieChart';
bdd.it('should save and load', function pageHeader() {
common.debug('Start of test' + testSubName + 'Visualization');
var vizName1 = 'Visualization ' + testSubName;
var remote = this.remote;

return visualizePage.saveVisualization(vizName1)
Expand All @@ -114,6 +114,22 @@ define(function (require) {
.then(function waitForVisualization() {
return visualizePage.waitForVisualization();
})
.then(function sleep() {
return common.sleep(2000);
})
.catch(common.handleError(this));
});

bdd.it('should show 10 slices in pie chart, take screenshot', function pageHeader() {
var remote = this.remote;
var expectedPieChartSliceCount = 10;

return visualizePage.getPieChartData()
.then(function (pieData) {
var barHeightTolerance = 1;
common.debug('pieData.length = ' + pieData.length);
expect(pieData.length).to.be(expectedPieChartSliceCount);
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
Expand All @@ -138,28 +154,9 @@ define(function (require) {
common.debug(data.split('\n'));
expect(data.trim().split('\n')).to.eql(expectedTableData);
})
// expandChart (toggle)
.then(function () {
return visualizePage.collapseChart();
})
.then(function sleep() {
return common.sleep(500);
})
.catch(common.handleError(this));
});

bdd.it('should show 10 slices in pie chart', function pageHeader() {
var remote = this.remote;
var expectedPieChartSliceCount = 10;

return visualizePage.getPieChartData()
.then(function (pieData) {
var barHeightTolerance = 1;
common.debug('pieData.length = ' + pieData.length);
expect(pieData.length).to.be(expectedPieChartSliceCount);
})
.catch(common.handleError(this));
});

});
});
Expand Down
7 changes: 4 additions & 3 deletions test/intern.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ define(function (require) {
}],
tunnelOptions: serverConfig.servers.webdriver,
functionalSuites: [
// 'test/functional/status_page/index',
// 'test/functional/apps/settings/index',
// 'test/functional/apps/discover/index',
'test/functional/status_page/index',
'test/functional/apps/settings/index',
'test/functional/apps/discover/index',
'test/functional/apps/visualize/index'
],
excludeInstrumentation: /(fixtures|node_modules)\//,
Expand All @@ -26,6 +26,7 @@ define(function (require) {
}
},
timeouts: {
// this is how long a test can run before timing out
default: 90000
},
}, serverConfig);
Expand Down
19 changes: 3 additions & 16 deletions test/support/pages/VisualizePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,7 @@ define(function (require) {
return self.remote
.setFindTimeout(defaultTimeout)
.findByLinkText(vizName)
.click()
.then(function getSpinnerDone() {
return self.getSpinnerDone(); // only matches the hidden spinners
})
.catch(function () {
common.debug('didn\'t find vis name on first page');
return;
});
.click();
});
},

Expand All @@ -357,10 +350,7 @@ define(function (require) {
.then(function (chartTypes) {
function getChartType(chart) {
return chart
.getVisibleText()
.then(function (theText) {
return theText;
});
.getVisibleText();
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
Expand All @@ -379,10 +369,7 @@ define(function (require) {
.then(function (chartTypes) {
function getChartType(chart) {
return chart
.getVisibleText()
.then(function (theText) {
return theText;
});
.getVisibleText();
}
var getChartTypesPromises = chartTypes.map(getChartType);
return Promise.all(getChartTypesPromises);
Expand Down

0 comments on commit c0d049c

Please sign in to comment.