diff --git a/src/components/edit-menu/__tests__/edit-menu.test.tsx b/src/components/edit-menu/__tests__/edit-menu.test.tsx index 915cac32..8e1d4822 100644 --- a/src/components/edit-menu/__tests__/edit-menu.test.tsx +++ b/src/components/edit-menu/__tests__/edit-menu.test.tsx @@ -398,6 +398,35 @@ describe('EditMenu', () => { }); }); + it('lets moderators clear an existing canonical author ban', async () => { + testState.privileges = { + isAccountCommentAuthor: false, + isAccountMod: true, + isCommentAuthorMod: false, + }; + + await renderMenu({ + ...basePost, + author: { + ...basePost.author, + community: { + banExpiresAt: Math.floor(new Date('2026-03-12T00:00:00Z').getTime() / 1000), + }, + }, + }); + await openMenu(); + + const banCheckbox = getCheckbox('banUser'); + expect(banCheckbox?.checked).toBe(true); + expect(container.querySelector('[data-testid="ban-duration-input"]')?.value).toBe('4'); + + await click(banCheckbox); + await clickButton('save'); + + expect(testState.publishCommentModerationMock).toHaveBeenCalledOnce(); + expect(testState.modOptions?.commentModeration?.author).toBeUndefined(); + }); + it('does not enable purge when the confirmation is rejected', async () => { confirmSpy.mockReturnValue(false); testState.privileges = { diff --git a/src/components/edit-menu/edit-menu.tsx b/src/components/edit-menu/edit-menu.tsx index 696ac406..32028a4f 100644 --- a/src/components/edit-menu/edit-menu.tsx +++ b/src/components/edit-menu/edit-menu.tsx @@ -38,7 +38,7 @@ const EditMenu = ({ post }: { post: Comment }) => { const communityAddress = getCommentCommunityAddress(resolvedPost); const archived = isCommentArchived(resolvedPost); const authorDisplayName = resolvedPost?.author?.displayName; - const modBanExpiresAt = resolvedPost?.commentModeration?.author?.banExpiresAt; + const modBanExpiresAt = resolvedPost?.author?.community?.banExpiresAt ?? resolvedPost?.commentModeration?.author?.banExpiresAt; const purged = resolvedPost?.commentModeration?.purged ?? false; const [isEditMenuOpen, setIsEditMenuOpen] = useState(false); const [isContentEditorOpen, setIsContentEditorOpen] = useState(false);