Improve moderation controls and term management
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
assessCommunityModeration,
|
||||
findLocalModerationMatches,
|
||||
normalizeModerationTerm,
|
||||
parseModerationTermBatch,
|
||||
type CommunityModerationPolicy
|
||||
} from './community-moderation';
|
||||
|
||||
@@ -34,6 +35,27 @@ describe('community moderation policy', () => {
|
||||
expect(normalizeModerationTerm(' Rogue\u00a0Agent ')).toBe('rogue agent');
|
||||
});
|
||||
|
||||
it('parses pasted terms with automatic word and phrase matching', () => {
|
||||
expect(parseModerationTermBatch('weapon\nkill, machine gun; assault rifle')).toEqual({
|
||||
terms: [
|
||||
{ value: 'weapon', normalizedValue: 'weapon', matchMode: 'word' },
|
||||
{ value: 'kill', normalizedValue: 'kill', matchMode: 'word' },
|
||||
{ value: 'machine gun', normalizedValue: 'machine gun', matchMode: 'phrase' },
|
||||
{ value: 'assault rifle', normalizedValue: 'assault rifle', matchMode: 'phrase' }
|
||||
],
|
||||
duplicateCount: 0
|
||||
});
|
||||
});
|
||||
|
||||
it('deduplicates pasted terms after compatibility and case normalization', () => {
|
||||
const parsed = parseModerationTermBatch('Weapon\nweapon\nMACHINE GUN\nmachine gun');
|
||||
expect(parsed.terms).toEqual([
|
||||
{ value: 'Weapon', normalizedValue: 'weapon', matchMode: 'word' },
|
||||
{ value: 'MACHINE GUN', normalizedValue: 'machine gun', matchMode: 'phrase' }
|
||||
]);
|
||||
expect(parsed.duplicateCount).toBe(2);
|
||||
});
|
||||
|
||||
it('allows an exact local exception to suppress a matching banned term', () => {
|
||||
const matches = findLocalModerationMatches('Rogue Agent tactics', 'comment', policy({
|
||||
detectPii: false,
|
||||
|
||||
Reference in New Issue
Block a user