Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Hide deleted messages on widget side (#2614)
- Loading branch information
Showing
13 changed files
with
222 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default { | ||
computed: { | ||
messageContentAttributes() { | ||
const { content_attributes: attribute = {} } = this.message; | ||
return attribute; | ||
}, | ||
hasAttachments() { | ||
return !!( | ||
this.message.attachments && this.message.attachments.length > 0 | ||
); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export default { | ||
nonDeletedMessage: { | ||
content: 'Hey', | ||
content_attributes: {}, | ||
attachments: [ | ||
{ | ||
data_url: 'https://assets.com/kseb-bill.pdf', | ||
extension: null, | ||
file_type: 'file', | ||
}, | ||
], | ||
content_type: 'text', | ||
conversation_id: 1, | ||
created_at: 1626111625, | ||
id: 1, | ||
message_type: 0, | ||
}, | ||
deletedMessage: { | ||
content: 'This message was deleted', | ||
content_attributes: { deleted: true }, | ||
content_type: null, | ||
conversation_id: 1, | ||
created_at: 1626111634, | ||
id: 2, | ||
message_type: 1, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { shallowMount } from '@vue/test-utils'; | ||
import messageMixin from '../messageMixin'; | ||
import messages from './messageFixture'; | ||
|
||
describe('messageMixin', () => { | ||
let Component = { | ||
render() {}, | ||
title: 'TestComponent', | ||
mixins: [messageMixin], | ||
}; | ||
|
||
it('deleted messages', async () => { | ||
const wrapper = shallowMount(Component, { | ||
data() { | ||
return { | ||
message: messages.deletedMessage, | ||
}; | ||
}, | ||
}); | ||
expect(wrapper.vm.messageContentAttributes).toEqual({ | ||
deleted: true, | ||
}); | ||
expect(wrapper.vm.hasAttachments).toBe(false); | ||
}); | ||
it('non-deleted messages', async () => { | ||
const wrapper = shallowMount(Component, { | ||
data() { | ||
return { | ||
message: messages.nonDeletedMessage, | ||
}; | ||
}, | ||
}); | ||
expect(wrapper.vm.deletedMessage).toBe(undefined); | ||
expect(wrapper.vm.messageContentAttributes).toEqual({}); | ||
expect(wrapper.vm.hasAttachments).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.