Fixes issue where the wrong text appeared in modal

This commit is contained in:
Alex Corey 2021-08-24 12:19:59 -04:00
parent e7dbe90cb5
commit 2e5ef22585
2 changed files with 25 additions and 5 deletions

View File

@ -8,10 +8,9 @@ import { Role } from 'types';
import AlertModal from '../AlertModal';
function DeleteRoleConfirmationModal({ role, username, onCancel, onConfirm }) {
const isTeamRole = () =>
const sourceOfRole = () =>
typeof role.team_id !== 'undefined' ? t`Team` : t`User`;
const title = t`Remove ${isTeamRole()} Access`;
const title = t`Remove ${sourceOfRole()} Access`;
return (
<AlertModal
variant="danger"
@ -38,7 +37,7 @@ function DeleteRoleConfirmationModal({ role, username, onCancel, onConfirm }) {
</Button>,
]}
>
{isTeamRole() ? (
{sourceOfRole() === 'Team' ? (
<>
{t`Are you sure you want to remove ${role.name} access from ${role.team_name}? Doing so affects all members of the team.`}
<br />

View File

@ -14,7 +14,7 @@ const role = {
};
describe('<DeleteRoleConfirmationModal />', () => {
test('should render initially', () => {
test('should render Team confirmation modal', () => {
const wrapper = mountWithContexts(
<DeleteRoleConfirmationModal
role={role}
@ -24,5 +24,26 @@ describe('<DeleteRoleConfirmationModal />', () => {
/>
);
wrapper.update();
expect(wrapper.find('ModalBoxBody').text()).toBe(
'Are you sure you want to remove Member access from The Team? Doing so affects all members of the team.If you only want to remove access for this particular user, please remove them from the team.'
);
expect(wrapper.find('Title').text()).toBe('Remove Team Access');
});
test('should render the User confirmation delete modal', () => {
delete role.team_id;
const wrapper = mountWithContexts(
<DeleteRoleConfirmationModal
role={role}
username="jane"
onCancel={() => {}}
onConfirm={() => {}}
/>
);
wrapper.update();
expect(wrapper.find('Title').text()).toBe('Remove User Access');
expect(wrapper.find('ModalBoxBody').text()).toBe(
'Are you sure you want to remove Member access from jane?'
);
});
});