diff --git a/app/javascript/dashboard/helper/specs/emailQuoteExtractor.spec.js b/app/javascript/dashboard/helper/specs/emailQuoteExtractor.spec.js index 1a2c02ec9..09210094e 100644 --- a/app/javascript/dashboard/helper/specs/emailQuoteExtractor.spec.js +++ b/app/javascript/dashboard/helper/specs/emailQuoteExtractor.spec.js @@ -241,6 +241,44 @@ describe('EmailQuoteExtractor', () => { expect(c.textContent).toContain('Pat'); expect(EmailQuoteExtractor.hasQuotes(html)).toBe(false); }); + + it('cuts wrapper-level siblings when the marker is in a nested child', () => { + // Outlook nested shape: marker sits in an inner block, but the actual + // forwarded body lives in later siblings of the outer wrapper. Strategy + // 2 selects the outer match so the wrapper's later siblings strip too. + const html = + '
My reply.
' + + '-----Original Message-----
From: Sam
' + + 'Old body
' + + '-----Original Message-----
' + + 'From: Sam
' + + 'Old quoted body
' + + 'Reply pretending to be bottom-posted
'; + const c = cleaned(html); + expect(c.textContent).not.toContain('Original Message'); + expect(c.textContent).not.toContain('From: Sam'); + expect(c.textContent).not.toContain('Old quoted body'); + expect(c.textContent).not.toContain( + 'Reply pretending to be bottom-posted' + ); + }); }); describe('multi-line attribution headers (From / Sent / To)', () => {