diff --git a/src/plugins/comment_paragraph/hotspot/export-comment-button.component.spec.ts b/src/plugins/comment_paragraph/hotspot/export-comment-button.component.spec.ts index 487b641..686f2c2 100644 --- a/src/plugins/comment_paragraph/hotspot/export-comment-button.component.spec.ts +++ b/src/plugins/comment_paragraph/hotspot/export-comment-button.component.spec.ts @@ -3,15 +3,16 @@ import {ComponentTestHelper, createClass} from '../../../spec/component-test-hel import * as helpers from "../../../spec/helpers"; import {Provider} from 'ng-forward'; import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; +import {PermissionDirective} from '../../../app/shared/components/permission/permission.directive'; let htmlTemplate = ''; describe("Components", () => { describe("Export Comment Button Hotspot Component", () => { - let serviceMock = jasmine.createSpyObj("CommentParagraphService", [ "getArticle" ]); + let serviceMock = jasmine.createSpyObj("CommentParagraphService", ["getArticle"]); - let providers = [ new Provider('CommentParagraphService', { useValue: serviceMock }) ] + let providers = [new Provider('CommentParagraphService', { useValue: serviceMock })] .concat(helpers.provideFilters('translateFilter')); let helper: ComponentTestHelper; @@ -20,7 +21,7 @@ describe("Components", () => { beforeEach((done) => { let cls = createClass({ template: htmlTemplate, - directives: [ExportCommentButtonHotspotComponent], + directives: [ExportCommentButtonHotspotComponent, PermissionDirective], providers: providers, properties: { article: {} @@ -48,5 +49,10 @@ describe("Components", () => { expect(helper.all('.export-comment-button').length).toEqual(0); }); + it('not display export comment button when user does not have permission', () => { + helper.component.article = { setting: { comment_paragraph_plugin_activate: true } }; + helper.detectChanges(); + expect(helper.find('.export-comment-button').attr('style')).toEqual("display: none; "); + }); }); }); diff --git a/src/plugins/comment_paragraph/hotspot/export-comment-button.html b/src/plugins/comment_paragraph/hotspot/export-comment-button.html index 26d1c8f..20f05de 100644 --- a/src/plugins/comment_paragraph/hotspot/export-comment-button.html +++ b/src/plugins/comment_paragraph/hotspot/export-comment-button.html @@ -1,5 +1,5 @@ + class="btn btn-default btn-xs export-comment-button" ng-if="ctrl.isActivated()" + permission="ctrl.article.permissions" permission-action="allow_edit"> {{"comment-paragraph-plugin.export" | translate}} - -- libgit2 0.21.2