@@ -12,14 +12,16 @@ import { TranslateService } from '@mm-services/translate.service';
12
12
import { TranslateFromService } from '@mm-services/translate-from.service' ;
13
13
import { ButtonType } from '@mm-components/fast-action-button/fast-action-button.component' ;
14
14
import { ReportsActions } from '@mm-actions/reports' ;
15
+ import { UserSettingsService } from '@mm-services/user-settings.service' ;
15
16
16
- describe ( 'Session service' , ( ) => {
17
+ describe ( 'Fast Action Button service' , ( ) => {
17
18
let service : FastActionButtonService ;
18
19
let router ;
19
20
let authService ;
20
21
let responsiveService ;
21
22
let translateService ;
22
23
let translateFromService ;
24
+ let userSettingsService ;
23
25
let documentMock ;
24
26
let domElement ;
25
27
@@ -29,6 +31,7 @@ describe('Session service', () => {
29
31
responsiveService = { isMobile : sinon . stub ( ) } ;
30
32
translateService = { instant : sinon . stub ( ) . returnsArg ( 0 ) } ;
31
33
translateFromService = { get : sinon . stub ( ) . returnsArg ( 0 ) } ;
34
+ userSettingsService = { get : sinon . stub ( ) . resolves ( ) } ;
32
35
domElement = {
33
36
click : sinon . stub ( ) ,
34
37
remove : sinon . stub ( ) ,
@@ -46,6 +49,7 @@ describe('Session service', () => {
46
49
{ provide : ResponsiveService , useValue : responsiveService } ,
47
50
{ provide : TranslateService , useValue : translateService } ,
48
51
{ provide : TranslateFromService , useValue : translateFromService } ,
52
+ { provide : UserSettingsService , useValue : userSettingsService } ,
49
53
{ provide : DOCUMENT , useValue : documentMock } ,
50
54
] ,
51
55
} ) ;
@@ -759,6 +763,29 @@ describe('Session service', () => {
759
763
assertUpdateFacilityAction ( actions [ 0 ] ) ;
760
764
} ) ;
761
765
766
+ it ( 'should not return send message action if sendto matches user' , async ( ) => {
767
+ const context = {
768
+ reportContentType : 'other' ,
769
+ communicationContext : {
770
+ sendTo : { _id : '1234' , phone : '+2541234567890' } ,
771
+ callbackOpenSendMessage : sinon . stub ( ) ,
772
+ } ,
773
+ } ;
774
+ authService . has . resolves ( true ) ;
775
+ responsiveService . isMobile . returns ( true ) ;
776
+ userSettingsService . get . resolves ( { contact_id : '1234' } ) ;
777
+
778
+ const actions = await service . getReportRightSideActions ( context ) ;
779
+
780
+ expect ( actions . length ) . to . equal ( 1 ) ;
781
+ expect ( authService . has . args ) . to . have . deep . members ( [
782
+ [ [ 'can_view_message_action' ] ] ,
783
+ [ 'can_edit' ] ,
784
+ ] ) ;
785
+
786
+ assertUpdateFacilityAction ( actions [ 0 ] ) ;
787
+ } ) ;
788
+
762
789
it ( 'should not return actions if no permissions' , async ( ) => {
763
790
const context = {
764
791
reportContentType : 'other' ,
0 commit comments