mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(edit menu): read canonical author bans
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user