fix(edit menu): read canonical author bans

This commit is contained in:
Tommaso Casaburi
2026-06-07 22:46:20 +07:00
parent aa5a985201
commit 38d18b141e
2 changed files with 30 additions and 1 deletions
@@ -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<HTMLInputElement>('[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 = {
+1 -1
View File
@@ -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);