From 2e5ef22585f192f09dcb50e74a4043d6d17e99eb Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Tue, 24 Aug 2021 12:19:59 -0400 Subject: [PATCH] Fixes issue where the wrong text appeared in modal --- .../DeleteRoleConfirmationModal.js | 7 +++--- .../DeleteRoleConfirmationModal.test.js | 23 ++++++++++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/awx/ui/src/components/ResourceAccessList/DeleteRoleConfirmationModal.js b/awx/ui/src/components/ResourceAccessList/DeleteRoleConfirmationModal.js index 640b315918..38f56f0d0f 100644 --- a/awx/ui/src/components/ResourceAccessList/DeleteRoleConfirmationModal.js +++ b/awx/ui/src/components/ResourceAccessList/DeleteRoleConfirmationModal.js @@ -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 ( , ]} > - {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.`}
diff --git a/awx/ui/src/components/ResourceAccessList/DeleteRoleConfirmationModal.test.js b/awx/ui/src/components/ResourceAccessList/DeleteRoleConfirmationModal.test.js index 2c0aa78093..2e75ef5c8a 100644 --- a/awx/ui/src/components/ResourceAccessList/DeleteRoleConfirmationModal.test.js +++ b/awx/ui/src/components/ResourceAccessList/DeleteRoleConfirmationModal.test.js @@ -14,7 +14,7 @@ const role = { }; describe('', () => { - test('should render initially', () => { + test('should render Team confirmation modal', () => { const wrapper = mountWithContexts( ', () => { /> ); 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( + {}} + 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?' + ); }); });