mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(mod queue): stop resurfacing stale pending history (#1130)
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { filterVisibleModQueueFeed, getModQueueCommentRoute, getQueuedCommentRouteState } from '../mod-queue-utils';
|
||||
import {
|
||||
filterVisibleModQueueFeed,
|
||||
getModQueueCommentRoute,
|
||||
getQueuedCommentRouteState,
|
||||
getVisibleQueuedCommentHistory,
|
||||
shouldKeepQueuedCommentHistory,
|
||||
} from '../mod-queue-utils';
|
||||
|
||||
describe('mod queue utils', () => {
|
||||
it('keeps all queue comments unless they were locally dismissed', () => {
|
||||
@@ -31,6 +37,30 @@ describe('mod queue utils', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps only terminal local moderation states in queue history', () => {
|
||||
expect(shouldKeepQueuedCommentHistory({ cid: 'pending', pendingApproval: true })).toBe(false);
|
||||
expect(shouldKeepQueuedCommentHistory({ cid: 'published', pendingApproval: false })).toBe(false);
|
||||
expect(shouldKeepQueuedCommentHistory({ cid: 'approved', approved: true, pendingApproval: false })).toBe(true);
|
||||
expect(shouldKeepQueuedCommentHistory({ cid: 'rejected', approved: false, pendingApproval: false })).toBe(true);
|
||||
expect(shouldKeepQueuedCommentHistory({ cid: 'removed', pendingApproval: true, removed: true })).toBe(true);
|
||||
});
|
||||
|
||||
it('does not resurface stale pending history after the live feed drops it', () => {
|
||||
const feed = [{ cid: 'live-pending', communityAddress: 'tech.eth', pendingApproval: true }];
|
||||
const history = [
|
||||
{ cid: 'stale-pending', communityAddress: 'tech.eth', pendingApproval: true },
|
||||
{ cid: 'live-pending', communityAddress: 'tech.eth', pendingApproval: true },
|
||||
{ cid: 'approved', approved: true, communityAddress: 'tech.eth', pendingApproval: false },
|
||||
{ cid: 'rejected', approved: false, communityAddress: 'tech.eth', pendingApproval: false },
|
||||
{ cid: 'other-board-approved', approved: true, communityAddress: 'g.eth', pendingApproval: false },
|
||||
];
|
||||
|
||||
expect(getVisibleQueuedCommentHistory(feed, history, ['tech.eth'])).toEqual([
|
||||
{ cid: 'approved', approved: true, communityAddress: 'tech.eth', pendingApproval: false },
|
||||
{ cid: 'rejected', approved: false, communityAddress: 'tech.eth', pendingApproval: false },
|
||||
]);
|
||||
});
|
||||
|
||||
it('builds excerpt routes from the comment permalink cid', () => {
|
||||
expect(getModQueueCommentRoute('g', 'reply-cid')).toBe('/g/thread/reply-cid');
|
||||
expect(getModQueueCommentRoute('g', undefined)).toBeUndefined();
|
||||
|
||||
Reference in New Issue
Block a user