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

Initial test to see if screenshot timing is the prob. #5932

Closed
wants to merge 11 commits into from
96 changes: 47 additions & 49 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,9 +112,50 @@ define(function (require) {
.then(function loadSavedVisualization() {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function getSpinnerDone() {
common.debug('Waiting...');
return headerPage.getSpinnerDone();
.then(function () {
return visualizePage.waitForVisualization();
})
// We have to sleep sometime between loading the saved visTitle
// and trying to access the chart below with getXAxisLabels
// otherwise it hangs.
.then(function sleep() {
return common.sleep(2000);
})
.catch(common.handleError(this));
});


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'
];
var yAxisLabels = ['0','200','400','600','800','1,000','1,200','1,400','1,600'];
var expectedAreaChartData = [37, 202, 740, 1437, 1371, 751, 188, 31, 42, 202,
683, 1361, 1415, 707, 177, 27, 32, 175, 707, 1408, 1355, 726, 201, 29
];

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();
})
.then(function (labels) {
common.debug('Y-Axis labels = ' + labels);
expect(labels).to.eql(yAxisLabels);
})
.then(function getAreaChartData() {
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');
Expand All @@ -127,7 +166,6 @@ define(function (require) {


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 Expand Up @@ -165,50 +203,10 @@ define(function (require) {
common.debug('getDataTableData = ' + data.split('\n'));
expect(data.trim().split('\n')).to.eql(expectedTableData);
})
.then(function collapseChart() {
return visualizePage.collapseChart();
})
.then(function sleep() {
return common.sleep(2000);
})
.catch(common.handleError(this));
});


bdd.it('should show correct chart', 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'
];
var yAxisLabels = ['0','200','400','600','800','1,000','1,200','1,400','1,600'];
var expectedAreaChartData = [37, 202, 740, 1437, 1371, 751, 188, 31, 42, 202,
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);
})
.then(function getYAxisLabels() {
return visualizePage.getYAxisLabels();
})
.then(function (labels) {
common.debug('Y-Axis labels = ' + labels);
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);
})
.catch(common.handleError(this));
});

});
});
Expand Down
23 changes: 13 additions & 10 deletions test/functional/apps/visualize/_data_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,29 @@ define(function (require) {


bdd.describe('data table', function indexPatternCreation() {
var testSubName = 'DataTable';
var vizName1 = 'Visualization ' + testSubName;

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

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

bdd.it('should be able to save and load', function pageHeader() {
return visualizePage.saveVisualization(vizName1)
.then(function (message) {
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 takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
.then(function () {
return visualizePage.waitForVisualization();
})
.catch(common.handleError(this));
});


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

bdd.it('should show correct data, take screenshot', function pageHeader() {
var chartHeight = 0;
var expectedChartData = [ '0 2,088', '2,000 2,748', '4,000 2,707', '6,000 2,876',
'8,000 2,863', '10,000 147', '12,000 148', '14,000 129', '16,000 161', '18,000 137'
Expand All @@ -124,6 +123,10 @@ define(function (require) {
common.debug(data.split('\n'));
expect(data.split('\n')).to.eql(expectedChartData);
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});

Expand Down
20 changes: 12 additions & 8 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 @@ -104,23 +104,22 @@ define(function (require) {
.then(function () {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function takeScreenshot() {
// take a snapshot just as an example.
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
.then(function waitForVisualization() {
return visualizePage.waitForVisualization();
})
.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;

// this test only verifies the numerical part of this data
// it could also check the legend to verify the extensions
var expectedChartData = ['jpg 9,109', 'css 2,159', 'png 1,373', 'gif 918', 'php 445'];

// sleep a bit before trying to get the chart data
return common.sleep(3000)
.then(function () {
return visualizePage.getLineChartData()
Expand All @@ -135,6 +134,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
45 changes: 23 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 @@ -111,6 +111,26 @@ define(function (require) {
.then(function () {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function waitForVisualization() {
return visualizePage.waitForVisualization();
})
// sleep a bit before trying to get the pie chart data below
.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 @@ -135,28 +155,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
10 changes: 7 additions & 3 deletions test/functional/apps/visualize/_tile_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ define(function (require) {
.then(function () {
return visualizePage.loadSavedVisualization(vizName1);
})
.then(function waitForVisualization() {
return visualizePage.waitForVisualization();
})
// sleep a bit before taking the screenshot or it won't show data
.then(function sleep() {
return common.sleep(4000);
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
Expand Down Expand Up @@ -134,9 +141,6 @@ define(function (require) {
expect(data.trim().split('\n')).to.eql(expectedTableData);
});
})
.then(function () {
return visualizePage.collapseChart();
})
.catch(common.handleError(this));
});

Expand Down
25 changes: 12 additions & 13 deletions test/functional/apps/visualize/_vertical_bar_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,17 @@ define(function (require) {
.then(function () {
return headerPage.getSpinnerDone(); // only matches the hidden spinner
})
.then(function sleep() {
return common.sleep(1000);
.then(function waitForVisualization() {
return visualizePage.waitForVisualization();
});
});

bdd.describe('vertical bar chart', function indexPatternCreation() {
var testSubName = 'VerticalBarChart';
var vizName1 = 'Visualization ' + testSubName;


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

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

bdd.it('should save and load', function pageHeader() {
return visualizePage.saveVisualization(vizName1)
.then(function (message) {
common.debug('Saved viz message = ' + message);
Expand All @@ -109,15 +105,14 @@ define(function (require) {
.then(function () {
return headerPage.getSpinnerDone(); // only matches the hidden spinner
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
.then(function waitForVisualization() {
return visualizePage.waitForVisualization();
})
.catch(common.handleError(this));
});


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

var expectedChartValues = [37, 202, 740, 1437, 1371, 751, 188, 31, 42, 202, 683,
1361, 1415, 707, 177, 27, 32, 175, 707, 1408, 1355, 726, 201, 29
Expand All @@ -135,6 +130,10 @@ define(function (require) {
common.debug('data.length=' + data.length);
expect(data).to.eql(expectedChartValues);
})
.then(function takeScreenshot() {
common.debug('Take screenshot');
common.saveScreenshot('./screenshot-' + testSubName + '.png');
})
.catch(common.handleError(this));
});

Expand Down
1 change: 1 addition & 0 deletions test/intern.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ define(function (require) {
}
},
timeouts: {
// this is how long a test can run before timing out
default: 90000
},
}, serverConfig);
Expand Down
Loading