From 8bd9ad8847d98f81ee7c3171cb5f89fb696ee15d Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 1 Jun 2017 10:23:50 +0200 Subject: [PATCH] add automated registration test --- www/register/main.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/www/register/main.js b/www/register/main.js index 7d14dc02a..b53a142f1 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -2,8 +2,9 @@ define([ 'jquery', '/common/login.js', '/common/cryptpad-common.js', - '/common/credential.js' // preloaded for login.js -], function ($, Login, Cryptpad) { + '/common/test.js', + '/common/credential.js', // preloaded for login.js +], function ($, Login, Cryptpad, Test) { var Messages = Cryptpad.Messages; $(function () { @@ -63,6 +64,11 @@ define([ var $register = $('button#register'); var logMeIn = function (result) { + if (Test.testing) { + Test.passed(); + window.alert("Test passed!"); + return; + } localStorage.User_hash = result.userHash; var proxy = result.proxy; @@ -137,7 +143,6 @@ define([ case 'ALREADY_REGISTERED': Cryptpad.removeLoadingScreen(function () { Cryptpad.confirm(Messages.register_alreadyRegistered, function (yes) { - if (!yes) { return; } proxy.login_name = uname; if (!proxy[Cryptpad.displayNameKey]) { @@ -153,6 +158,9 @@ define([ } return; } + + if (Test.testing) { return void logMeIn(result); } + Cryptpad.eraseTempSessionValues(); if (shouldImport) { sessionStorage.migrateAnonDrive = 1; @@ -176,5 +184,18 @@ define([ $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); + }); }); });