Initial commit: Add logistics and order_detail message types
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
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>
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
import axios from 'axios';
|
||||
import { actions } from '../../labels';
|
||||
import * as types from '../../../mutation-types';
|
||||
import labelsList from './fixtures';
|
||||
|
||||
const commit = vi.fn();
|
||||
global.axios = axios;
|
||||
vi.mock('axios');
|
||||
|
||||
describe('#actions', () => {
|
||||
describe('#get', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
const mockedGet = vi.fn(url => {
|
||||
if (url === '/api/v1/labels') {
|
||||
return Promise.resolve({ data: { payload: labelsList } });
|
||||
}
|
||||
if (url === '/api/v1/accounts//cache_keys') {
|
||||
return Promise.resolve({ data: { cache_keys: { labels: 0 } } });
|
||||
}
|
||||
// Return default value or throw an error for unexpected requests
|
||||
return Promise.reject(new Error('Unexpected request: ' + url));
|
||||
});
|
||||
|
||||
axios.get = mockedGet;
|
||||
|
||||
await actions.get({ commit });
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_LABEL_UI_FLAG, { isFetching: true }],
|
||||
[types.default.SET_LABELS, labelsList],
|
||||
[types.default.SET_LABEL_UI_FLAG, { isFetching: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.get.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await actions.get({ commit });
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_LABEL_UI_FLAG, { isFetching: true }],
|
||||
[types.default.SET_LABEL_UI_FLAG, { isFetching: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#create', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.post.mockResolvedValue({ data: labelsList[0] });
|
||||
await actions.create({ commit }, labelsList[0]);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_LABEL_UI_FLAG, { isCreating: true }],
|
||||
[types.default.ADD_LABEL, labelsList[0]],
|
||||
[types.default.SET_LABEL_UI_FLAG, { isCreating: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.post.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(actions.create({ commit })).rejects.toThrow(Error);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_LABEL_UI_FLAG, { isCreating: true }],
|
||||
[types.default.SET_LABEL_UI_FLAG, { isCreating: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#update', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.patch.mockResolvedValue({ data: labelsList[0] });
|
||||
await actions.update({ commit }, labelsList[0]);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_LABEL_UI_FLAG, { isUpdating: true }],
|
||||
[types.default.EDIT_LABEL, labelsList[0]],
|
||||
[types.default.SET_LABEL_UI_FLAG, { isUpdating: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(actions.update({ commit }, labelsList[0])).rejects.toThrow(
|
||||
Error
|
||||
);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_LABEL_UI_FLAG, { isUpdating: true }],
|
||||
[types.default.SET_LABEL_UI_FLAG, { isUpdating: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#delete', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.delete.mockResolvedValue({ data: labelsList[0] });
|
||||
await actions.delete({ commit }, labelsList[0].id);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_LABEL_UI_FLAG, { isDeleting: true }],
|
||||
[types.default.DELETE_LABEL, labelsList[0].id],
|
||||
[types.default.SET_LABEL_UI_FLAG, { isDeleting: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.delete.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(
|
||||
actions.delete({ commit }, labelsList[0].id)
|
||||
).rejects.toThrow(Error);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_LABEL_UI_FLAG, { isDeleting: true }],
|
||||
[types.default.SET_LABEL_UI_FLAG, { isDeleting: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
export default [
|
||||
{
|
||||
id: 1,
|
||||
title: 'customer-support',
|
||||
description: 'Customer support queries',
|
||||
color: '#0076FF',
|
||||
show_on_sidebar: true,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
title: 'saas-customer',
|
||||
description: 'Customers who have account on app.chatwoot.com',
|
||||
color: '#A8DBCB',
|
||||
show_on_sidebar: false,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
title: 'hosted-customer',
|
||||
description: 'Customers who have self-hosted instance',
|
||||
color: '#F50471',
|
||||
show_on_sidebar: false,
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
title: 'enterprise',
|
||||
description: 'Customers who are using enterprise',
|
||||
color: '#A90CFD',
|
||||
show_on_sidebar: false,
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
title: 'billing-enquiry',
|
||||
description: 'Queries on billing issues',
|
||||
color: '#74B57A',
|
||||
show_on_sidebar: false,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,30 @@
|
||||
import { getters } from '../../labels';
|
||||
import labels from './fixtures';
|
||||
describe('#getters', () => {
|
||||
it('getLabels', () => {
|
||||
const state = { records: labels };
|
||||
expect(getters.getLabels(state)).toEqual(labels);
|
||||
});
|
||||
|
||||
it('getLabelsOnSidebar', () => {
|
||||
const state = { records: labels };
|
||||
expect(getters.getLabelsOnSidebar(state)).toEqual([labels[0]]);
|
||||
});
|
||||
|
||||
it('getUIFlags', () => {
|
||||
const state = {
|
||||
uiFlags: {
|
||||
isFetching: true,
|
||||
isCreating: false,
|
||||
isUpdating: false,
|
||||
isDeleting: false,
|
||||
},
|
||||
};
|
||||
expect(getters.getUIFlags(state)).toEqual({
|
||||
isFetching: true,
|
||||
isCreating: false,
|
||||
isUpdating: false,
|
||||
isDeleting: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import types from '../../../mutation-types';
|
||||
import { mutations } from '../../labels';
|
||||
import labels from './fixtures';
|
||||
describe('#mutations', () => {
|
||||
describe('#SET_LABELS', () => {
|
||||
it('set label records', () => {
|
||||
const state = { records: [] };
|
||||
mutations[types.SET_LABELS](state, labels);
|
||||
expect(state.records).toEqual(labels);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#ADD_LABEL', () => {
|
||||
it('push newly created label to the store', () => {
|
||||
const state = { records: [labels[0]] };
|
||||
mutations[types.ADD_LABEL](state, labels[1]);
|
||||
expect(state.records).toEqual([labels[0], labels[1]]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#EDIT_LABEL', () => {
|
||||
it('update label record', () => {
|
||||
const state = { records: [labels[0]] };
|
||||
mutations[types.EDIT_LABEL](state, {
|
||||
id: 1,
|
||||
title: 'customer-support-queries',
|
||||
});
|
||||
expect(state.records[0].title).toEqual('customer-support-queries');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#DELETE_LABEL', () => {
|
||||
it('delete label record', () => {
|
||||
const state = { records: [labels[0]] };
|
||||
mutations[types.DELETE_LABEL](state, 1);
|
||||
expect(state.records).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user