Merge pull request #10934 from AlexSCorey/10925-WrongDeleteModal

Fixes issue where the wrong text appeared in modal
This commit is contained in:
Alex Corey 2021-08-25 11:45:20 -04:00 committed by GitHub
commit fb0e55fd1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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?'
);
});
});