add automated registration test

pull/1/head
ansuz 8 years ago
parent 07279c8dc7
commit 8bd9ad8847

@ -2,8 +2,9 @@ define([
'jquery', 'jquery',
'/common/login.js', '/common/login.js',
'/common/cryptpad-common.js', '/common/cryptpad-common.js',
'/common/credential.js' // preloaded for login.js '/common/test.js',
], function ($, Login, Cryptpad) { '/common/credential.js', // preloaded for login.js
], function ($, Login, Cryptpad, Test) {
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
$(function () { $(function () {
@ -63,6 +64,11 @@ define([
var $register = $('button#register'); var $register = $('button#register');
var logMeIn = function (result) { var logMeIn = function (result) {
if (Test.testing) {
Test.passed();
window.alert("Test passed!");
return;
}
localStorage.User_hash = result.userHash; localStorage.User_hash = result.userHash;
var proxy = result.proxy; var proxy = result.proxy;
@ -137,7 +143,6 @@ define([
case 'ALREADY_REGISTERED': case 'ALREADY_REGISTERED':
Cryptpad.removeLoadingScreen(function () { Cryptpad.removeLoadingScreen(function () {
Cryptpad.confirm(Messages.register_alreadyRegistered, function (yes) { Cryptpad.confirm(Messages.register_alreadyRegistered, function (yes) {
if (!yes) { return; }
proxy.login_name = uname; proxy.login_name = uname;
if (!proxy[Cryptpad.displayNameKey]) { if (!proxy[Cryptpad.displayNameKey]) {
@ -153,6 +158,9 @@ define([
} }
return; return;
} }
if (Test.testing) { return void logMeIn(result); }
Cryptpad.eraseTempSessionValues(); Cryptpad.eraseTempSessionValues();
if (shouldImport) { if (shouldImport) {
sessionStorage.migrateAnonDrive = 1; sessionStorage.migrateAnonDrive = 1;
@ -176,5 +184,18 @@ define([
$dialog.find('> div').addClass('half'); $dialog.find('> div').addClass('half');
}); });
}); });
Test(function () {
$uname.val('test' + Math.random());
$passwd.val('test');
$confirm.val('test');
$checkImport[0].checked = true;
$checkAcceptTerms[0].checked = true;
$register.click();
window.setTimeout(function () {
Cryptpad.findOKButton().click()
}, 1000);
});
}); });
}); });

Loading…
Cancel
Save