Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thetif committed Apr 21, 2017
1 parent eb0e8c4 commit eb42826
Show file tree
Hide file tree
Showing 18 changed files with 372 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@
});

element.on('change', function(onChangeEvent) {
console.log('csv change');
if (onChangeEvent && onChangeEvent.target && onChangeEvent.target.files && onChangeEvent.target.files.length &&
onChangeEvent.target.files[0] && onChangeEvent.target.files[0].name) {
console.log('filename', onChangeEvent.target.files[0].name);
var reader = new FileReader();
scope.filename = onChangeEvent.target.files[0].name;
reader.onload = function(onLoadEvent) {
Expand Down Expand Up @@ -125,7 +123,6 @@
}
}
} else if (onChangeEvent && onChangeEvent.target && !onChangeEvent.target.files) {
console.log('no files');
scope.filename = null;
angular.element('input[type="file"]').val(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,6 @@ exports.list = function(req, res) {
}

if (req.query.byCreator) {
console.log('byCreator', req.query.byCreator);
if (req.query.byCreator === 'true') {
and.push({ 'user': req.user });
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
headersValid: false,
filename: ''
};
console.log('reset', $scope.csv);

$scope.bulkFileUploaded = false;

Expand Down
19 changes: 10 additions & 9 deletions modules/profiles/client/views/profiles.client.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@
<div class="col-md-3 col-sm-4 shaded">
<img ng-src="{{vm.user.profileImageURL}}" alt="{{vm.user.displayName}}" class="img-circle img-responsive center-block" width="100" />
<h3 class="text-center"><a href="#" ng-click="vm.openViewUserModal(vm.user)">{{vm.user.displayName}}</a></h3>
<p class="text-muted text-center"><b>{{vm.user.username}}</b><br/>{{vm.user.email}}</p>
<p ng-bind-html="vm.user.researchInterests | sanitize"></p>
<p class="text-muted text-center" id="profile-view-contact"><b>{{vm.user.username}}</b><br/>{{vm.user.email}}</p>
<p id="profile-view-research-interests" ng-bind-html="vm.user.researchInterests | sanitize"></p>
<div class="text-center" ng-show="vm.isTeamLead">
<a class="btn btn-success" ng-click="vm.openTeamProfileForm()"><i class="fa fa-plus"></i> Create a team</a>
</div>
<hr/>
<div ng-show="vm.organization && vm.organization._id">
<div ng-show="vm.organization && vm.organization._id" id="profile-view-side-organization">
<h6>Organization</h6>
<h4><a ui-sref="profiles.organization-view({ schoolOrgId: vm.organization._id })">{{vm.organization.name}}</a><br/>
<small>{{vm.organization.city}}, {{vm.organization.state}}</small></h4>
<hr/>
</div>
<div ng-show="vm.teams">
<div ng-show="vm.teams" id="profile-view-side-teams">
<h6>{{vm.teams.length > 1 ? 'Teams' : 'Team'}}</h6>
<h4 ng-repeat="team in vm.teams">
<a ui-sref="profiles.team-view({ teamId: team._id })">{{team.name}}</a><br/>
<small ng-show="vm.isTeamMember">
<a ng-click="vm.openViewUserModal(team.teamLead)">{{team.teamLead.displayName}}</a></small>
<span ng-repeat="lead in team.teamLeads"><a ng-click="vm.openViewUserModal(lead)">{{lead.displayName}}</a>{{($last) ? '' : ', '}}</span>
</small>
</h4>
<hr/>
</div>
Expand Down Expand Up @@ -115,7 +116,7 @@ <h4><a ui-sref="profiles.organization-view({ schoolOrgId: team.schoolOrg._id })"
<div class="col-lg-6 col-md-12">
<br/>
<div class="row">
<div class="col-sm-4">
<div class="col-sm-6">
<h6><i class="fa fa-user"></i> <span class="blue">{{team.teamLeads.length}}</span> {{(team.teamLeads.length > 1) ? 'Team Leads' : 'Team Lead'}}</h6>
<p ng-repeat="teamLead in team.teamLeads" ng-show="team.teamLeads && team.teamLeads.length > 0">
<img ng-src="{{teamLead.profileImageURL}}" alt="{{teamLead.displayName}}"
Expand All @@ -130,22 +131,22 @@ <h6><i class="fa fa-user"></i> <span class="blue">{{team.teamLeads.length}}</spa
<hr/>
<h6><i class="fa fa-users"></i> <span class="blue">{{team.teamMembers.length}}</span> team members</h6>
</div>
<div class="col-sm-4" ng-show="vm.valuesLoaded">
<div class="col-sm-6" ng-show="vm.valuesLoaded">
<h6><i class="fa fa-file-image-o"></i><span class="blue">{{(team.expeditions) ? team.expeditions.length : 0}}</span> Published Expeditions</h6>
<ul class="list-unstyled">
<li ng-repeat="expedition in team.expeditions">
<a ui-sref="expeditions.view({ expeditionId: expedition._id })">{{expedition.name}}</a>
</li>
</ul>
</div>
<div class="col-sm-4" ng-show="vm.valuesLoaded">
<!-- <div class="col-sm-4" ng-show="vm.valuesLoaded">
<h6><i class="fa fa-flag"></i><span class="blue">{{(team.stations) ? team.stations.length : 0}}</span> Restoration Stations</h6>
<ul class="list-unstyled">
<li ng-repeat="station in team.stations">
<a ng-click="vm.openViewRestorationStation(station)">{{station.name}}</a>
</li>
</ul>
</div>
</div> -->
</div>
</div>
</div>
Expand Down
31 changes: 30 additions & 1 deletion modules/profiles/tests/e2e/common-profiles.e2e.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
var path = require('path'),
EC = protractor.ExpectedConditions;

var station1 = {
name: 'Test Station',
location: {
latitude: '39.765',
longitude: '-76.234'
},
bodyOfWater: 'Flushing Bay',
boroughCounty: 'Queens',
shoreLineText: 'Fixed Pier',
statusText: 'Active',
siteCoordinatorName: 'Site1 Coordinator',
propertyOwnerName: 'Property1'
};
var station2 = {
name: 'Other Station',
location: {
latitude: '39.765',
longitude: '-76.234'
},
bodyOfWater: 'Bronx River',
boroughCounty: 'Bronx',
shoreLineText: 'Dirt/Sand',
statusText: 'Active',
siteCoordinatorName: 'Site2 Coordinator',
propertyOwnerName: 'Property2'
};

var assertORSProfile = function(values, teamLead, organization, isAdmin, isOwner) {
// Station image
if (values.photo) {
Expand Down Expand Up @@ -72,5 +99,7 @@ var assertORSProfile = function(values, teamLead, organization, isAdmin, isOwner
};

module.exports = {
assertORSProfile: assertORSProfile
assertORSProfile: assertORSProfile,
station1: station1,
station2: station2
};
30 changes: 30 additions & 0 deletions modules/profiles/tests/e2e/organization-lead-profile.e2e.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var path = require('path'),
moment = require('moment'),
CommonUser = require('../../../users/tests/e2e/common-users.e2e.tests'),
signinAs = CommonUser.signinAs,
signout = CommonUser.signout,
signup = CommonUser.signup,
CommonExpedition = require('../../../expeditions/tests/e2e/common-expeditions.e2e.tests'),
uploadImage = CommonExpedition.uploadImage,
assertImage = CommonExpedition.assertImage,
defaultMapCoordinates = CommonExpedition.defaultMapCoordinates,
assertMapCoordinates = CommonExpedition.assertMapCoordinates,
CommonProfiles = require('../../../profiles/tests/e2e/common-profiles.e2e.tests'),
assertORSProfile = CommonProfiles.assertORSProfile,
EC = protractor.ExpectedConditions;

describe('Profile E2E Tests', function() {
var admin = CommonUser.admin;
var leader = CommonUser.leader;
var member1 = CommonUser.member1;
var member2 = CommonUser.member2;
var newLeader = CommonUser.newLeader;
var newStudent = CommonUser.newStudent;
var team = CommonUser.team;
var organization = CommonUser.organization;

var station1 = CommonProfiles.station1;
var station2 = CommonProfiles.station2;
});
30 changes: 30 additions & 0 deletions modules/profiles/tests/e2e/organization-profile.e2e.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var path = require('path'),
moment = require('moment'),
CommonUser = require('../../../users/tests/e2e/common-users.e2e.tests'),
signinAs = CommonUser.signinAs,
signout = CommonUser.signout,
signup = CommonUser.signup,
CommonExpedition = require('../../../expeditions/tests/e2e/common-expeditions.e2e.tests'),
uploadImage = CommonExpedition.uploadImage,
assertImage = CommonExpedition.assertImage,
defaultMapCoordinates = CommonExpedition.defaultMapCoordinates,
assertMapCoordinates = CommonExpedition.assertMapCoordinates,
CommonProfiles = require('../../../profiles/tests/e2e/common-profiles.e2e.tests'),
assertORSProfile = CommonProfiles.assertORSProfile,
EC = protractor.ExpectedConditions;

describe('Profile E2E Tests', function() {
var admin = CommonUser.admin;
var leader = CommonUser.leader;
var member1 = CommonUser.member1;
var member2 = CommonUser.member2;
var newLeader = CommonUser.newLeader;
var newStudent = CommonUser.newStudent;
var team = CommonUser.team;
var organization = CommonUser.organization;

var station1 = CommonProfiles.station1;
var station2 = CommonProfiles.station2;
});
102 changes: 102 additions & 0 deletions modules/profiles/tests/e2e/profiles.e2e.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
'use strict';

var path = require('path'),
moment = require('moment'),
CommonUser = require('../../../users/tests/e2e/common-users.e2e.tests'),
signinAs = CommonUser.signinAs,
signout = CommonUser.signout,
signup = CommonUser.signup,
CommonExpedition = require('../../../expeditions/tests/e2e/common-expeditions.e2e.tests'),
uploadImage = CommonExpedition.uploadImage,
assertImage = CommonExpedition.assertImage,
defaultMapCoordinates = CommonExpedition.defaultMapCoordinates,
assertMapCoordinates = CommonExpedition.assertMapCoordinates,
CommonProfiles = require('../../../profiles/tests/e2e/common-profiles.e2e.tests'),
assertORSProfile = CommonProfiles.assertORSProfile,
EC = protractor.ExpectedConditions;

describe('Profile E2E Tests', function() {
var admin = CommonUser.admin;
var leader = CommonUser.leader;
var leader2 = CommonUser.leader2;
var member1 = CommonUser.member1;
var member2 = CommonUser.member2;
var member3 = CommonUser.member3;
var member4 = CommonUser.member4;
var newLeader = CommonUser.newLeader;
var newStudent = CommonUser.newStudent;
var team = CommonUser.team;
var team2 = CommonUser.team2;
var organization = CommonUser.organization;

var station1 = CommonProfiles.station1;
var station2 = CommonProfiles.station2;

var assertProfile = function(values, organization, teams, isTeamLead, isTeamMember) {
//Profile image
expect(element(by.css('img[class="img-circle img-responsive center-block"]')).isDisplayed()).toBe(true);
//Name
var name = element(by.css('a[ng-click="vm.openViewUserModal(vm.user)"]'));
expect(name.isDisplayed()).toBe(true);
expect(name.getText()).toEqual(values.displayName);
//Contact
var contact = element(by.id('profile-view-contact'));
expect(contact.isDisplayed()).toBe(true);
expect(contact.getText()).toEqual(values.username + '\n' + values.email);
//Research interests
var research = element(by.id('profile-view-research-interests'));
expect(research.isDisplayed()).toBe(true);
if (values.researchInterestsText) expect(research.getText()).toEqual(values.researchInterestsText);

var createTeamButton = element(by.css('a[ng-click="vm.openTeamProfileForm()"]'));
if (isTeamLead) {
expect(createTeamButton.isDisplayed()).toBe(true);
} else {
expect(createTeamButton.isDisplayed()).toBe(false);
}

//Sidebar Organization
var sideOrganization = element(by.id('profile-view-side-organization'));
if (organization) {
expect(sideOrganization.getText()).toEqual('ORGANIZATION\n' + organization.name + '\n' + organization.city + ', ' + organization.state);
expect(element(by.css('a[ui-sref="profiles.organization-view({ schoolOrgId: vm.organization._id })"]')).isDisplayed()).toBe(true);
}

var sideTeams = element(by.id('profile-view-side-teams'));
if (teams) {
var sideTeamsText = ((teams.length > 1) ? 'TEAMS' : 'TEAM') + '\n';
for (var i = 0; i < teams.length; i++) {
sideTeamsText += teams[i].name;
if (isTeamMember || i < teams.length-1) {
sideTeamsText += '\n';
}
if (isTeamMember) {
for (var j = 0; j < teams[i].teamLeads.length; j++) {
sideTeamsText += teams[i].teamLeads[j].displayName;
if (j < teams[i].teamLeads.length-1) {
sideTeamsText += ', ';
}
}
}
}
expect(sideTeams.isDisplayed()).toBe(true);
expect(sideTeams.getText()).toEqual(sideTeamsText);
}

expect(element(by.cssContainingText('.btn-default', 'Edit profile')).isDisplayed()).toBe(true);
expect(element(by.cssContainingText('.btn-default', 'Change profile picture')).isDisplayed()).toBe(true);
expect(element(by.cssContainingText('.btn-default', 'Change password')).isDisplayed()).toBe(true);
};

describe('Profile View', function() {
it('should allow team lead to view their profile', function() {
//Sign in as leader
signinAs(leader);
//Assert that it went to correct opening page
expect(browser.getCurrentUrl()).toEqual('http://localhost:8081/restoration');
browser.get('http://localhost:8081/profiles');

assertProfile(leader, organization, [team, team2], true, false);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var path = require('path'),
moment = require('moment'),
CommonUser = require('../../../users/tests/e2e/common-users.e2e.tests'),
signinAs = CommonUser.signinAs,
signout = CommonUser.signout,
signup = CommonUser.signup,
CommonExpedition = require('../../../expeditions/tests/e2e/common-expeditions.e2e.tests'),
uploadImage = CommonExpedition.uploadImage,
assertImage = CommonExpedition.assertImage,
defaultMapCoordinates = CommonExpedition.defaultMapCoordinates,
assertMapCoordinates = CommonExpedition.assertMapCoordinates,
CommonProfiles = require('../../../profiles/tests/e2e/common-profiles.e2e.tests'),
assertORSProfile = CommonProfiles.assertORSProfile,
EC = protractor.ExpectedConditions;

describe('Profile E2E Tests', function() {
var admin = CommonUser.admin;
var leader = CommonUser.leader;
var member1 = CommonUser.member1;
var member2 = CommonUser.member2;
var newLeader = CommonUser.newLeader;
var newStudent = CommonUser.newStudent;
var team = CommonUser.team;
var organization = CommonUser.organization;

var station1 = CommonProfiles.station1;
var station2 = CommonProfiles.station2;
});
30 changes: 30 additions & 0 deletions modules/profiles/tests/e2e/team-lead-profile.e2e.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var path = require('path'),
moment = require('moment'),
CommonUser = require('../../../users/tests/e2e/common-users.e2e.tests'),
signinAs = CommonUser.signinAs,
signout = CommonUser.signout,
signup = CommonUser.signup,
CommonExpedition = require('../../../expeditions/tests/e2e/common-expeditions.e2e.tests'),
uploadImage = CommonExpedition.uploadImage,
assertImage = CommonExpedition.assertImage,
defaultMapCoordinates = CommonExpedition.defaultMapCoordinates,
assertMapCoordinates = CommonExpedition.assertMapCoordinates,
CommonProfiles = require('../../../profiles/tests/e2e/common-profiles.e2e.tests'),
assertORSProfile = CommonProfiles.assertORSProfile,
EC = protractor.ExpectedConditions;

describe('Profile E2E Tests', function() {
var admin = CommonUser.admin;
var leader = CommonUser.leader;
var member1 = CommonUser.member1;
var member2 = CommonUser.member2;
var newLeader = CommonUser.newLeader;
var newStudent = CommonUser.newStudent;
var team = CommonUser.team;
var organization = CommonUser.organization;

var station1 = CommonProfiles.station1;
var station2 = CommonProfiles.station2;
});
Loading

0 comments on commit eb42826

Please sign in to comment.