diff --git a/LesionTracker/tests/nightwatch/.npmignore b/LesionTracker/tests/nightwatch/.npmignore new file mode 100644 index 000000000..27a3afbbc --- /dev/null +++ b/LesionTracker/tests/nightwatch/.npmignore @@ -0,0 +1 @@ +reports diff --git a/LesionTracker/tests/nightwatch/assertions/sampleAssertion.js b/LesionTracker/tests/nightwatch/assertions/sampleAssertion.js new file mode 100644 index 000000000..e720f80f8 --- /dev/null +++ b/LesionTracker/tests/nightwatch/assertions/sampleAssertion.js @@ -0,0 +1,4 @@ +exports.assertion = function() { + + return this; // allows the command to be chained. +}; diff --git a/LesionTracker/tests/nightwatch/commands/actions/sampleAction.js b/LesionTracker/tests/nightwatch/commands/actions/sampleAction.js new file mode 100644 index 000000000..bb0506876 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/actions/sampleAction.js @@ -0,0 +1,4 @@ +exports.command = function() { + + return this; +}; diff --git a/LesionTracker/tests/nightwatch/commands/api/entry/reviewSignInPage.js b/LesionTracker/tests/nightwatch/commands/api/entry/reviewSignInPage.js new file mode 100644 index 000000000..e6c6c1520 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/api/entry/reviewSignInPage.js @@ -0,0 +1,15 @@ +exports.command = function(username, password) { + this + .waitForElementVisible('#entrySignIn', 1000) + .verify.elementPresent("#signInPageTitle") + .verify.elementPresent("#signInPageMessage") + .verify.elementPresent("#signInPageEmailInput") + .verify.elementPresent("#signInPagePasswordInput") + .verify.elementPresent("#signInToAppButton") + .verify.elementPresent("#needAnAccountButton") + + .verify.containsText("#signInPageTitle", "Sign In") + .verify.containsText("#signInPageMessage", "Improve your clincal practice with checklists.") + + return this; // allows the command to be chained. +}; diff --git a/LesionTracker/tests/nightwatch/commands/api/entry/reviewSignUpPage.js b/LesionTracker/tests/nightwatch/commands/api/entry/reviewSignUpPage.js new file mode 100644 index 000000000..a3b661b87 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/api/entry/reviewSignUpPage.js @@ -0,0 +1,11 @@ +exports.command = function(username, password) { + this + .waitForElementVisible('#entrySignUp', 1000) + .verify.elementPresent("#signUpPageEmailInput") + .verify.elementPresent("#signUpPagePasswordInput") + .verify.elementPresent("#signUpPagePasswordConfirmInput") + + .verify.elementPresent("#signUpPageJoinNowButton") + + return this; // allows the command to be chained. +}; diff --git a/LesionTracker/tests/nightwatch/commands/api/entry/signIn.js b/LesionTracker/tests/nightwatch/commands/api/entry/signIn.js new file mode 100644 index 000000000..37d77a2fc --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/api/entry/signIn.js @@ -0,0 +1,14 @@ +exports.command = function(username, password) { + + this + .waitForElementVisible('#entrySignIn', 1000) + .verify.elementPresent("#signInPageEmailInput") + .verify.elementPresent("#signInPagePasswordInput") + + .setValue("#signInPageEmailInput", username) + .setValue("#signInPagePasswordInput", password) + + .click("#signInToAppButton").pause(1000) + + return this; // allows the command to be chained. +}; diff --git a/LesionTracker/tests/nightwatch/commands/api/entry/signOut.js b/LesionTracker/tests/nightwatch/commands/api/entry/signOut.js new file mode 100644 index 000000000..909787c54 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/api/entry/signOut.js @@ -0,0 +1,8 @@ +exports.command = function(email, password) { + + this + .verify.elementPresent("#logoutButton") + .click("#logoutButton").pause(500) + + return this; // allows the command to be chained. +}; diff --git a/LesionTracker/tests/nightwatch/commands/api/entry/signUp.js b/LesionTracker/tests/nightwatch/commands/api/entry/signUp.js new file mode 100644 index 000000000..6e2634289 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/api/entry/signUp.js @@ -0,0 +1,23 @@ +exports.command = function(email, password) { + + this + .waitForElementVisible('#entrySignUp', 1000) + .verify.elementPresent("#signUpPageEmailInput") + .verify.elementPresent("#signUpPagePasswordInput") + .verify.elementPresent("#signUpPagePasswordConfirmInput") + + .clearValue("#signUpPageEmailInput") + .clearValue("#signUpPagePasswordInput") + .clearValue("#signUpPagePasswordConfirmInput") + + // .setValue("#signUpPageUsernameInput", "Jane Doe") + .setValue("#signUpPageEmailInput", email) + .setValue("#signUpPagePasswordInput", password) + .setValue("#signUpPagePasswordConfirmInput", password) + + .click("#signUpPageJoinNowButton").pause(200) + + + + return this; // allows the command to be chained. +}; diff --git a/LesionTracker/tests/nightwatch/commands/api/meteor/callMeteorMethod.js b/LesionTracker/tests/nightwatch/commands/api/meteor/callMeteorMethod.js new file mode 100644 index 000000000..629933fe9 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/api/meteor/callMeteorMethod.js @@ -0,0 +1,21 @@ +// async version calls method on the server +exports.command = function(methodName, timeout) { + var client = this; + if (!timeout) { + timeout = 5000; + } + + this + .timeoutsAsyncScript(timeout) + .executeAsync(function(data, meteorCallback){ + //return HipaaLogger.logEventObject(data); + Meteor.call(methodName, data, function(meteorError, meteorResult){ + var response = (meteorError ? { error: meteorError } : { result: meteorResult }); + meteorCallback(response); + }) + }, [hipaaEvent], function(result){ + console.log("result.value", result.value); + client.assert.ok(result.value); + }).pause(1000) + return this; +}; diff --git a/LesionTracker/tests/nightwatch/commands/api/meteor/checkSession.js b/LesionTracker/tests/nightwatch/commands/api/meteor/checkSession.js new file mode 100644 index 000000000..2696db638 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/api/meteor/checkSession.js @@ -0,0 +1,40 @@ +/*exports.command = function(sessionName, expectedValue, timeout, callback) { + + var self = this; + if (!timeout) { + timeout = 5000; + } + + var glassOpacity = false; + + this + .timeoutsAsyncScript(timeout) + .executeAsync(function (data, callback) { + return Session.get('glassOpacity'); + }, [''], function (response) { // you need to pass an ARRAY of ONE argument, must be a bug + if (response.value.error) { + throw 'Meteor apply (call) returned an error: ' + response.value.error; + } else if (typeof callback === 'function') { + callback.call(self); + } + }) + return this; +};*/ + + + + +// syncrhonous version; only works for checking javascript objects on client +exports.command = function(sessionVarName, expectedValue) { + var client = this; + this + .execute(function(data){ + return Session.get(data); + }, [sessionVarName], function(result){ + client.assert.ok(result.value); + if(expectedValue){ + client.assert.equal(result.value, expectedValue); + } + }).pause(1000) + return this; +}; diff --git a/LesionTracker/tests/nightwatch/commands/components/reviewMainLayout.js b/LesionTracker/tests/nightwatch/commands/components/reviewMainLayout.js new file mode 100644 index 000000000..33e06a408 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/components/reviewMainLayout.js @@ -0,0 +1,10 @@ +exports.command = function(username, password) { + this + .verify.elementPresent("#appBody") + .verify.elementPresent("#navbarHeader") + .verify.elementPresent("#contentContainer") + .verify.elementPresent("#contentContainer .content-scrollable") + .verify.elementPresent("#navbarFooter") + + return this; // allows the command to be chained. +}; diff --git a/LesionTracker/tests/nightwatch/commands/methods/objectMethod.js b/LesionTracker/tests/nightwatch/commands/methods/objectMethod.js new file mode 100644 index 000000000..d3ac064d9 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/methods/objectMethod.js @@ -0,0 +1,22 @@ +// async version calls method on the server +exports.command = function(methodName, timeout) { + /*var client = this; + if (!timeout) { + timeout = 5000; + } + + this + .timeoutsAsyncScript(timeout) + .executeAsync(function(data, meteorCallback){ + //return HipaaLogger.logEventObject(data); + Meteor.call(methodName, data, function(meteorError, meteorResult){ + var response = (meteorError ? { error: meteorError } : { result: meteorResult }); + meteorCallback(response); + }) + }, [hipaaEvent], function(result){ + console.log("result.value", result.value); + client.assert.ok(result.value); + }).pause(1000) + return this;*/ + return this; +}; diff --git a/LesionTracker/tests/nightwatch/commands/sectionBreak.js b/LesionTracker/tests/nightwatch/commands/sectionBreak.js new file mode 100644 index 000000000..084597d3a --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/sectionBreak.js @@ -0,0 +1,9 @@ +exports.command = function(input, callback) { + + this + .frame(null) + .waitForElementVisible("body", 1000, "=============================================================") + .verify.elementPresent("body", "== " + input) + + return this; // allows the command to be chained. +}; diff --git a/LesionTracker/tests/nightwatch/commands/waitForPage.js b/LesionTracker/tests/nightwatch/commands/waitForPage.js new file mode 100644 index 000000000..0b1ddc845 --- /dev/null +++ b/LesionTracker/tests/nightwatch/commands/waitForPage.js @@ -0,0 +1,7 @@ +exports.command = function(pageId) { + + this + .waitForElementVisible(pageId, 3000) + + return this; // allows the command to be chained. +}; diff --git a/LesionTracker/tests/nightwatch/globals.json b/LesionTracker/tests/nightwatch/globals.json new file mode 100644 index 000000000..d41eedcb1 --- /dev/null +++ b/LesionTracker/tests/nightwatch/globals.json @@ -0,0 +1,8 @@ +{ + "default" : { + "myGlobal" : 1 + }, + "test_env" : { + "myGlobal" : 2 + } +} diff --git a/LesionTracker/tests/nightwatch/logs/selenium-debug.log b/LesionTracker/tests/nightwatch/logs/selenium-debug.log new file mode 100644 index 000000000..ecf814651 --- /dev/null +++ b/LesionTracker/tests/nightwatch/logs/selenium-debug.log @@ -0,0 +1 @@ +hh:mm:ss.sss INFO - Initializing debug log diff --git a/LesionTracker/tests/nightwatch/unittests/foo.js b/LesionTracker/tests/nightwatch/unittests/foo.js new file mode 100644 index 000000000..389292aaa --- /dev/null +++ b/LesionTracker/tests/nightwatch/unittests/foo.js @@ -0,0 +1,34 @@ +//var Utils = require('lib/util/utils.js'); +module.exports = { + testTrue: function(client){ + client.assert.equal(true, true); + } + /*testFormatElapsedTime : function(client) { + var test = client.assert; + + var resultMs = Utils.formatElapsedTime(999); + var resultSec = Utils.formatElapsedTime(1999); + var resultMin = Utils.formatElapsedTime(122299, true); + + test.equal(resultMs, '999ms'); + test.equal(resultSec, '1.999s'); + test.equal(resultMin, '2m 2s / 122299ms'); + }, + + testMakeFnAsync : function(client) { + function asynFn(done) { + done(); + } + + function syncFn() {} + + var test = client.assert; + + test.equal(Utils.makeFnAsync(1, asynFn), asynFn); + + var convertedFn = Utils.makeFnAsync(1, syncFn); + convertedFn(function() { + test.ok('converted fn called'); + }); + }*/ +}; diff --git a/LesionTracker/tests/nightwatch/walkthroughs/appLayout.js b/LesionTracker/tests/nightwatch/walkthroughs/appLayout.js new file mode 100644 index 000000000..a2122614a --- /dev/null +++ b/LesionTracker/tests/nightwatch/walkthroughs/appLayout.js @@ -0,0 +1,14 @@ +// add tests to this file using the Nightwatch.js API +// http://nightwatchjs.org/api + +module.exports = { + "Layout & Static Pages" : function (client) { + client + .url("http://localhost:3000") + .resizeWindow(1024, 768) + .verify.elementPresent("body") + + + .end(); + } +};