feat: Replace contentTypeMixin within the component (#9802)

# Pull Request Template

## Description

This PR will completely remove the `contentTypeMixin` and be used in the
component as it is.

Fixes
https://linear.app/chatwoot/issue/CW-3465/rewrite-contenttypemixin-mixin-as-a-helper

## Type of change

- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

Take a look at this component
`app/javascript/dashboard/components/widgets/conversation/Message.vue`


## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
This commit is contained in:
Sivin Varghese 2024-07-22 13:08:04 +05:30 committed by GitHub
parent 79381b08cc
commit 81d7c51a84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 43 deletions

View File

@ -158,7 +158,7 @@ import InstagramStory from './bubble/InstagramStory.vue';
import InstagramStoryReply from './bubble/InstagramStoryReply.vue'; import InstagramStoryReply from './bubble/InstagramStoryReply.vue';
import Spinner from 'shared/components/Spinner.vue'; import Spinner from 'shared/components/Spinner.vue';
import alertMixin from 'shared/mixins/alertMixin'; import alertMixin from 'shared/mixins/alertMixin';
import contentTypeMixin from 'shared/mixins/contentTypeMixin'; import { CONTENT_TYPES } from 'shared/constants/contentType';
import { MESSAGE_TYPE, MESSAGE_STATUS } from 'shared/constants/messages'; import { MESSAGE_TYPE, MESSAGE_STATUS } from 'shared/constants/messages';
import { generateBotMessageContent } from './helpers/botMessageContentHelper'; import { generateBotMessageContent } from './helpers/botMessageContentHelper';
import { BUS_EVENTS } from 'shared/constants/busEvents'; import { BUS_EVENTS } from 'shared/constants/busEvents';
@ -184,7 +184,7 @@ export default {
InstagramStoryReply, InstagramStoryReply,
Spinner, Spinner,
}, },
mixins: [alertMixin, messageFormatterMixin, contentTypeMixin], mixins: [alertMixin, messageFormatterMixin],
props: { props: {
data: { data: {
type: Object, type: Object,
@ -482,6 +482,9 @@ export default {
} }
return ''; return '';
}, },
isEmailContentType() {
return this.contentType === CONTENT_TYPES.INCOMING_EMAIL;
},
}, },
watch: { watch: {
data() { data() {

View File

@ -1,9 +0,0 @@
import { CONTENT_TYPES } from '../constants/contentType';
export default {
computed: {
isEmailContentType() {
return this.contentType === CONTENT_TYPES.INCOMING_EMAIL;
},
},
};

View File

@ -1,32 +0,0 @@
import { shallowMount } from '@vue/test-utils';
import contentTypeMixin from '../contentTypeMixin';
describe('contentTypeMixin', () => {
it('returns true if contentType is incoming_email', () => {
const Component = {
render() {},
mixins: [contentTypeMixin],
computed: {
contentType() {
return 'incoming_email';
},
},
};
const wrapper = shallowMount(Component);
expect(wrapper.vm.isEmailContentType).toBe(true);
});
it('returns false if contentType is not incoming_email', () => {
const Component = {
render() {},
mixins: [contentTypeMixin],
computed: {
contentType() {
return 'input_select';
},
},
};
const wrapper = shallowMount(Component);
expect(wrapper.vm.isEmailContentType).toBe(false);
});
});