@@ -41,12 +41,28 @@ describe('TeamMembers', function() {
41
41
wrapper . update ( ) ;
42
42
} ) ;
43
43
44
- it ( 'can invite member from team dropdown' , async function ( ) {
44
+ it ( 'can invite member from team dropdown with access' , async function ( ) {
45
+ const org = TestStubs . Organization ( { access : [ 'team:admin' ] , openMembership : false } ) ;
45
46
const wrapper = mountWithTheme (
46
- < TeamMembers
47
- params = { { orgId : organization . slug , teamId : team . slug } }
48
- organization = { organization }
49
- /> ,
47
+ < TeamMembers params = { { orgId : org . slug , teamId : team . slug } } organization = { org } /> ,
48
+ routerContext
49
+ ) ;
50
+
51
+ await tick ( ) ;
52
+ wrapper . update ( ) ;
53
+
54
+ wrapper . find ( 'DropdownButton[data-test-id="add-member"]' ) . simulate ( 'click' ) ;
55
+ wrapper
56
+ . find ( 'StyledCreateMemberLink[data-test-id="invite-member"]' )
57
+ . simulate ( 'click' ) ;
58
+
59
+ expect ( openInviteMembersModal ) . toHaveBeenCalled ( ) ;
60
+ } ) ;
61
+
62
+ it ( 'can invite member from team dropdown with access and `Open Membership` enabled' , async function ( ) {
63
+ const org = TestStubs . Organization ( { access : [ 'team:admin' ] , openMembership : true } ) ;
64
+ const wrapper = mountWithTheme (
65
+ < TeamMembers params = { { orgId : org . slug , teamId : team . slug } } organization = { org } /> ,
50
66
routerContext
51
67
) ;
52
68
@@ -61,6 +77,39 @@ describe('TeamMembers', function() {
61
77
expect ( openInviteMembersModal ) . toHaveBeenCalled ( ) ;
62
78
} ) ;
63
79
80
+ it ( 'can invite member from team dropdown without access and `Open Membership` enabled' , async function ( ) {
81
+ const org = TestStubs . Organization ( { access : [ ] , openMembership : true } ) ;
82
+ const wrapper = mountWithTheme (
83
+ < TeamMembers params = { { orgId : org . slug , teamId : team . slug } } organization = { org } /> ,
84
+ routerContext
85
+ ) ;
86
+
87
+ await tick ( ) ;
88
+ wrapper . update ( ) ;
89
+
90
+ wrapper . find ( 'DropdownButton[data-test-id="add-member"]' ) . simulate ( 'click' ) ;
91
+ wrapper
92
+ . find ( 'StyledCreateMemberLink[data-test-id="invite-member"]' )
93
+ . simulate ( 'click' ) ;
94
+
95
+ expect ( openInviteMembersModal ) . toHaveBeenCalled ( ) ;
96
+ } ) ;
97
+
98
+ it ( 'cannot invite member from team dropdown without access and `Open Membership` disabled' , async function ( ) {
99
+ const org = TestStubs . Organization ( { access : [ ] , openMembership : false } ) ;
100
+ const wrapper = mountWithTheme (
101
+ < TeamMembers params = { { orgId : org . slug , teamId : team . slug } } organization = { org } /> ,
102
+ routerContext
103
+ ) ;
104
+
105
+ await tick ( ) ;
106
+ wrapper . update ( ) ;
107
+
108
+ expect (
109
+ wrapper . find ( 'DropdownButton[data-test-id="add-member"]' ) . prop ( 'disabled' )
110
+ ) . toBe ( true ) ;
111
+ } ) ;
112
+
64
113
it ( 'can remove member from team' , async function ( ) {
65
114
const endpoint = `/organizations/${ organization . slug } /members/${
66
115
members [ 0 ] . id
0 commit comments