Add Clinical Meteor packages to Lesion Tracker

This commit is contained in:
Erik Ziegler committed 2016-01-25 17:14:42 +01:00
1 parent 383b4ff4c0
commit b2fa6ead3b
56 files changed
+2355 -9

No files matched your search

@@ -0,0 +1,197 @@
// var nightwatch = require('nightwatch');
describe('clinical:active-entry', function () {
var server = meteor();
var client = browser(server);
// before(function () {
// return server.promise(function (resolve){
// Meteor.users.find().forEach(function(user){
// Meteor.users.remove({_id: user._id});
// }, function(){
// resolve();
// });
// });
// });
// afterEach(function (){
// return client.promise(function (resolve){
// Meteor.logout(function(error, result){
// resolve();
// });
// });
// });
it("ActiveEntry object should be loaded on client and server", function () {
return server.execute(function () {
expect(ActiveEntry.isAbc()).to.equal('abc');
}).then(function (data){
return client.execute(function (a) {
expect(ActiveEntry.isAbc()).to.equal('abc');
});
});
});
it("Error messages should be empty by default", function () {
return client.execute(function () {
expect(ActiveEntry.errorMessages.get('signInError')).to.equal(false);
});
});
// ActiveEntry.verifyEmail
it('Email validation confirms it is a properly formatted email.', function () {
return client.execute(function (a) {
ActiveEntry.verifyEmail('janedoe@somewhere.com');
expect(ActiveEntry.errorMessages.get('email')).to.equal("Email present");
ActiveEntry.verifyEmail('');
expect(ActiveEntry.errorMessages.get('email')).to.equal("Email is required");
ActiveEntry.verifyEmail('janedoe.somewhere.com');
expect(ActiveEntry.errorMessages.get('email')).to.equal("Email is poorly formatted");
});
});
// ActiveEntry.verifyPassword
it('Password validation confirms it is a properly formatted password.', function () {
return client.execute(function (a) {
ActiveEntry.verifyPassword('');
expect(ActiveEntry.errorMessages.get('password')).to.equal("Password is required");
ActiveEntry.verifyPassword('kittens');
expect(ActiveEntry.errorMessages.get('password')).to.equal("Password is weak");
ActiveEntry.verifyPassword('kittens123');
expect(ActiveEntry.errorMessages.get('password')).to.equal("Password present");
});
});
// ActiveEntry.verifyConfirmPassword
it('Password match validation confirms that two passwords are the same.', function () {
return client.execute(function (a) {
ActiveEntry.verifyConfirmPassword('kittens123', '');
expect(ActiveEntry.errorMessages.get('confirm')).to.equal("Password is required");
ActiveEntry.verifyConfirmPassword('kittens123', 'kittens');
expect(ActiveEntry.errorMessages.get('confirm')).to.equal("Password is weak");
ActiveEntry.verifyConfirmPassword('kittens123', 'kittens123');
expect(ActiveEntry.errorMessages.get('confirm')).to.equal("Passwords match");
});
});
// ActiveEntry.verifyFullName
it('Fullname validation confirms that at least a first and last name are entered.', function () {
return client.execute(function (a) {
ActiveEntry.verifyFullName('');
expect(ActiveEntry.errorMessages.get('fullName')).to.equal("Name is required");
ActiveEntry.verifyFullName('Jane');
expect(ActiveEntry.errorMessages.get('fullName')).to.equal("Name is probably not complete");
ActiveEntry.verifyFullName('Jane Doe');
expect(ActiveEntry.errorMessages.get('fullName')).to.equal("Name present");
});
});
// ActiveEntry.signIn
it('Newly created user record should have role, profile, and name set.', function () {
return client.execute(function () {
ActiveEntry.signUp('janedoe@test.org', 'janedoe123', 'janedoe123', 'Jane Doe');
expect(ActiveEntry.errorMessages.get('fullName')).to.equal("Name present");
}).then(function (){
return server.wait(300, 'until account is created on the server', function () {
return Meteor.users.findOne({'emails.address': 'janedoe@test.org'});
}).then(function (user){
expect(user.role).to.equal('user');
expect(user.profile.fullName).to.equal('Jane Doe');
});
});
});
it("Newly created user should have fullName(), preferredName(), and familyName() methods.", function () {
return server.execute(function () {
var user = Meteor.users.findOne({'emails.address': 'janedoe@test.org'});
expect(user).to.be.ok;
expect(user.fullName()).to.equal('Jane Doe');
expect(user.givenName()).to.equal('Jane');
expect(user.familyName()).to.equal('Doe');
}).then(function(){
// client.wait(500, "until user is logged out", function(){
// Meteor.logout();
// });
return client.promise(function (resolve){
Meteor.logout(function(error, result){
resolve();
});
});
});
});
it("Newly created user can sign in to the application.", function () {
return client.execute(function () {
expect(Meteor.userId()).to.not.exist;
ActiveEntry.signIn('janedoe@test.org', 'janedoe123');
}).then(function (){
client.wait(3000, "for user to sign in", function (){
expect(Meteor.userId()).to.exist;
});
});
});
it("Newly created user can sign out of the application.", function () {
return client.execute(function () {
expect(Meteor.userId()).to.not.exist;
ActiveEntry.signIn('janedoe@test.org', 'janedoe123');
}).then(function (){
client.wait(3000, "for user to sign in", function (){
expect(Meteor.userId()).to.exist;
ActiveEntry.signOut('janedoe@test.org');
}).then(function (){
expect(Meteor.userId()).to.not.exist;
});
});
});
// it("config should be able to change company logo", function () {
//
// });
// it("config should be able to change entry message text", function () {
//
// });
// it("new user should be able to register on desktop", function () {
// client.location = "/sign-in";
//
// client.execute(function () {
// expect($('#entrySignIn')).to.exist();
// expect($('#signInPageEmailInput')).to.exist();
// expect($('#signInPagePasswordInput')).to.exist();
// expect($('#signInToAppButton')).to.exist();
// }).setValue('#signInPageEmailInput', 'house@test.org')
// .setValue('#signInPagePasswordInput', 'house@test.org')
// .click('#signInToAppButton').execute(function(){
// expect($('#entrySignIn')).to.exist();
// expect($('#signInPageEmailInput')).to.exist();
// expect($('#signInPagePasswordInput')).to.exist();
// expect($('#signInToAppButton')).to.exist();
// // expect($('#entrySignIn')).to.not.exist();
// // expect($('#signInPageEmailInput')).to.not.exist();
// // expect($('#signInPagePasswordInput')).to.not.exist();
// // expect($('#signInToAppButton')).to.not.exist();
// });
// // .then(function(data){
// // return server.execute(3000, 'until the account is created', function () {
// // expect(Meteor.users.find().count()).to.be.above(20);
// // });
// // });
// });
});
@@ -0,0 +1,22 @@
// async version calls method on the server
exports.command = function () {
var client = this;
this
.timeoutsAsyncScript(5000)
.executeAsync(function (data, meteorCallback) {
//return HipaaLogger.logEventObject(data);
Meteor.call("dropCollaborations", data, function (meteorError, meteorResult) {
var response = (meteorError ? {
error: meteorError
} : {
result: meteorResult
});
meteorCallback(response);
});
}, [], function (result) {
console.log("result.value", result.value);
client.assert.ok(result.value);
}).pause(1000);
return this;
};
@@ -0,0 +1,184 @@
// when new user fills out form and registers, new user should get created
// when user signs in with username and password, should redirect to home page
// newly created user record should have role
// newly created user record should have profile
// newly created user record should have full, preferred, and family name
// user object should return first name
// user object should return last name
// user should be able to request reset password email
// user should be able to request be able to create new account
// guest should be notified if username already exists
// guest should be notified if passwords do not match
// guest should be notified if email is not correctly formatted
// new user should be able to register on desktop
// new user should be able to register on tablet
// existing user should be able to sign in on desktop
// existing user should be able to sign in on tablet
// existing user should be able to sign in on phone
// company logo should display on sign//in page
module.exports = {
tags: ['users', 'entry'],
before: function(client){
client
.url("http://localhost:3000/entrySignUp")
.initializeUsers()
.resizeWindow(1024, 768)
},
"new user should be able to register on desktop" : function (client) {
client
.verify.elementPresent("#entrySignUp")
.verify.elementPresent("#signUpPageTitle")
.verify.elementPresent("#signUpPageMessage")
.verify.elementPresent("#signUpPageEmailInput")
.verify.elementPresent("#signUpPagePasswordInput")
.verify.elementPresent("#signUpPageJoinNowButton")
.verify.elementPresent("#signUpPageSignInButton")
},
"company logo should display on sign-in page" : function (client) {
client
.verify.elementPresent("#entrySignUp")
.verify.elementPresent("#entryAppLogo")
},
"user should be able to request be able to create new account" : function (client) {
client.verify.elementPresent("#signUpPageEmailInput")
.verify.elementPresent("#signUpPagePasswordInput")
.verify.elementPresent("#signUpPagePasswordInput")
.verify.elementPresent("#signUpPageJoinNowButton")
},
"guest should be notified if password is insecure" : function (client) {
client
.clearValue("input")
.verify.elementPresent("#signUpPagePasswordInput")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid gray')
.setValue("#signUpPagePasswordInput", "jan")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid rgb(242, 222, 222)')
.setValue("#signUpPagePasswordInput", "icedoe123")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid green')
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid gray')
.setValue("#signUpPagePasswordConfirmInput", "ja")
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid rgb(242, 222, 222)')
.clearValue("#signUpPagePasswordConfirmInput")
.setValue("#signUpPagePasswordConfirmInput", "janicedoe123")
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid green')
},
"guest should be notified if passwords do not match" : function (client) {
client
.clearValue("#signUpPagePasswordConfirmInput")
.clearValue("#signUpPagePasswordInput")
.resetEntry()
.pause(500)
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid gray')
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid gray')
.setValue("#signUpPagePasswordInput", "janicedoe123")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid green')
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid gray')
.setValue("#signUpPagePasswordConfirmInput", "janicedoe123")
.verify.cssProperty('#signUpPagePasswordInput', 'border', '1px solid green')
.verify.cssProperty('#signUpPagePasswordConfirmInput', 'border', '1px solid green')
},
"guest should be notified if email is not correctly formatted" : function (client) {
client
.clearValue("#signUpPageEmailInput")
.resetEntry()
.verify.elementPresent("#signUpPageEmailInput")
.verify.cssProperty('#signUpPageEmailInput', 'border', '1px solid gray')
.setValue("#signUpPageEmailInput", "janicedoe")
.verify.cssProperty('#signUpPageEmailInput', 'border', '1px solid rgb(242, 222, 222)')
.setValue("#signUpPageEmailInput", "@symptomatic.io")
.verify.cssProperty('#signUpPageEmailInput', 'border', '1px solid green')
},
"when new user fills out form and registers, new user should get created" : function (client) {
client
.verify.elementPresent("#entrySignUp")
.clearValue("#signUpPagePasswordConfirmInput")
.clearValue("#signUpPagePasswordInput")
.clearValue("#signUpPageFullNameInput")
.clearValue("#signUpPageEmailInput")
.resetEntry()
.setValue("#signUpPageFullNameInput", "Janice Doe")
.setValue("#signUpPageEmailInput", "janicedoe@symptomatic.io")
.setValue("#signUpPagePasswordInput", "janicedoe123")
.setValue("#signUpPagePasswordConfirmInput", "janicedoe123")
.click("#signUpPageJoinNowButton").pause(1000)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io")
},
"user should be able to signout" : function (client) {
client
.verify.elementPresent("#logoutButton")
.click("#logoutButton").pause(300)
.verify.containsText("#usernameLink", "Sign In")
},
"user should be able to request reset password email" : function (client) {
client
.url("http://localhost:3000/entrySignIn")
.verify.elementPresent("#forgotPasswordButton")
.click("#forgotPasswordButton")
.verify.elementPresent("#forgotPassword")
.verify.elementPresent("#signInPageEmailInput")
.verify.elementPresent("#sendReminderButton")
},
"existing user should be able to sign in on desktop" : function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(1600, 1200)
.verify.containsText("#usernameLink", "Sign In")
.signIn("janicedoe@symptomatic.io", "janicedoe123").pause(500)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io")
.click("#logoutButton").pause(200)
.verify.containsText("#usernameLink", "Sign In")
},
"existing user should be able to sign in on tablet" : function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(1024, 768)
.verify.containsText("#usernameLink", "Sign In")
.signIn("janicedoe@symptomatic.io", "janicedoe123").pause(500)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io")
.click("#logoutButton").pause(200)
.verify.containsText("#usernameLink", "Sign In")
},
"existing user should be able to sign in on phone" : function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(320, 960)
// .verify.containsText("#usernameLink", "Sign In")
.signIn("janicedoe@symptomatic.io", "janicedoe123").pause(500)
.click("#sidebarToggle").pause(300)
.verify.containsText("#usernameLink", "janicedoe@symptomatic.io")
.click("#logoutButton").pause(200)
.verify.containsText("#usernameLink", "Sign In")
},
"if anonymous user tries to log in with non-existing account, a message is shown" : function (client) {
client
.url("http://localhost:3000/entrySignIn")
.resizeWindow(1024, 768)
.signIn("alice@symptomatic.io", "alice123").pause(500)
.verify.containsText("#signInPageMessage", "User not found [403]")
.verify.cssProperty("#signInPageMessage", "color", "rgba(169, 68, 66, 1)")
.verify.cssProperty("#signInPageMessage", "background-color", "rgba(242, 222, 222, 1)")
.verify.cssProperty("#signInPageMessage", "border-color", "rgb(235, 204, 209)")
},
"anonymous guest should be notified if email already exists" : function (client) {
client
.url("http://localhost:3000/entrySignUp")
.resizeWindow(1024, 768)
.signUp("janicedoe@symptomatic.io", "janicedoe123").pause(500)
.click("#signUpPageEmailInput").pause(500)
.verify.elementPresent("#signUpPageMessage")
.verify.containsText("#signUpPageMessage", "Email already exists. [403]")
},
after: function(client){
client
.dropEntryUsers()
.end();
}
};