feat: Adds support for image resize in the message bubble (#8182)

This commit is contained in:
Sivin Varghese
2023-11-08 14:11:47 +05:30
committed by GitHub
parent 5d224f2e04
commit e0f33e62af
3 changed files with 59 additions and 2 deletions

View File

@@ -28,6 +28,32 @@ describe('#MessageFormatter', () => {
});
});
describe('content with image and has "cw_image_height" query at the end of URL', () => {
it('should set image height correctly', () => {
const message =
'Chatwoot is an opensource tool. ![](http://chatwoot.com/chatwoot.png?cw_image_height=24px)';
expect(new MessageFormatter(message).formattedMessage).toMatch(
'<p>Chatwoot is an opensource tool. <img src="http://chatwoot.com/chatwoot.png?cw_image_height=24px" alt="" style="height: 24px;" /></p>'
);
});
it('should set image height correctly if its original size', () => {
const message =
'Chatwoot is an opensource tool. ![](http://chatwoot.com/chatwoot.png?cw_image_height=auto)';
expect(new MessageFormatter(message).formattedMessage).toMatch(
'<p>Chatwoot is an opensource tool. <img src="http://chatwoot.com/chatwoot.png?cw_image_height=auto" alt="" style="height: auto;" /></p>'
);
});
it('should not set height', () => {
const message =
'Chatwoot is an opensource tool. ![](http://chatwoot.com/chatwoot.png)';
expect(new MessageFormatter(message).formattedMessage).toMatch(
'<p>Chatwoot is an opensource tool. <img src="http://chatwoot.com/chatwoot.png" alt="" /></p>'
);
});
});
describe('tweets', () => {
it('should return the same string if not tags or @mentions', () => {
const message = 'Chatwoot is an opensource tool';