Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ebapp into fix/chatgpt-modal-height
  • Loading branch information
paulobernardoaf committed Nov 14, 2023
2 parents 77653af + d13e7d0 commit 868c29e
Show file tree
Hide file tree
Showing 8 changed files with 1,044 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/components/whatsAppCatalogs/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<div class="whatsapp-catalog-card__wrapper__actions">
<unnnic-switch
ref="catalogConnectSwitch"
:value="catalog.is_connected"
use-v-model
size="small"
Expand All @@ -31,6 +32,7 @@
/>
<unnnic-switch
v-if="catalog.is_connected"
ref="cartEnableSwitch"
:value="enabledCart"
use-v-model
size="small"
Expand All @@ -55,7 +57,7 @@
catalog: {
type: Object,
required: true,
default: () => {},
default: /* istanbul ignore next */ () => {},
},
enabledCart: {
type: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/components/whatsAppCatalogs/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
await this.getCommerceSettings({ appUuid });
await this.getWhatsAppCloudCatalogs({ appUuid, params });
if (this.errorWhatsAppCloudCatalog) {
if (this.errorWhatsAppCloudCatalogs) {
unnnicCallAlert({
props: {
text: this.$t('WhatsApp.catalog.error.fetch_catalogs'),
Expand Down
24 changes: 13 additions & 11 deletions tests/unit/specs/components/config/external/chatgpt/Config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ singleApp.config = {
rules: 'rules',
knowledge_base: 'base',
ai_model: 'gpt-3.5-turbo-16k',
voice_tone: [{
'value': '1',
'label': 'Neutral',
}],
voice_tone: [
{
value: '1',
label: 'Neutral',
},
],
conversation_style: [
{
'value': '0.7,0.8',
'label': 'Creative',
'description': 'Responds creatively, less objectively'
}
value: '0.7,0.8',
label: 'Creative',
description: 'Responds creatively, less objectively',
},
],
};

Expand Down Expand Up @@ -226,9 +228,9 @@ describe('components/config/external/chatgpt/Config.vue', () => {
ai_model: 'gpt-3.5-turbo-16k',
rules: 'rules 1',
knowledge_base: 'knowledge base 1',
temperature: "0.7",
top_p: "0.8",
voice_tone: "Em tom Neutral",
temperature: '0.7',
top_p: '0.8',
voice_tone: 'Em tom Neutral',
},
},
});
Expand Down
80 changes: 80 additions & 0 deletions tests/unit/specs/components/whatsAppCatalogs/Card.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import Vuex from 'vuex';
import { mount, createLocalVue } from '@vue/test-utils';
import Card from '@/components/whatsAppCatalogs/Card.vue';
import '@weni/unnnic-system';
import i18n from '@/utils/plugins/i18n';

const localVue = createLocalVue();
localVue.use(Vuex);

const mountComponent = async ({
errorDisableCatalog = false,
enabledCart = false,
catalog = {},
} = {}) => {
const state = {
errorDisableCatalog,
};

const actions = {
disableWhatsAppCloudCatalogs: jest.fn(),
};

const store = new Vuex.Store({
modules: {
WhatsAppCloud: {
namespaced: true,
actions,
state,
},
},
});

const wrapper = mount(Card, {
localVue,
store,
i18n,
propsData: {
catalog,
enabledCart,
},
});

return { wrapper, actions, state };
};

describe('components/whatsAppCatalog/Card.vue', () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('should be rendered properly', async () => {
const { wrapper } = await mountComponent();
expect(wrapper).toMatchSnapshot();
});

describe('catalog connect emits', () => {
it('should emit enable on toggle catalog connect', async () => {
const { wrapper } = await mountComponent();
const toggle = wrapper.findComponent({ ref: 'catalogConnectSwitch' });
toggle.vm.$emit('input', true);
expect(wrapper.emitted().enable).toBeTruthy();
});

it('should emit disable on toggle catalog connect', async () => {
const { wrapper } = await mountComponent();
const toggle = wrapper.findComponent({ ref: 'catalogConnectSwitch' });
toggle.vm.$emit('input', false);
expect(wrapper.emitted().disable).toBeTruthy();
});
});

describe('toggleCart emit', () => {
it('should emit toggleCart on switch click', async () => {
const { wrapper } = await mountComponent({ catalog: { is_connected: true } });
const toggle = wrapper.findComponent({ ref: 'cartEnableSwitch' });
toggle.trigger('click');
expect(wrapper.emitted().toggleCart).toBeTruthy();
});
});
});
Loading

0 comments on commit 868c29e

Please sign in to comment.