2017-06-10 10:55:38 +03:00
|
|
|
/* globals casper, setPiskelFromGrid, isDrawerExpanded, getValue, isChecked,
|
|
|
|
evalLine, waitForEvent, piskelFrameEqualsGrid, replaceFunction, setPiskelFromImageSrc */
|
|
|
|
|
2017-06-10 12:06:16 +03:00
|
|
|
casper.test.begin('Preferences settings panel test', 11, function(test) {
|
2017-06-10 10:55:38 +03:00
|
|
|
test.timeout = test.fail.bind(test, ['Test timed out']);
|
|
|
|
|
|
|
|
function onTestStart() {
|
|
|
|
test.assertExists('#drawing-canvas-container canvas', 'Piskel ready, test starting');
|
|
|
|
|
|
|
|
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
|
|
|
|
|
2017-06-10 12:06:16 +03:00
|
|
|
// Open preferences panel.
|
|
|
|
test.assertDoesntExist('.expanded .settings-section-preferences', 'Check if preferences panel is closed');
|
2017-06-10 10:55:38 +03:00
|
|
|
casper.click('[data-setting="user"]');
|
|
|
|
|
2017-06-10 12:06:16 +03:00
|
|
|
casper.waitForSelector('.expanded .settings-section-preferences', onPreferencesPanelReady, test.timeout, 10000);
|
2017-06-10 10:55:38 +03:00
|
|
|
}
|
|
|
|
|
2017-06-10 12:06:16 +03:00
|
|
|
function onPreferencesPanelReady() {
|
|
|
|
casper.echo('Preferences panel ready');
|
2017-06-10 10:55:38 +03:00
|
|
|
|
|
|
|
test.assert(isDrawerExpanded(), 'settings drawer is expanded');
|
2017-06-10 12:06:16 +03:00
|
|
|
test.assertExists('.expanded .settings-section-preferences',
|
|
|
|
'Check if preferences panel is opened');
|
2017-06-10 10:55:38 +03:00
|
|
|
|
2017-06-10 12:06:16 +03:00
|
|
|
test.assertExists('.preferences-panel-misc', 'Check if misc tab is rendered');
|
|
|
|
test.assertDoesntExist('.preferences-panel-grid', 'Check that grid tab is not rendered');
|
2017-06-10 10:55:38 +03:00
|
|
|
casper.click('[data-tab-id="grid"]');
|
|
|
|
casper.waitForSelector('[data-tab-id="grid"]', onGridTabSelected, test.timeout, 10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onGridTabSelected() {
|
|
|
|
casper.echo('Grid tab ready');
|
|
|
|
|
2017-06-10 12:06:16 +03:00
|
|
|
test.assertDoesntExist('.preferences-panel-tile', 'Check that tile tab is not rendered');
|
2017-06-10 10:55:38 +03:00
|
|
|
casper.click('[data-tab-id="tile"]');
|
|
|
|
casper.waitForSelector('[data-tab-id="tile"]', onTileTabSelected, test.timeout, 10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onTileTabSelected() {
|
|
|
|
casper.echo('Tile tab ready');
|
|
|
|
|
|
|
|
// Click on settings again to close the settings drawer.
|
|
|
|
casper.click('[data-setting="user"]');
|
|
|
|
casper.waitForSelector('[data-pskl-controller="settings"]:not(.expanded)', onDrawerClosed, test.timeout, 10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDrawerClosed() {
|
|
|
|
test.assert(!isDrawerExpanded(), 'settings drawer is closed');
|
|
|
|
// Open the settings again to check if the last tab is selected.
|
|
|
|
casper.click('[data-setting="user"]');
|
2017-06-10 12:06:16 +03:00
|
|
|
casper.waitForSelector('.expanded .settings-section-preferences', onPreferencesPanelExpandedAgain, test.timeout, 10000);
|
2017-06-10 10:55:38 +03:00
|
|
|
}
|
|
|
|
|
2017-06-10 12:06:16 +03:00
|
|
|
function onPreferencesPanelExpandedAgain() {
|
2017-06-10 10:55:38 +03:00
|
|
|
casper.echo('Tile tab ready');
|
2017-06-10 12:06:16 +03:00
|
|
|
test.assertExists('.preferences-panel-tile', 'Check if tile tab is selected');
|
2017-06-10 10:55:38 +03:00
|
|
|
|
|
|
|
// Close the panel a second time.
|
|
|
|
casper.click('[data-setting="user"]');
|
|
|
|
casper.waitForSelector('[data-pskl-controller="settings"]:not(.expanded)', onDrawerClosedAgain, test.timeout, 10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDrawerClosedAgain() {
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|