Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬
Ruby actioncablechat-widgetconversationcustomer-supportdashboarddesigndockerdocker-imageherokuintercomjavascriptlivechatopensourcerailsrubysassvuejswhatsappzendesk
import {
buildForwardedEmailHtml,
textToHtml,
} from 'dashboard/helper/forwardEmailHelper';
const labels = {
title: '---------- Forwarded message ---------',
from: 'From',
date: 'Date',
subject: 'Subject',
to: 'To',
};
describe('forwardEmailHelper', () => {
describe('textToHtml', () => {
it('escapes html and converts line breaks', () => {
expect(textToHtml('Hi <b>there</b>\nBye & thanks')).toBe(
'Hi <b>there</b><br>Bye & thanks'
);
});
});
describe('buildForwardedEmailHtml', () => {
const build = overrides =>
buildForwardedEmailHtml({
labels,
sender: { name: 'Jane Doe', email: '[email protected]' },
date: 'Thu, Sep 17, 2026 at 9:39 AM',
subject: 'Order #42',
recipients: ['[email protected]'],
bodyHtml: '<p>Original body</p>',
...overrides,
});
it('renders the gmail style header followed by the body', () => {
expect(build()).toBe(
[
'<div class="chatwoot_forward_header">',
'---------- Forwarded message ---------<br>',
'From: <b>Jane Doe</b> <<a href="mailto:[email protected]">[email protected]</a>><br>',
'Date: Thu, Sep 17, 2026 at 9:39 AM<br>',
'Subject: Order #42<br>',
'To: <<a href="mailto:[email protected]">[email protected]</a>>',
'</div><br><p>Original body</p>',
].join('')
);
});
it('omits the bold name when the sender has none', () => {
expect(build({ sender: { email: '[email protected]' } })).toContain(
'From: <<a href="mailto:[email protected]">[email protected]</a>><br>'
);
});
it('lists every recipient', () => {
expect(
build({ recipients: ['[email protected]', '[email protected]'] })
).toContain(
'To: <<a href="mailto:[email protected]">[email protected]</a>>, <<a href="mailto:[email protected]">[email protected]</a>>'
);
});
it('escapes header values but keeps the body html intact', () => {
const html = build({
sender: { name: '<script>x</script>', email: 'a"[email protected]' },
subject: 'Re: <img src=x onerror=alert(1)>',
bodyHtml: '<p>Keep <b>this</b></p>',
});
expect(html).toContain('<b><script>x</script></b>');
expect(html).toContain('mailto:a"[email protected]');
expect(html).toContain('Subject: Re: <img src=x onerror=alert(1)>');
expect(html).toContain('<p>Keep <b>this</b></p>');
expect(html).not.toContain('<script>');
});
});
});