|
@@ -1,18 +1,15 @@
|
|
|
import React from 'react';
|
|
|
-import {shallow} from 'sentry-test/enzyme';
|
|
|
+import {shallow, mountWithTheme} from 'sentry-test/enzyme';
|
|
|
|
|
|
import OrganizationMemberRow from 'app/views/settings/organizationMembers/organizationMemberRow';
|
|
|
|
|
|
-const findWithText = (wrapper, text) =>
|
|
|
- wrapper.filterWhere(n => n.prop('children') && n.prop('children').includes(text));
|
|
|
-
|
|
|
describe('OrganizationMemberRow', function() {
|
|
|
const member = {
|
|
|
id: '1',
|
|
|
email: '',
|
|
|
name: '',
|
|
|
- role: '',
|
|
|
- roleName: '',
|
|
|
+ role: 'member',
|
|
|
+ roleName: 'Member',
|
|
|
pending: false,
|
|
|
flags: {
|
|
|
'sso:linked': false,
|
|
@@ -45,6 +42,11 @@ describe('OrganizationMemberRow', function() {
|
|
|
onLeave: () => {},
|
|
|
};
|
|
|
|
|
|
+ const resendButton = 'StyledButton[aria-label="Resend invite"]';
|
|
|
+ const resendSsoButton = 'StyledButton[aria-label="Resend SSO link"]';
|
|
|
+ const leaveButton = 'StyledButton[aria-label="Leave"]';
|
|
|
+ const removeButton = 'StyledButton[aria-label="Remove"]';
|
|
|
+
|
|
|
beforeEach(function() {});
|
|
|
|
|
|
it('does not have 2fa warning if user has 2fa', function() {
|
|
@@ -60,8 +62,7 @@ describe('OrganizationMemberRow', function() {
|
|
|
}}
|
|
|
/>
|
|
|
);
|
|
|
- expect(wrapper.find('NoTwoFactorIcon')).toHaveLength(0);
|
|
|
- expect(wrapper.find('HasTwoFactorIcon')).toHaveLength(1);
|
|
|
+ expect(wrapper.find('AuthIcon').prop('has2fa')).toBe(true);
|
|
|
});
|
|
|
|
|
|
it('has 2fa warning if user does not have 2fa enabled', function() {
|
|
@@ -77,8 +78,7 @@ describe('OrganizationMemberRow', function() {
|
|
|
}}
|
|
|
/>
|
|
|
);
|
|
|
- expect(wrapper.find('NoTwoFactorIcon')).toHaveLength(1);
|
|
|
- expect(wrapper.find('HasTwoFactorIcon')).toHaveLength(0);
|
|
|
+ expect(wrapper.find('AuthIcon').prop('has2fa')).toBe(false);
|
|
|
});
|
|
|
|
|
|
describe('Pending user', function() {
|
|
@@ -91,7 +91,7 @@ describe('OrganizationMemberRow', function() {
|
|
|
};
|
|
|
|
|
|
it('has "Invited" status, no "Resend Invite"', function() {
|
|
|
- const wrapper = shallow(
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
<OrganizationMemberRow
|
|
|
{...props}
|
|
|
member={{
|
|
@@ -101,50 +101,49 @@ describe('OrganizationMemberRow', function() {
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
- expect(findWithText(wrapper.find('strong'), 'Invited')).toHaveLength(1);
|
|
|
-
|
|
|
- expect(wrapper.find('ResendInviteButton')).toHaveLength(0);
|
|
|
+ expect(wrapper.find('[data-test-id="member-role"]').text()).toBe('Invited Member');
|
|
|
+ expect(wrapper.find(resendButton).prop('disabled')).toBe(true);
|
|
|
});
|
|
|
|
|
|
it('has "Resend Invite" button only if `canAddMembers` is true', function() {
|
|
|
- const wrapper = shallow(<OrganizationMemberRow {...props} canAddMembers />);
|
|
|
-
|
|
|
- expect(findWithText(wrapper.find('strong'), 'Invited')).toHaveLength(1);
|
|
|
+ const wrapper = mountWithTheme(<OrganizationMemberRow {...props} canAddMembers />);
|
|
|
|
|
|
- expect(wrapper.find('ResendInviteButton')).toHaveLength(1);
|
|
|
+ expect(wrapper.find('[data-test-id="member-role"]').text()).toBe('Invited Member');
|
|
|
+ expect(wrapper.find(resendButton).prop('disabled')).toBe(false);
|
|
|
});
|
|
|
|
|
|
it('has the right inviting states', function() {
|
|
|
- let wrapper = shallow(<OrganizationMemberRow {...props} canAddMembers />);
|
|
|
+ let wrapper = mountWithTheme(<OrganizationMemberRow {...props} canAddMembers />);
|
|
|
|
|
|
- expect(wrapper.find('ResendInviteButton')).toHaveLength(1);
|
|
|
+ expect(wrapper.find(resendButton).exists()).toBe(true);
|
|
|
|
|
|
- wrapper = shallow(
|
|
|
+ wrapper = mountWithTheme(
|
|
|
<OrganizationMemberRow {...props} canAddMembers status="loading" />
|
|
|
);
|
|
|
|
|
|
// Should have loader
|
|
|
expect(wrapper.find('LoadingIndicator')).toHaveLength(1);
|
|
|
// No Resend Invite button
|
|
|
- expect(wrapper.find('ResendInviteButton')).toHaveLength(0);
|
|
|
+ expect(wrapper.find(resendButton).exists()).toBe(false);
|
|
|
|
|
|
- wrapper = shallow(
|
|
|
+ wrapper = mountWithTheme(
|
|
|
<OrganizationMemberRow {...props} canAddMembers status="success" />
|
|
|
);
|
|
|
|
|
|
// Should have loader
|
|
|
expect(wrapper.find('LoadingIndicator')).toHaveLength(0);
|
|
|
// No Resend Invite button
|
|
|
- expect(wrapper.find('ResendInviteButton')).toHaveLength(0);
|
|
|
- expect(findWithText(wrapper.find('span'), 'Sent!')).toHaveLength(1);
|
|
|
+ expect(wrapper.find(resendButton).exists()).toBe(false);
|
|
|
+ expect(wrapper.find('[data-test-id="member-status"]').text()).toBe('Sent!');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe('Expired user', function() {
|
|
|
it('has "Expired" status', function() {
|
|
|
- const wrapper = shallow(
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
<OrganizationMemberRow
|
|
|
{...defaultProps}
|
|
|
+ canAddMembers
|
|
|
member={{
|
|
|
...member,
|
|
|
pending: true,
|
|
@@ -153,8 +152,8 @@ describe('OrganizationMemberRow', function() {
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
- expect(findWithText(wrapper.find('strong'), 'Expired')).toHaveLength(1);
|
|
|
- expect(wrapper.find('ResendInviteButton')).toHaveLength(0);
|
|
|
+ expect(wrapper.find('[data-test-id="member-role"]').text()).toBe('Expired Invite');
|
|
|
+ expect(wrapper.find(resendButton).prop('disabled')).toBe(false);
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -168,9 +167,10 @@ describe('OrganizationMemberRow', function() {
|
|
|
};
|
|
|
|
|
|
it('shows "Invited" status if user has not registered and not linked', function() {
|
|
|
- const wrapper = shallow(
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
<OrganizationMemberRow
|
|
|
{...props}
|
|
|
+ canAddMembers
|
|
|
member={{
|
|
|
...member,
|
|
|
pending: true,
|
|
@@ -178,13 +178,12 @@ describe('OrganizationMemberRow', function() {
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
- expect(findWithText(wrapper.find('strong'), 'Invited')).toHaveLength(1);
|
|
|
-
|
|
|
- expect(wrapper.find('ResendInviteButton')).toHaveLength(0);
|
|
|
+ expect(wrapper.find('[data-test-id="member-role"]').text()).toBe('Invited Member');
|
|
|
+ expect(wrapper.find(resendButton).prop('disabled')).toBe(false);
|
|
|
});
|
|
|
|
|
|
it('shows "missing SSO link" message if user is registered and needs link', function() {
|
|
|
- const wrapper = shallow(
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
<OrganizationMemberRow
|
|
|
{...props}
|
|
|
member={{
|
|
@@ -193,13 +192,12 @@ describe('OrganizationMemberRow', function() {
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
- expect(findWithText(wrapper.find('strong'), 'Invited')).toHaveLength(0);
|
|
|
- expect(findWithText(wrapper.find('strong'), 'Missing SSO Link')).toHaveLength(1);
|
|
|
- expect(wrapper.find('ResendInviteButton')).toHaveLength(0);
|
|
|
+ expect(wrapper.find('[data-test-id="member-role"]').text()).toBe('Member');
|
|
|
+ expect(wrapper.find(resendSsoButton).prop('disabled')).toBe(true);
|
|
|
});
|
|
|
|
|
|
- it('has "Resend Invite" button only if `canAddMembers` is true and no link', function() {
|
|
|
- const wrapper = shallow(
|
|
|
+ it('has "Resend SSO link" button only if `canAddMembers` is true and no link', function() {
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
<OrganizationMemberRow
|
|
|
{...props}
|
|
|
canAddMembers
|
|
@@ -209,7 +207,7 @@ describe('OrganizationMemberRow', function() {
|
|
|
/>
|
|
|
);
|
|
|
|
|
|
- expect(wrapper.find('ResendInviteButton')).toHaveLength(1);
|
|
|
+ expect(wrapper.find(resendSsoButton).prop('disabled')).toBe(false);
|
|
|
});
|
|
|
|
|
|
it('has 2fa warning if user is linked does not have 2fa enabled', function() {
|
|
@@ -228,8 +226,8 @@ describe('OrganizationMemberRow', function() {
|
|
|
}}
|
|
|
/>
|
|
|
);
|
|
|
- expect(wrapper.find('NoTwoFactorIcon')).toHaveLength(1);
|
|
|
- expect(wrapper.find('HasTwoFactorIcon')).toHaveLength(0);
|
|
|
+
|
|
|
+ expect(wrapper.find('AuthIcon').prop('has2fa')).toBe(false);
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -243,22 +241,19 @@ describe('OrganizationMemberRow', function() {
|
|
|
};
|
|
|
|
|
|
it('has button to leave organization and no button to remove', function() {
|
|
|
- const wrapper = shallow(<OrganizationMemberRow {...props} memberCanLeave />);
|
|
|
- expect(findWithText(wrapper.find('Button'), 'Leave')).toHaveLength(1);
|
|
|
- expect(findWithText(wrapper.find('Button'), 'Remove')).toHaveLength(0);
|
|
|
+ const wrapper = mountWithTheme(<OrganizationMemberRow {...props} memberCanLeave />);
|
|
|
+
|
|
|
+ expect(wrapper.find(leaveButton).exists()).toBe(true);
|
|
|
+ expect(wrapper.find(removeButton).exists()).toBe(false);
|
|
|
});
|
|
|
|
|
|
it('has disabled button to leave organization and no button to remove when member can not leave', function() {
|
|
|
- const wrapper = shallow(
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
<OrganizationMemberRow {...props} memberCanLeave={false} />
|
|
|
);
|
|
|
- expect(findWithText(wrapper.find('Button'), 'Leave')).toHaveLength(1);
|
|
|
- expect(
|
|
|
- findWithText(wrapper.find('Button'), 'Leave')
|
|
|
- .first()
|
|
|
- .prop('disabled')
|
|
|
- ).toBe(true);
|
|
|
- expect(findWithText(wrapper.find('Button'), 'Remove')).toHaveLength(0);
|
|
|
+
|
|
|
+ expect(wrapper.find(leaveButton).prop('disabled')).toBe(true);
|
|
|
+ expect(wrapper.find(removeButton).exists()).toBe(false);
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -268,24 +263,23 @@ describe('OrganizationMemberRow', function() {
|
|
|
};
|
|
|
|
|
|
it('does not have Leave button', function() {
|
|
|
- const wrapper = shallow(<OrganizationMemberRow {...props} memberCanLeave />);
|
|
|
+ const wrapper = mountWithTheme(<OrganizationMemberRow {...props} memberCanLeave />);
|
|
|
|
|
|
- expect(findWithText(wrapper.find('Button'), 'Leave')).toHaveLength(0);
|
|
|
+ expect(wrapper.find(leaveButton).exists()).toBe(false);
|
|
|
});
|
|
|
|
|
|
it('has Remove disabled button when `canRemoveMembers` is false', function() {
|
|
|
- const wrapper = shallow(<OrganizationMemberRow {...props} />);
|
|
|
+ const wrapper = mountWithTheme(<OrganizationMemberRow {...props} />);
|
|
|
|
|
|
- expect(findWithText(wrapper.find('Button'), 'Remove')).toHaveLength(1);
|
|
|
- expect(findWithText(wrapper.find('Button'), 'Remove').prop('disabled')).toBe(true);
|
|
|
+ expect(wrapper.find(removeButton).prop('disabled')).toBe(true);
|
|
|
});
|
|
|
|
|
|
it('has Remove button when `canRemoveMembers` is true', function() {
|
|
|
- const wrapper = shallow(<OrganizationMemberRow {...props} canRemoveMembers />);
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
+ <OrganizationMemberRow {...props} canRemoveMembers />
|
|
|
+ );
|
|
|
|
|
|
- const removeButton = findWithText(wrapper.find('Button'), 'Remove');
|
|
|
- expect(removeButton).toHaveLength(1);
|
|
|
- expect(removeButton.first().prop('disabled')).toBe(false);
|
|
|
+ expect(wrapper.find(removeButton).prop('disabled')).toBe(false);
|
|
|
});
|
|
|
});
|
|
|
});
|