kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
152 lines
5.2 KiB
152 lines
5.2 KiB
9 years ago
|
// -- copyright
|
||
10 years ago
|
// OpenProject is a project management system.
|
||
10 years ago
|
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
10 years ago
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License version 3.
|
||
|
//
|
||
|
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
// Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License
|
||
|
// as published by the Free Software Foundation; either version 2
|
||
|
// of the License, or (at your option) any later version.
|
||
|
//
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program; if not, write to the Free Software
|
||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
//
|
||
|
// See doc/COPYRIGHT.rdoc for more details.
|
||
9 years ago
|
// ++
|
||
10 years ago
|
|
||
|
/*jshint expr: true*/
|
||
|
|
||
9 years ago
|
describe('workPackageCommentDirectiveTest', function() {
|
||
10 years ago
|
var I18n, ActivityService, compile, scope, element, stateParams, q, commentCreation;
|
||
9 years ago
|
var workPackageFieldService = {};
|
||
9 years ago
|
var html = "<work-package-comment work-package='workPackage' activities='activities'></work-package-comment>";
|
||
10 years ago
|
stateParams = {};
|
||
|
|
||
9 years ago
|
beforeEach(angular.mock.module('ui.router',
|
||
10 years ago
|
'openproject.api',
|
||
|
'openproject.models',
|
||
|
'openproject.layout',
|
||
|
'openproject.services',
|
||
|
'openproject.uiComponents',
|
||
9 years ago
|
'openproject.inplace-edit',
|
||
10 years ago
|
'openproject.workPackages.tabs',
|
||
|
'openproject.workPackages.directives',
|
||
9 years ago
|
'openproject.workPackages.models'));
|
||
10 years ago
|
|
||
9 years ago
|
beforeEach(angular.mock.module('openproject.templates', function($provide) {
|
||
10 years ago
|
var configurationService = {
|
||
10 years ago
|
commentsSortedInDescendingOrder: function() { return []; }
|
||
|
};
|
||
|
|
||
|
$provide.constant('$stateParams', stateParams);
|
||
|
$provide.constant('ConfigurationService', configurationService);
|
||
|
}));
|
||
|
|
||
9 years ago
|
beforeEach(angular.mock.module('openproject.services', function($provide) {
|
||
9 years ago
|
$provide.constant('WorkPackageFieldService', workPackageFieldService);
|
||
|
$provide.constant('WorkPackageService', {});
|
||
|
}));
|
||
|
|
||
10 years ago
|
beforeEach(inject(function($rootScope, $compile, $q, _I18n_, _ActivityService_) {
|
||
|
I18n = _I18n_;
|
||
|
q = $q;
|
||
|
scope = $rootScope.$new();
|
||
|
|
||
|
compile = function() {
|
||
9 years ago
|
workPackageFieldService.isEmpty = sinon.stub().returns(true);
|
||
10 years ago
|
element = $compile(html)(scope);
|
||
|
scope.$digest();
|
||
|
};
|
||
|
|
||
9 years ago
|
workPackageFieldService.isEmpty = sinon.stub().returns(true);
|
||
|
|
||
10 years ago
|
ActivityService = _ActivityService_;
|
||
|
var createComments = sinon.stub(ActivityService, 'createComment');
|
||
|
commentCreation = q.defer();
|
||
|
createComments.returns(commentCreation.promise);
|
||
|
|
||
|
var stub = sinon.stub(I18n, 't');
|
||
|
stub.withArgs('js.label_add_comment_title').returns('trans_title');
|
||
|
stub.withArgs('js.label_add_comment').returns('trans_add_comment');
|
||
|
stub.withArgs('js.button_cancel').returns('trans_cancel');
|
||
|
}));
|
||
|
|
||
|
afterEach(function() {
|
||
|
I18n.t.restore();
|
||
|
ActivityService.createComment.restore();
|
||
|
});
|
||
|
|
||
|
beforeEach(function() {
|
||
|
var workPackage = {
|
||
|
links: {
|
||
|
addComment: { href: 'addComment' },
|
||
|
}
|
||
|
};
|
||
|
|
||
|
scope.workPackage = workPackage;
|
||
|
});
|
||
|
|
||
|
|
||
|
describe('activity comments', function() {
|
||
|
describe('without comment link in work package', function() {
|
||
|
beforeEach(function() {
|
||
|
scope.workPackage.links.addComment = undefined;
|
||
|
compile();
|
||
|
});
|
||
|
|
||
|
it('should not display the comments form', function() {
|
||
9 years ago
|
expect(element.find('.work-packages--activity--add-comment').hasClass('ng-hide'))
|
||
|
.to.equal(true);
|
||
10 years ago
|
});
|
||
|
});
|
||
|
|
||
|
describe('with comment link in work package', function() {
|
||
10 years ago
|
var commentSection, commentField;
|
||
|
|
||
10 years ago
|
beforeEach(function() {
|
||
|
compile();
|
||
10 years ago
|
|
||
9 years ago
|
commentSection = element.find('.work-packages--activity--add-comment');
|
||
10 years ago
|
});
|
||
|
|
||
|
it('should display the comments form', function() {
|
||
10 years ago
|
expect(commentSection.length).to.equal(1);
|
||
10 years ago
|
});
|
||
|
|
||
9 years ago
|
it('should display a placeholder in the comments field', function() {
|
||
|
var readvalue = commentSection.find('.inplace-edit--read-value');
|
||
|
expect(readvalue.text().trim()).to.equal('trans_title');
|
||
|
});
|
||
10 years ago
|
|
||
9 years ago
|
describe('when clicking the inplace edit', function() {
|
||
|
beforeEach(function() {
|
||
|
commentSection.find('.inplace-editing--trigger-link').click();
|
||
9 years ago
|
});
|
||
10 years ago
|
|
||
9 years ago
|
it('does not allow sending comment with an empty message', function() {
|
||
9 years ago
|
var saveButton = commentSection.find('.inplace-edit--control--save');
|
||
|
var commentField = commentSection.find('textarea').click();
|
||
10 years ago
|
|
||
9 years ago
|
expect(saveButton.attr('disabled')).to.eq('disabled');
|
||
10 years ago
|
|
||
9 years ago
|
commentField.val('a useful comment');
|
||
9 years ago
|
commentField.trigger('change');
|
||
|
expect(saveButton.attr('disabled')).to.be.undefined;
|
||
9 years ago
|
});
|
||
10 years ago
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|