@@ -87,7 +87,7 @@ describe('Project Member Invite create', () => {
87
87
} ) ,
88
88
models . ProjectMemberInvite . create ( {
89
89
projectId : project1 . id ,
90
- email : 'duplicate_lowercase@gmail .com' ,
90
+ email : 'duplicate_lowercase@test .com' ,
91
91
role : PROJECT_MEMBER_ROLE . MANAGER ,
92
92
status : INVITE_STATUS . PENDING ,
93
93
createdBy : 1 ,
@@ -97,7 +97,27 @@ describe('Project Member Invite create', () => {
97
97
} ) ,
98
98
models . ProjectMemberInvite . create ( {
99
99
projectId : project1 . id ,
100
- email : 'DUPLICATE_UPPERCASE@gmail.com' ,
100
+ email : 'DUPLICATE_UPPERCASE@test.com' ,
101
+ role : PROJECT_MEMBER_ROLE . MANAGER ,
102
+ status : INVITE_STATUS . PENDING ,
103
+ createdBy : 1 ,
104
+ updatedBy : 1 ,
105
+ createdAt : '2016-06-30 00:33:07+00' ,
106
+ updatedAt : '2016-06-30 00:33:07+00' ,
107
+ } ) ,
108
+ models . ProjectMemberInvite . create ( {
109
+ projectId : project1 . id ,
110
+ email : 'with.dot@gmail.com' ,
111
+ role : PROJECT_MEMBER_ROLE . MANAGER ,
112
+ status : INVITE_STATUS . PENDING ,
113
+ createdBy : 1 ,
114
+ updatedBy : 1 ,
115
+ createdAt : '2016-06-30 00:33:07+00' ,
116
+ updatedAt : '2016-06-30 00:33:07+00' ,
117
+ } ) ,
118
+ models . ProjectMemberInvite . create ( {
119
+ projectId : project1 . id ,
120
+ email : 'withoutdot@gmail.com' ,
101
121
role : PROJECT_MEMBER_ROLE . MANAGER ,
102
122
status : INVITE_STATUS . PENDING ,
103
123
createdBy : 1 ,
@@ -664,33 +684,14 @@ describe('Project Member Invite create', () => {
664
684
} ) ;
665
685
666
686
it ( 'should return 201 and empty response when trying add already invited member by lowercase email' , ( done ) => {
667
- const mockHttpClient = _ . merge ( testUtil . mockHttpClient , {
668
- get : ( ) => Promise . resolve ( {
669
- status : 200 ,
670
- data : {
671
- id : 'requesterId' ,
672
- version : 'v3' ,
673
- result : {
674
- success : true ,
675
- status : 200 ,
676
- content : {
677
- success : [ {
678
- roleName : USER_ROLE . COPILOT ,
679
- } ] ,
680
- } ,
681
- } ,
682
- } ,
683
- } ) ,
684
- } ) ;
685
- sandbox . stub ( util , 'getHttpClient' , ( ) => mockHttpClient ) ;
686
687
request ( server )
687
688
. post ( `/v4/projects/${ project1 . id } /members/invite` )
688
689
. set ( {
689
690
Authorization : `Bearer ${ testUtil . jwts . copilot } ` ,
690
691
} )
691
692
. send ( {
692
693
param : {
693
- emails : [ 'DUPLICATE_LOWERCASE@gmail .com' ] ,
694
+ emails : [ 'DUPLICATE_LOWERCASE@test .com' ] ,
694
695
role : 'customer' ,
695
696
} ,
696
697
} )
@@ -703,40 +704,20 @@ describe('Project Member Invite create', () => {
703
704
const resJson = res . body . result . content . success ;
704
705
should . exist ( resJson ) ;
705
706
resJson . length . should . equal ( 0 ) ;
706
- server . services . pubsub . publish . neverCalledWith ( 'project.member.invite.created' ) . should . be . true ;
707
707
done ( ) ;
708
708
}
709
709
} ) ;
710
710
} ) ;
711
711
712
712
it ( 'should return 201 and empty response when trying add already invited member by uppercase email' , ( done ) => {
713
- const mockHttpClient = _ . merge ( testUtil . mockHttpClient , {
714
- get : ( ) => Promise . resolve ( {
715
- status : 200 ,
716
- data : {
717
- id : 'requesterId' ,
718
- version : 'v3' ,
719
- result : {
720
- success : true ,
721
- status : 200 ,
722
- content : {
723
- success : [ {
724
- roleName : USER_ROLE . COPILOT ,
725
- } ] ,
726
- } ,
727
- } ,
728
- } ,
729
- } ) ,
730
- } ) ;
731
- sandbox . stub ( util , 'getHttpClient' , ( ) => mockHttpClient ) ;
732
713
request ( server )
733
714
. post ( `/v4/projects/${ project1 . id } /members/invite` )
734
715
. set ( {
735
716
Authorization : `Bearer ${ testUtil . jwts . copilot } ` ,
736
717
} )
737
718
. send ( {
738
719
param : {
739
- emails : [ 'duplicate_uppercase@gmail .com' ] ,
720
+ emails : [ 'duplicate_uppercase@test .com' ] ,
740
721
role : 'customer' ,
741
722
} ,
742
723
} )
@@ -749,12 +730,65 @@ describe('Project Member Invite create', () => {
749
730
const resJson = res . body . result . content . success ;
750
731
should . exist ( resJson ) ;
751
732
resJson . length . should . equal ( 0 ) ;
752
- server . services . pubsub . publish . neverCalledWith ( 'project.member.invite.created' ) . should . be . true ;
753
733
done ( ) ;
754
734
}
755
735
} ) ;
756
736
} ) ;
757
737
738
+ it ( 'should return 201 and empty response when trying add already invited member by gmail email with dot' ,
739
+ ( done ) => {
740
+ request ( server )
741
+ . post ( `/v4/projects/${ project1 . id } /members/invite` )
742
+ . set ( {
743
+ Authorization : `Bearer ${ testUtil . jwts . copilot } ` ,
744
+ } )
745
+ . send ( {
746
+ param : {
747
+ emails : [ 'WITHdot@gmail.com' ] ,
748
+ role : 'customer' ,
749
+ } ,
750
+ } )
751
+ . expect ( 'Content-Type' , / j s o n / )
752
+ . expect ( 201 )
753
+ . end ( ( err , res ) => {
754
+ if ( err ) {
755
+ done ( err ) ;
756
+ } else {
757
+ const resJson = res . body . result . content . success ;
758
+ should . exist ( resJson ) ;
759
+ resJson . length . should . equal ( 0 ) ;
760
+ done ( ) ;
761
+ }
762
+ } ) ;
763
+ } ) ;
764
+
765
+ it ( 'should return 201 and empty response when trying add already invited member by gmail email without dot' ,
766
+ ( done ) => {
767
+ request ( server )
768
+ . post ( `/v4/projects/${ project1 . id } /members/invite` )
769
+ . set ( {
770
+ Authorization : `Bearer ${ testUtil . jwts . copilot } ` ,
771
+ } )
772
+ . send ( {
773
+ param : {
774
+ emails : [ 'WITHOUT.dot@gmail.com' ] ,
775
+ role : 'customer' ,
776
+ } ,
777
+ } )
778
+ . expect ( 'Content-Type' , / j s o n / )
779
+ . expect ( 201 )
780
+ . end ( ( err , res ) => {
781
+ if ( err ) {
782
+ done ( err ) ;
783
+ } else {
784
+ const resJson = res . body . result . content . success ;
785
+ should . exist ( resJson ) ;
786
+ resJson . length . should . equal ( 0 ) ;
787
+ done ( ) ;
788
+ }
789
+ } ) ;
790
+ } ) ;
791
+
758
792
describe ( 'Bus api' , ( ) => {
759
793
let createEventSpy ;
760
794
0 commit comments