Issue #803 - Add integration test for single png export

This commit is contained in:
juliandescottes 2018-06-09 14:43:27 +02:00 committed by Julian Descottes
parent 8662ab65ad
commit 27497313ff
2 changed files with 26 additions and 5 deletions

View File

@ -130,3 +130,10 @@ function setPiskelFromImageSrc(src) {
});\
}');
}
function beforeTest() {
// Cleanup local storage.
casper.evaluate(function() {
localStorage.clear();
}, {});
}

View File

@ -1,9 +1,12 @@
/* globals casper, setPiskelFromGrid, isDrawerExpanded, getValue, isChecked,
evalLine, waitForEvent, piskelFrameEqualsGrid, replaceFunction, setPiskelFromImageSrc */
casper.test.begin('PNG export test, with 2x scaling', 16, function(test) {
test.timeout = test.fail.bind(test, ['Test timed out']);
// PNG export will be tested with single frame export and spritesheet export.
// This global variable will be set before starting each test.
var testButtonClass;
casper.test.begin('PNG export test, with 2x scaling', 32, function(test) {
test.timeout = test.fail.bind(test, ['Test timed out']);
function onTestStart() {
test.assertExists('#drawing-canvas-container canvas', 'Piskel ready, test starting');
@ -59,8 +62,8 @@ casper.test.begin('PNG export test, with 2x scaling', 16, function(test) {
test.assertEquals(getValue('[name="resize-height"]'), "4", 'Resize height is 4px');
test.assertEquals(getValue('[name="resize-height"]'), "4", 'Resize height is 4px');
casper.echo('Clicking on Download PNG button');
casper.click('.png-download-button');
casper.echo('Clicking on the export button');
casper.click(testButtonClass);
casper.echo('Wait for #casper-imagedata-ready');
casper.waitForSelector('#casper-imagedata-ready', onImageDataReady, test.timeout, 10000);
@ -111,9 +114,20 @@ casper.test.begin('PNG export test, with 2x scaling', 16, function(test) {
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
casper.echo("URL loaded");
casper.echo("Test with spritesheet PNG export");
beforeTest();
testButtonClass = '.png-download-button';
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.then(function () {
casper.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
casper.echo("Test with single frame PNG export");
beforeTest();
testButtonClass = '.selected-frame-download-button';
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
})
.run(function () {
test.done();
});