Updated smoke test to try in build server

This commit is contained in:
Robin Ward 2015-11-06 14:09:03 -05:00
parent acecfeb37f
commit 7baed4eb51

View file

@ -25,9 +25,9 @@ page.onInitialized = function() {
});
};
// page.onConsoleMessage = function(msg) {
// console.log(msg);
// }
page.onConsoleMessage = function(msg) {
console.log(msg);
}
page.waitFor = function(desc, fn, cb) {
var start = +new Date();
@ -45,6 +45,7 @@ page.waitFor = function(desc, fn, cb) {
} else {
if (diff > TIMEOUT) {
console.log("FAILED: " + desc + " - " + diff + "ms");
page.render('/tmp/failed.png');
cb(false);
} else {
setTimeout(check, 25);
@ -58,27 +59,31 @@ page.waitFor = function(desc, fn, cb) {
var actions = [];
var test = function(desc, fn) {
function test(desc, fn) {
actions.push({ test: fn, desc: desc });
};
var exec = function(desc, fn) {
function wait(delay) {
actions.push({ wait: delay });
}
function exec(desc, fn) {
actions.push({ exec: fn, desc: desc });
};
var execAsync = function(desc, delay, fn) {
function execAsync(desc, delay, fn) {
actions.push({ execAsync: fn, delay: delay, desc: desc });
};
var upload = function(input, path) {
function upload(input, path) {
actions.push({ upload: path, input: input });
};
// var screenshot = function(filename) {
// actions.push({ screenshot: filename });
// }
function screenshot(filename) {
actions.push({ screenshot: filename });
}
var run = function() {
function run() {
var allPassed = true;
var done = function() {
@ -115,6 +120,11 @@ var run = function() {
console.log("SCREENSHOT: " + action.screenshot);
page.render(action.screenshot);
performNextAction();
} else if (action.wait) {
console.log("WAIT: " + action.wait + "ms");
setTimeout(function() {
performNextAction();
}, action.wait);
}
}
};
@ -172,17 +182,36 @@ var runTests = function() {
return document.querySelector(".current-user");
});
exec("go home", function() {
$('#site-logo').click();
});
test("it shows a topic list", function() {
return document.querySelector(".topic-list");
});
exec("open composer", function() {
$("#create-topic").click();
});
test('the editor is visible', function() {
return document.querySelector(".d-editor");
});
exec("compose new topic", function() {
var date = " (" + (+new Date()) + ")",
title = "This is a new topic" + date,
post = "I can write a new topic inside the smoke test!" + date + "\n\n";
$("#create-topic").click();
$("#reply-title").val(title).trigger("change");
$("#reply-control .d-editor-input").val(post).trigger("change");
$("#reply-control .d-editor-input").focus()[0].setSelectionRange(post.length, post.length);
});
test("updates preview", function() {
return document.querySelector(".d-editor-preview p");
});
exec("open upload modal", function() {
$(".d-editor-button-bar .upload").click();
});
@ -192,6 +221,14 @@ var runTests = function() {
});
upload("#filename-input", "spec/fixtures/images/large & unoptimized.png");
test("the file is inserted into the input", function() {
return document.getElementById('filename-input').files.length
});
screenshot('/tmp/upload-modal.png');
test("upload modal is open", function() {
return document.querySelector("#filename-input");
});
exec("click upload button", function() {
$(".modal .btn-primary").click();
@ -238,7 +275,9 @@ var runTests = function() {
run();
};
phantom.clearCookies();
page.open(system.args[1], function() {
page.evaluate(function() { localStorage.clear(); });
console.log("OPENED: " + system.args[1]);
runTests();
});