diff --git a/src/frontend/apps/desk/src/features/mail-domains/access-management/components/AccessAction.tsx b/src/frontend/apps/desk/src/features/mail-domains/access-management/components/AccessAction.tsx
index ae8ff60db..b8f1f053f 100644
--- a/src/frontend/apps/desk/src/features/mail-domains/access-management/components/AccessAction.tsx
+++ b/src/frontend/apps/desk/src/features/mail-domains/access-management/components/AccessAction.tsx
@@ -46,47 +46,52 @@ export const AccessAction = ({
isOpen={isDropOpen}
>
-
-
+ {(mailDomain.abilities.put || mailDomain.abilities.patch) && (
+
+ )}
+ {mailDomain.abilities.delete && (
+
+ )}
- {isModalRoleOpen && (
- setIsModalRoleOpen(false)}
- slug={mailDomain.slug}
- />
- )}
- {isModalDeleteOpen && (
+ {isModalRoleOpen &&
+ (mailDomain.abilities.put || mailDomain.abilities.patch) && (
+ setIsModalRoleOpen(false)}
+ slug={mailDomain.slug}
+ />
+ )}
+ {isModalDeleteOpen && mailDomain.abilities.delete && (
{
).not.toBeInTheDocument();
});
+ it('does not render "Update role" button when mailDomain lacks "put" and "patch" abilities', async () => {
+ const mailDomainWithoutUpdate = {
+ ...mockMailDomain,
+ abilities: {
+ ...mockMailDomain.abilities,
+ put: false,
+ patch: false,
+ },
+ };
+
+ renderAccessAction(Role.ADMIN, mockAccess, mailDomainWithoutUpdate);
+
+ const openButton = screen.getByLabelText('Open the access options modal');
+ await userEvent.click(openButton);
+
+ expect(
+ screen.queryByLabelText(
+ 'Open the modal to update the role of this access',
+ ),
+ ).not.toBeInTheDocument();
+ });
+
it('opens the role update modal with correct props when "Update role" is clicked', async () => {
renderAccessAction();
@@ -101,6 +123,25 @@ describe('AccessAction', () => {
);
});
+ it('does not render "Remove from domain" button when mailDomain lacks "delete" ability', async () => {
+ const mailDomainWithoutDelete = {
+ ...mockMailDomain,
+ abilities: {
+ ...mockMailDomain.abilities,
+ delete: false,
+ },
+ };
+
+ renderAccessAction(Role.ADMIN, mockAccess, mailDomainWithoutDelete);
+
+ const openButton = screen.getByLabelText('Open the access options modal');
+ await userEvent.click(openButton);
+
+ expect(
+ screen.queryByLabelText('Open the modal to delete this access'),
+ ).not.toBeInTheDocument();
+ });
+
it('opens the delete modal with correct props when "Remove from domain" is clicked', async () => {
renderAccessAction();