@@ -390,6 +390,57 @@ describe('FilterHandler recipient spam overrides', () => {
390390 expect ( getSpamResult ( result ) ) . to . not . exist ;
391391 } ) ;
392392
393+ it ( 'should not let a spam override replace a filter mailbox destination' , async ( ) => {
394+ const mailbox = new ObjectId ( ) ;
395+ const { addOptions, result } = await runCase ( {
396+ overrideFlags : [ 'spam' ] ,
397+ filters : [
398+ {
399+ _id : new ObjectId ( ) ,
400+ query : {
401+ headers : {
402+ from : 'alice@example.com'
403+ }
404+ } ,
405+ action : {
406+ mailbox
407+ }
408+ }
409+ ]
410+ } ) ;
411+
412+ expect ( addOptions . mailbox ) . to . equal ( mailbox ) ;
413+ expect ( addOptions . path ) . to . not . exist ;
414+ expect ( addOptions . specialUse ) . to . not . exist ;
415+ expect ( getSpamResult ( result ) ) . to . not . exist ;
416+ } ) ;
417+
418+ it ( 'should prefer a filter mailbox destination over a spam action' , async ( ) => {
419+ const mailbox = new ObjectId ( ) ;
420+ const { addOptions, result } = await runCase ( {
421+ filters : [
422+ {
423+ _id : new ObjectId ( ) ,
424+ query : {
425+ headers : {
426+ from : 'alice@example.com'
427+ }
428+ } ,
429+ action : {
430+ mailbox,
431+ spam : true
432+ }
433+ }
434+ ]
435+ } ) ;
436+
437+ expect ( addOptions . mailbox ) . to . equal ( mailbox ) ;
438+ expect ( addOptions . path ) . to . not . exist ;
439+ expect ( addOptions . specialUse ) . to . not . exist ;
440+ expect ( getSpamResult ( result ) ) . to . not . exist ;
441+ expect ( addOptions . prepared . mimeTree . header . some ( header => / ^ W D - M a i l - C l a s s i f i c a t i o n : / i. test ( header ) ) ) . to . equal ( false ) ;
442+ } ) ;
443+
393444 it ( 'should prefer ham when mixed with spam-like override flags' , async ( ) => {
394445 const { addOptions } = await runCase ( {
395446 overrideFlags : [ 'blacklist' , 'ham' ]
0 commit comments