fix(mod queue): stop resurfacing stale pending history (#1130)

This commit is contained in:
Tommaso Casaburi
2026-05-15 18:35:41 +07:00
committed by GitHub
parent 84864019f5
commit a6f6e42bd7
3 changed files with 67 additions and 21 deletions
@@ -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();