mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Updated smoke test to try in build server
This commit is contained in:
parent
acecfeb37f
commit
7baed4eb51
1 changed files with 51 additions and 12 deletions
|
@ -25,9 +25,9 @@ page.onInitialized = function() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// page.onConsoleMessage = function(msg) {
|
page.onConsoleMessage = function(msg) {
|
||||||
// console.log(msg);
|
console.log(msg);
|
||||||
// }
|
}
|
||||||
|
|
||||||
page.waitFor = function(desc, fn, cb) {
|
page.waitFor = function(desc, fn, cb) {
|
||||||
var start = +new Date();
|
var start = +new Date();
|
||||||
|
@ -45,6 +45,7 @@ page.waitFor = function(desc, fn, cb) {
|
||||||
} else {
|
} else {
|
||||||
if (diff > TIMEOUT) {
|
if (diff > TIMEOUT) {
|
||||||
console.log("FAILED: " + desc + " - " + diff + "ms");
|
console.log("FAILED: " + desc + " - " + diff + "ms");
|
||||||
|
page.render('/tmp/failed.png');
|
||||||
cb(false);
|
cb(false);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(check, 25);
|
setTimeout(check, 25);
|
||||||
|
@ -58,27 +59,31 @@ page.waitFor = function(desc, fn, cb) {
|
||||||
|
|
||||||
var actions = [];
|
var actions = [];
|
||||||
|
|
||||||
var test = function(desc, fn) {
|
function test(desc, fn) {
|
||||||
actions.push({ test: fn, desc: desc });
|
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 });
|
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 });
|
actions.push({ execAsync: fn, delay: delay, desc: desc });
|
||||||
};
|
};
|
||||||
|
|
||||||
var upload = function(input, path) {
|
function upload(input, path) {
|
||||||
actions.push({ upload: path, input: input });
|
actions.push({ upload: path, input: input });
|
||||||
};
|
};
|
||||||
|
|
||||||
// var screenshot = function(filename) {
|
function screenshot(filename) {
|
||||||
// actions.push({ screenshot: filename });
|
actions.push({ screenshot: filename });
|
||||||
// }
|
}
|
||||||
|
|
||||||
var run = function() {
|
function run() {
|
||||||
var allPassed = true;
|
var allPassed = true;
|
||||||
|
|
||||||
var done = function() {
|
var done = function() {
|
||||||
|
@ -115,6 +120,11 @@ var run = function() {
|
||||||
console.log("SCREENSHOT: " + action.screenshot);
|
console.log("SCREENSHOT: " + action.screenshot);
|
||||||
page.render(action.screenshot);
|
page.render(action.screenshot);
|
||||||
performNextAction();
|
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");
|
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() {
|
exec("compose new topic", function() {
|
||||||
var date = " (" + (+new Date()) + ")",
|
var date = " (" + (+new Date()) + ")",
|
||||||
title = "This is a new topic" + date,
|
title = "This is a new topic" + date,
|
||||||
post = "I can write a new topic inside the smoke test!" + date + "\n\n";
|
post = "I can write a new topic inside the smoke test!" + date + "\n\n";
|
||||||
|
|
||||||
$("#create-topic").click();
|
|
||||||
$("#reply-title").val(title).trigger("change");
|
$("#reply-title").val(title).trigger("change");
|
||||||
$("#reply-control .d-editor-input").val(post).trigger("change");
|
$("#reply-control .d-editor-input").val(post).trigger("change");
|
||||||
$("#reply-control .d-editor-input").focus()[0].setSelectionRange(post.length, post.length);
|
$("#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() {
|
exec("open upload modal", function() {
|
||||||
$(".d-editor-button-bar .upload").click();
|
$(".d-editor-button-bar .upload").click();
|
||||||
});
|
});
|
||||||
|
@ -192,6 +221,14 @@ var runTests = function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
upload("#filename-input", "spec/fixtures/images/large & unoptimized.png");
|
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() {
|
exec("click upload button", function() {
|
||||||
$(".modal .btn-primary").click();
|
$(".modal .btn-primary").click();
|
||||||
|
@ -238,7 +275,9 @@ var runTests = function() {
|
||||||
run();
|
run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
phantom.clearCookies();
|
||||||
page.open(system.args[1], function() {
|
page.open(system.args[1], function() {
|
||||||
|
page.evaluate(function() { localStorage.clear(); });
|
||||||
console.log("OPENED: " + system.args[1]);
|
console.log("OPENED: " + system.args[1]);
|
||||||
runTests();
|
runTests();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue