Files
gochat/frontend/app/javascript/widget/components/ConversationWrap.spec.js
T
rogee 9b8d575657
Build and publish Docker images / Build and publish images (push) Successful in 2m23s
fix: reopen pending human conversations
2026-09-14 18:55:51 +08:00

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);
});
});