Build and publish Docker images / Build and publish images (push) Successful in 2m23s
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
import { shallowMount } from '@vue/test-utils';
|
|
import { createStore } from 'vuex';
|
|
import { describe, expect, it } from 'vitest';
|
|
import ConversationWrap from './ConversationWrap.vue';
|
|
|
|
const mountConversation = ({
|
|
status = 'pending',
|
|
aiTakeoverActive = false,
|
|
isAgentTyping = false,
|
|
messageType = 0,
|
|
} = {}) =>
|
|
shallowMount(ConversationWrap, {
|
|
props: { groupedMessages: [] },
|
|
global: {
|
|
plugins: [
|
|
createStore({
|
|
getters: {
|
|
'appConfig/darkMode': () => 'light',
|
|
'conversation/getEarliestMessage': () => ({ id: 1 }),
|
|
'conversation/getLastMessage': () => ({
|
|
message_type: messageType,
|
|
}),
|
|
'conversation/getAllMessagesLoaded': () => true,
|
|
'conversation/getIsFetchingList': () => false,
|
|
'conversation/getConversationSize': () => 1,
|
|
'conversation/getIsAgentTyping': () => isAgentTyping,
|
|
'conversationAttributes/getConversationParams': () => ({
|
|
id: 1,
|
|
status,
|
|
aiTakeoverActive,
|
|
}),
|
|
},
|
|
}),
|
|
],
|
|
},
|
|
});
|
|
|
|
describe('ConversationWrap', () => {
|
|
it('does not show typing for an ordinary pending conversation', () => {
|
|
const wrapper = mountConversation();
|
|
|
|
expect(wrapper.vm.showStatusIndicator).toBe(false);
|
|
});
|
|
|
|
it('shows typing while an AI takeover is waiting for a reply', () => {
|
|
const wrapper = mountConversation({ aiTakeoverActive: true });
|
|
|
|
expect(wrapper.vm.showStatusIndicator).toBe(true);
|
|
});
|
|
|
|
it('shows typing when an explicit agent typing event is active', () => {
|
|
const wrapper = mountConversation({
|
|
status: 'open',
|
|
isAgentTyping: true,
|
|
});
|
|
|
|
expect(wrapper.vm.showStatusIndicator).toBe(true);
|
|
});
|
|
});
|