Feature: Customise widget for bot conversations (#834)
* Feature: Customise widget for bot conversations
This commit is contained in:
19
app/javascript/widget/mixins/configMixin.js
Normal file
19
app/javascript/widget/mixins/configMixin.js
Normal file
@@ -0,0 +1,19 @@
|
||||
export default {
|
||||
computed: {
|
||||
hideInputForBotConversations() {
|
||||
return window.chatwootWebChannel.hideInputForBotConversations;
|
||||
},
|
||||
useInboxAvatarForBot() {
|
||||
return window.chatwootWidgetDefaults.useInboxAvatarForBot;
|
||||
},
|
||||
hasAConnectedAgentBot() {
|
||||
return !!window.chatwootWebChannel.hasAConnectedAgentBot;
|
||||
},
|
||||
inboxAvatarUrl() {
|
||||
return window.chatwootWebChannel.avatarUrl;
|
||||
},
|
||||
channelConfig() {
|
||||
return window.chatwootWebChannel;
|
||||
},
|
||||
},
|
||||
};
|
||||
35
app/javascript/widget/mixins/specs/configMixin.spec.js
Normal file
35
app/javascript/widget/mixins/specs/configMixin.spec.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { createWrapper } from '@vue/test-utils';
|
||||
import configMixin from '../configMixin';
|
||||
import Vue from 'vue';
|
||||
|
||||
global.chatwootWebChannel = {
|
||||
hideInputForBotConversations: true,
|
||||
avatarUrl: 'https://test.url',
|
||||
hasAConnectedAgentBot: 'AgentBot',
|
||||
};
|
||||
|
||||
global.chatwootWidgetDefaults = {
|
||||
useInboxAvatarForBot: true,
|
||||
};
|
||||
|
||||
describe('configMixin', () => {
|
||||
test('returns config', () => {
|
||||
const Component = {
|
||||
render() {},
|
||||
title: 'TestComponent',
|
||||
mixins: [configMixin],
|
||||
};
|
||||
const Constructor = Vue.extend(Component);
|
||||
const vm = new Constructor().$mount();
|
||||
const wrapper = createWrapper(vm);
|
||||
expect(wrapper.vm.hideInputForBotConversations).toBe(true);
|
||||
expect(wrapper.vm.hasAConnectedAgentBot).toBe(true);
|
||||
expect(wrapper.vm.useInboxAvatarForBot).toBe(true);
|
||||
expect(wrapper.vm.inboxAvatarUrl).toBe('https://test.url');
|
||||
expect(wrapper.vm.channelConfig).toEqual({
|
||||
hideInputForBotConversations: true,
|
||||
avatarUrl: 'https://test.url',
|
||||
hasAConnectedAgentBot: 'AgentBot',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user