Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
88 lines
2.5 KiB
JavaScript
88 lines
2.5 KiB
JavaScript
import { useConversationLabels } from '../useConversationLabels';
|
|
import { useStore, useStoreGetters } from 'dashboard/composables/store';
|
|
|
|
vi.mock('dashboard/composables/store');
|
|
|
|
describe('useConversationLabels', () => {
|
|
let store;
|
|
let getters;
|
|
|
|
beforeEach(() => {
|
|
store = {
|
|
getters: {
|
|
'conversationLabels/getConversationLabels': vi.fn(),
|
|
},
|
|
dispatch: vi.fn(),
|
|
};
|
|
getters = {
|
|
getSelectedChat: { value: { id: 1 } },
|
|
'labels/getLabels': {
|
|
value: [
|
|
{ id: 1, title: 'Label 1' },
|
|
{ id: 2, title: 'Label 2' },
|
|
{ id: 3, title: 'Label 3' },
|
|
],
|
|
},
|
|
};
|
|
|
|
useStore.mockReturnValue(store);
|
|
useStoreGetters.mockReturnValue(getters);
|
|
});
|
|
|
|
it('should return the correct computed properties', () => {
|
|
store.getters['conversationLabels/getConversationLabels'].mockReturnValue([
|
|
'Label 1',
|
|
'Label 2',
|
|
]);
|
|
const { accountLabels, savedLabels, activeLabels, inactiveLabels } =
|
|
useConversationLabels();
|
|
|
|
expect(accountLabels.value).toEqual(getters['labels/getLabels'].value);
|
|
expect(savedLabels.value).toEqual(['Label 1', 'Label 2']);
|
|
expect(activeLabels.value).toEqual([
|
|
{ id: 1, title: 'Label 1' },
|
|
{ id: 2, title: 'Label 2' },
|
|
]);
|
|
expect(inactiveLabels.value).toEqual([{ id: 3, title: 'Label 3' }]);
|
|
});
|
|
|
|
it('should update labels correctly', async () => {
|
|
const { onUpdateLabels } = useConversationLabels();
|
|
await onUpdateLabels(['Label 1', 'Label 3']);
|
|
|
|
expect(store.dispatch).toHaveBeenCalledWith('conversationLabels/update', {
|
|
conversationId: 1,
|
|
labels: ['Label 1', 'Label 3'],
|
|
});
|
|
});
|
|
|
|
it('should add a label to the conversation', () => {
|
|
store.getters['conversationLabels/getConversationLabels'].mockReturnValue([
|
|
'Label 1',
|
|
]);
|
|
const { addLabelToConversation } = useConversationLabels();
|
|
|
|
addLabelToConversation({ title: 'Label 2' });
|
|
|
|
expect(store.dispatch).toHaveBeenCalledWith('conversationLabels/update', {
|
|
conversationId: 1,
|
|
labels: ['Label 1', 'Label 2'],
|
|
});
|
|
});
|
|
|
|
it('should remove a label from the conversation', () => {
|
|
store.getters['conversationLabels/getConversationLabels'].mockReturnValue([
|
|
'Label 1',
|
|
'Label 2',
|
|
]);
|
|
const { removeLabelFromConversation } = useConversationLabels();
|
|
|
|
removeLabelFromConversation('Label 2');
|
|
|
|
expect(store.dispatch).toHaveBeenCalledWith('conversationLabels/update', {
|
|
conversationId: 1,
|
|
labels: ['Label 1'],
|
|
});
|
|
});
|
|
});
|