Skip to content

Commit

Permalink
Issue #727 - update integration tests to wait for color service update
Browse files Browse the repository at this point in the history
  • Loading branch information
juliandescottes committed Oct 8, 2017
1 parent bf4cc33 commit 652027b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/casperjs/integration/settings/test-export-png.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ casper.test.begin('PNG export test', 13, function(test) {

test.assert(!isDrawerExpanded(), 'settings drawer is closed');

// Setup test Piskel
// Setup test Piskel
setPiskelFromGrid('['+
'[B, T],' +
'[T, B],' +
Expand Down
11 changes: 7 additions & 4 deletions test/casperjs/integration/settings/test-import-image-twice.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* globals casper, setPiskelFromGrid, isDrawerExpanded, getValue, isChecked,
evalLine, waitForEvent, replaceFunction, setPiskelFromImageSrc */

casper.test.begin('Double Image import test', 25, function(test) {
casper.test.begin('Double Image import test', 26, function(test) {
test.timeout = test.fail.bind(test, ['Test timed out']);

// Helper to retrieve the text content of the provided selector
Expand Down Expand Up @@ -54,18 +54,21 @@ casper.test.begin('Double Image import test', 25, function(test) {

test.assert(!isDrawerExpanded(), 'settings drawer is closed');

waitForEvent('PISKEL_RESET', onPiskelReset, test.timeout);

// 1x1 black pixel
var src = [
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcS',
'JAAAADUlEQVQYV2NgYGD4DwABBAEAcCBlCwAAAABJRU5ErkJggg=='
].join('');
setPiskelFromImageSrc(src);

// For this test the most important is that the color service picked up the color from the sprite
// since it drives which flow will be used for the import.
casper.waitForSelector('.palettes-list-color:nth-child(1)', onPiskelPaletteUpdated, test.timeout, 10000);
}

function onPiskelReset() {
function onPiskelPaletteUpdated() {
// Check the expected piskel was correctly loaded.
test.assertEquals(evalLine('pskl.app.currentColorsService.getCurrentColors().length'), 1, 'Has 1 color');
test.assertEquals(evalLine('pskl.app.piskelController.getPiskel().getWidth()'), 1, 'Piskel width is 1 pixel');
test.assertEquals(evalLine('pskl.app.piskelController.getPiskel().getHeight()'), 1, 'Piskel height is 1 pixel');

Expand Down
11 changes: 7 additions & 4 deletions test/casperjs/integration/settings/test-import-image.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* globals casper, setPiskelFromGrid, isDrawerExpanded, getValue, isChecked,
evalLine, waitForEvent, replaceFunction, setPiskelFromImageSrc */

casper.test.begin('Simple Image import test', 26, function(test) {
casper.test.begin('Simple Image import test', 27, function(test) {
test.timeout = test.fail.bind(test, ['Test timed out']);

// Helper to retrieve the text content of the provided selector
Expand Down Expand Up @@ -30,18 +30,21 @@ casper.test.begin('Simple Image import test', 26, function(test) {

test.assert(!isDrawerExpanded(), 'settings drawer is closed');

waitForEvent('PISKEL_RESET', onPiskelReset, test.timeout);

// 1x1 black pixel
var src = [
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcS',
'JAAAADUlEQVQYV2NgYGD4DwABBAEAcCBlCwAAAABJRU5ErkJggg=='
].join('');
setPiskelFromImageSrc(src);

// For this test the most important is that the color service picked up the color from the sprite
// since it drives which flow will be used for the import.
casper.waitForSelector('.palettes-list-color:nth-child(1)', onPiskelPaletteUpdated, test.timeout, 10000);
}

function onPiskelReset() {
function onPiskelPaletteUpdated() {
// Check the expected piskel was correctly loaded.
test.assertEquals(evalLine('pskl.app.currentColorsService.getCurrentColors().length'), 1, 'Has 1 color');
test.assertEquals(evalLine('pskl.app.piskelController.getPiskel().getWidth()'), 1, 'Piskel width is 1 pixel');
test.assertEquals(evalLine('pskl.app.piskelController.getPiskel().getHeight()'), 1, 'Piskel height is 1 pixel');

Expand Down

0 comments on commit 652027b

Please sign in to comment.