Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
willdoran committed Feb 14, 2016
1 parent ae211c9 commit 300da92
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 62 deletions.
1 change: 1 addition & 0 deletions app/mock-backend-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ angular.module('e2e-mocks', ['ngMockE2E'])
'config/map': require('../mocked_backend/api/v3/config/map.json'),
'sets': require('../mocked_backend/api/v3/sets.json'),
'collections': require('../mocked_backend/api/v3/collections.json'),
'roles': require('../mocked_backend/api/v3/roles.json'),
'users': require('../mocked_backend/api/v3/users.json'),
'users/me': require('../mocked_backend/api/v3/users/me.json'),
'config/site': require('../mocked_backend/api/v3/config/site.json')
Expand Down
3 changes: 2 additions & 1 deletion app/post/controllers/post-detail-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ function (
$promise
.then(function () {
var message = post.status === 'draft' ? 'notify.post.set_draft' : 'notify.post.publish_success';
$translate(message)
var role = message == 'draft' ? 'draft' : (_.isEmpty(post.published_to) ? 'everyone' : post.published_to.join(", "));
$translate(message, {role: role})
.then(function (message) {
Notify.showNotificationSlider(message);
});
Expand Down
3 changes: 2 additions & 1 deletion app/post/directives/post-editor-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ function (
$promise
.then(function (post) {
var message = post.status === 'draft' ? 'notify.post.set_draft' : 'notify.post.publish_success';
$translate(message)
var role = message == 'draft' ? 'draft' : (_.isEmpty(post.published_to) ? 'everyone' : post.published_to.join(", "));
$translate(message, {role: role})
.then(function (message) {
Notify.showNotificationSlider(message);
});
Expand Down
3 changes: 2 additions & 1 deletion app/post/directives/post-preview-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ function (
$promise
.then(function (post) {
var message = post.status === 'draft' ? 'notify.post.set_draft' : 'notify.post.publish_success';
$translate(message)
var role = message == 'draft' ? 'draft' : (_.isEmpty(post.published_to) ? 'everyone' : post.published_to.join(", "));
$translate(message, {role: role})
.then(function (message) {
Notify.showNotificationSlider(message);
});
Expand Down
4 changes: 3 additions & 1 deletion app/setting/controllers/setting-users-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ function (
$scope.$emit('setPageTitle', title);
});

$scope.roles = RoleEndpoint.query();
RoleEndpoint.query().$promise.then(function (roles) {
$scope.roles = roles;
});

$scope.filter = {
role: '',
Expand Down
50 changes: 22 additions & 28 deletions mocked_backend/api/v3/roles.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"count": 5,
"count": 4,
"results": [
{
"id": 1,
"url": "http://api.ushahidi.dev/api/v3/roles/1",
"role": "admin",
"name": "Admin",
"display_name": "Admin",
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"permissions": [],
"allowed_methods": [
"get",
"post",
Expand All @@ -18,10 +19,11 @@
{
"id": 2,
"url": "http://api.ushahidi.dev/api/v3/roles/2",
"role": "member",
"name": "Member",
"display_name": "Member",
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"permissions": [],
"allowed_methods": [
"get",
"post",
Expand All @@ -33,44 +35,36 @@
},
{
"id": 3,
"url": "http://api.ushahidi.dev/api/v3/roles/3",
"role": "guest",
"url": "http://api.ushahidi.dev/api/v3/roles/2",
"name": "Importer",
"display_name": "Importer",
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"permissions": ["Bulk Data Import"],
"allowed_methods": [
"get",
"post",
"put",
"delete"
"delete",
"update",
"change_status"
]
},
{
"id": 4,
"url": "http://api.ushahidi.dev/api/v3/roles/4",
"role": "custom role 1",
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"allowed_methods": [
"get",
"post",
"put",
"delete"
]
},
{
"id": 5,
"url": "http://api.ushahidi.dev/api/v3/roles/5",
"role": "custom role 2",
"url": "http://api.ushahidi.dev/api/v3/roles/2",
"name": "Manager",
"display_name": "Manager",
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"permissions": ["Manage Settings", "Manage Users", "Manage Posts"],
"allowed_methods": [
"get",
"post",
"put",
"delete"
"delete",
"update",
"change_status"
]
}
],
Expand All @@ -81,5 +75,5 @@
"curr": "http://api.ushahidi.dev/api/v3/roles?access_token=defaulttoken&orderby=created&order=desc&limit=100&offset=0",
"next": "http://api.ushahidi.dev/api/v3/roles?access_token=defaulttoken&orderby=created&order=desc&limit=100&offset=100",
"prev": "http://api.ushahidi.dev/api/v3/roles?access_token=defaulttoken&orderby=created&order=desc&limit=100&offset=0",
"total_count": 5
"total_count": 4
}
40 changes: 20 additions & 20 deletions mocked_backend/api/v3/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"role": "User",
"allowed_methods": [
"get",
"post",
Expand All @@ -31,7 +31,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -52,7 +52,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"role": "User",
"allowed_methods": [
"get",
"post",
Expand All @@ -71,7 +71,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -90,7 +90,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -110,7 +110,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"role": "User",
"allowed_methods": [
"get",
"post",
Expand All @@ -129,7 +129,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -147,7 +147,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"role": "User",
"allowed_methods": [
"get",
"post",
Expand All @@ -166,7 +166,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -185,7 +185,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -204,7 +204,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"role": "User",
"allowed_methods": [
"get",
"post",
Expand All @@ -223,7 +223,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -241,7 +241,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"role": "User",
"allowed_methods": [
"get",
"post",
Expand All @@ -260,7 +260,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -279,7 +279,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -298,7 +298,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"role": "User",
"allowed_methods": [
"get",
"post",
Expand All @@ -317,7 +317,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -335,7 +335,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "user",
"role": "User",
"allowed_methods": [
"get",
"post",
Expand All @@ -354,7 +354,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand All @@ -373,7 +373,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": null,
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand Down
2 changes: 1 addition & 1 deletion mocked_backend/api/v3/users/me.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"last_attempt": null,
"created": "1970-01-01T00:00:00+00:00",
"updated": "2014-12-13T19:17:57+00:00",
"role": "admin",
"role": "Admin",
"allowed_methods": [
"get",
"post",
Expand Down
2 changes: 1 addition & 1 deletion server/www/templates/settings/users.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h3 class="delta-alt" translate>user.search_and_filter</h3>
</div>
<div class="user bd">
<h3><a ng-href="/settings/users/{{user.id}}">{{user.realname}}</a></h3>
<h4 class="user-type">{{ getRole(user.role) }}</h4>
<h4 class="user-type">{{ user.role }}</h4>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/post/views/post-list-e2e-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('post detail interaction', function () {
postCollectionsButtonSelector = '.actions-content .dropdown-trigger.init.dropdown-toggle',
postCollectionsMenuSelector = '.actions-content .dropdown-menu.init',
collectionItem = '.form-field.checkbox input',
visibilityButtonsSelector = '.step select',
visibilityButtonsSelector = '.step legend',
confirmationMessageSelector = '.confirmation-message-wrapper p';

describe('as a logged in admin user', function () {
Expand All @@ -37,13 +37,13 @@ describe('post detail interaction', function () {

describe('when clicking a visibility option', function () {
beforeEach(function () {
var optionElement = visibilitySelect.element(by.cssContainingText('option', 'Member'));
var optionElement = element.all(by.css('.step .radio input')).get(1);
optionElement.click();

});
it('should set the visibility of the post and display a confirmation', function () {
var confirmMessage = element(by.css(confirmationMessageSelector));
expect(confirmMessage.getInnerHtml()).toEqual('Post has been published for Member');
expect(confirmMessage.getInnerHtml()).toEqual('Post has been published for everyone');
});
});
});
Expand Down
6 changes: 1 addition & 5 deletions test/e2e/settings/users-e2e-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ describe('users management', function () {
_.range(3, 6).forEach(function (i) {
element(by.css('#user-' + i + ' input[type="checkbox"]')).click();
});
// element.all(by.css('tr.user input[type="checkbox"]')).then(function(userCheckBoxes){
//
// });
element(by.css('#user-1 input[type="checkbox"]')).click();
});

Expand All @@ -159,8 +156,7 @@ describe('users management', function () {
browser.sleep(500);
});
it('shows an alert which asks if you really want to change the roles', function () {
expect(element(by.css('#confirm-modal-text')).getText()).toEqual('Are you sure you want to change the role of 4 users to Member?');
element(by.css('button#confirm-modal-ok')).click();
expect(element(by.css('#confirm-modal-text')).getText()).toEqual('Are you sure you want to change the role of 2 users to Member?');
});
});

Expand Down

0 comments on commit 300da92

Please sign in to comment.