Cleanup local storage before integration tests

This commit is contained in:
juliandescottes 2018-09-18 22:03:22 +02:00 committed by Julian Descottes
parent 52e49a1ed6
commit 99c060f4a7
18 changed files with 43 additions and 169 deletions

View file

@ -131,9 +131,24 @@ function setPiskelFromImageSrc(src) {
}');
}
function beforeTest() {
// Cleanup local storage.
casper.evaluate(function() {
localStorage.clear();
}, {});
/**
* Load the piskel website in debug mode and call the provided callback when ready.
*/
function startTest(test, callback) {
return casper
// Pass "integration-test" to avoid the "unsupported browser" dialog
.start(casper.cli.get('baseUrl')+"/?debug&integration-test")
.then(function () {
casper.echo("URL loaded");
casper.evaluate(function() {
localStorage.clear();
}, {});
casper.echo("Local storage cleaned");
casper.waitForSelector('#drawing-canvas-container canvas', callback, test.timeout, 20000);
})
.run(function () {
test.done();
});
}

View file

@ -55,13 +55,5 @@ casper.test.begin('Test palette switches to tiny mode if it contains more than 1
'Check that the palette colors container is not in tiny mode');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
casper.echo("URL loaded");
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -104,13 +104,5 @@ casper.test.begin('Simple GIF (<256 colors) export test, with 2x scaling', 18, f
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
casper.echo("URL loaded");
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -93,13 +93,5 @@ casper.test.begin('Simple GIF (<256 colors) export test', 14, function(test) {
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
casper.echo("URL loaded");
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -70,15 +70,7 @@ casper.test.begin('Complex GIF export test', 11, function(test) {
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
casper.echo("URL loaded");
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});
// Source for a base64 encoded PNG, 20x20, with 400 different colors.

View file

@ -111,24 +111,11 @@ casper.test.begin('PNG export test, with 2x scaling', 32, function(test) {
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
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();
});
casper.echo("Test with spritesheet PNG export");
testButtonClass = '.png-download-button';
startTest(test, onTestStart).then(function () {
casper.echo("Test with single frame PNG export");
testButtonClass = '.selected-frame-download-button';
startTest(test, onTestStart);
});
});

View file

@ -97,13 +97,5 @@ casper.test.begin('PNG export test', 13, function(test) {
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
casper.echo("URL loaded");
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -93,13 +93,5 @@ casper.test.begin('Image import test with an empty current sprite', 16, function
test.assertEquals(evalLine('pskl.app.piskelController.getFrameCount()'), 1, 'Piskel has 1 frame');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug&integration-test")
.then(function () {
casper.echo("URL loaded");
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -183,13 +183,5 @@ casper.test.begin('Double Image import test', 26, function(test) {
test.assertEquals(evalLine('pskl.app.piskelController.getFrameCount()'), 1, 'Piskel has 1 frame');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug&integration-test")
.then(function () {
casper.echo("URL loaded");
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -139,13 +139,5 @@ casper.test.begin('Simple Image import test', 27, function(test) {
test.assertEquals(evalLine('pskl.app.piskelController.getFrameCount()'), 1, 'Piskel has 1 frame');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug&integration-test")
.then(function () {
casper.echo("URL loaded");
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -65,13 +65,5 @@ casper.test.begin('Preferences settings panel test', 11, function(test) {
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
casper.echo("URL loaded");
casper.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -65,13 +65,5 @@ casper.test.begin('Test resize feature works, and check the output', 19, functio
]', 0, 0), 'Resized piskel content is as expected');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
this.echo("URL loaded");
this.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -66,13 +66,5 @@ casper.test.begin('Test resize content works, and check the output', 18, functio
]', 0, 0), 'Resized piskel content is as expected');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
this.echo("URL loaded");
this.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -49,13 +49,5 @@ casper.test.begin('Test updating default size works', 14 , function(test) {
322, 'Piskel height is now 322 pixels');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
this.echo("URL loaded");
this.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -85,13 +85,5 @@ casper.test.begin('Test resize panel width/height inputs are synchronized', 28 ,
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
this.echo("URL loaded");
this.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -74,13 +74,5 @@ casper.test.begin('Test resize feature works, and check the output', 20, functio
]', 0, 0), 'Resized piskel content is as expected');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
this.echo("URL loaded");
this.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -51,13 +51,5 @@ casper.test.begin('Test resize feature works', 16 , function(test) {
test.assertEquals(evalLine('pskl.app.piskelController.getPiskel().getHeight()'), 320, 'Piskel height is now 320 pixels');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
this.echo("URL loaded");
this.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});

View file

@ -71,13 +71,5 @@ casper.test.begin('Settings Test', 18, function(test) {
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
}
casper
.start(casper.cli.get('baseUrl')+"/?debug")
.then(function () {
this.echo("URL loaded");
this.waitForSelector('#drawing-canvas-container canvas', onTestStart, test.timeout, 20000);
})
.run(function () {
test.done();
});
startTest(test, onTestStart);
});